mirror of
https://gitee.com/jisol/jisol-game/
synced 2025-09-27 02:36:14 +00:00
提交上阵
This commit is contained in:
@@ -7,12 +7,11 @@ import BaseData from "./BaseData";
|
||||
//聊天数据
|
||||
export default class ChatData extends BaseData{
|
||||
|
||||
static Event = "ChatData_Event_Message";
|
||||
|
||||
//世界消息列表
|
||||
datas:string[] = [];
|
||||
|
||||
//接受消息事件
|
||||
receives:Function[] = [];
|
||||
|
||||
onInit() {
|
||||
//监听聊天消息
|
||||
app.socket.on(GAction.CHAT_RECEIVE_MESSAGE,this.onChatReceiveMessage,this,GActionType.GUIChatMessage);
|
||||
@@ -23,7 +22,7 @@ export default class ChatData extends BaseData{
|
||||
onChatReceiveMessage(info:GUIChatMessage){
|
||||
console.log(`ChatData - onChatReceiveMessage`,info.message);
|
||||
this.datas.push(info.message);
|
||||
this.receives.forEach(fun => fun(info))
|
||||
app.event.emit(ChatData.Event,info);
|
||||
}
|
||||
|
||||
//发送消息
|
||||
@@ -32,14 +31,12 @@ export default class ChatData extends BaseData{
|
||||
}
|
||||
|
||||
//监听接受消息
|
||||
on(receive:Function){
|
||||
this.receives.push(receive);
|
||||
on(receive:Function,target?: any){
|
||||
app.event.on(ChatData.Event,receive,target)
|
||||
}
|
||||
//取消
|
||||
off(receive:Function){
|
||||
let index = this.receives.indexOf(receive);
|
||||
if(index != -1)
|
||||
this.receives.splice(index,1);
|
||||
off(receive:Function,target?: any){
|
||||
app.event.off(ChatData.Event,receive,target)
|
||||
}
|
||||
|
||||
}
|
||||
|
50
JisolGameCocos/assets/script/data/PlayerTacticalData.ts
Normal file
50
JisolGameCocos/assets/script/data/PlayerTacticalData.ts
Normal file
@@ -0,0 +1,50 @@
|
||||
import { API, PlayerTacticalOV } from "../consts/API";
|
||||
import BaseData from "./BaseData";
|
||||
|
||||
interface PlayerTacticalInfo extends PlayerTacticalOV{
|
||||
roles:number[], //上阵的宠物顺序
|
||||
}
|
||||
|
||||
//玩家阵法数据 (玩家最多上阵 9 个宠物)
|
||||
export default class PlayerTacticalData extends BaseData{
|
||||
|
||||
//阵法信息
|
||||
info:PlayerTacticalInfo;
|
||||
|
||||
async onInit() {
|
||||
|
||||
await this.onUpdateInfo();
|
||||
|
||||
}
|
||||
|
||||
//更新阵法信息
|
||||
async onUpdateInfo(){
|
||||
let ov = await API.GetPlayerTactical();
|
||||
if(!ov.tacticalData){
|
||||
ov.tacticalData = JSON.stringify(this.getTacticalInfo());
|
||||
}
|
||||
this.info = {
|
||||
...ov,
|
||||
roles: JSON.parse(ov.tacticalData),
|
||||
}
|
||||
}
|
||||
|
||||
//更新上阵
|
||||
async UpdateTactical(roles:number[]){
|
||||
this.info.roles = roles;
|
||||
this.info.tacticalData = JSON.stringify(this.info.roles);
|
||||
//上传到服务器
|
||||
await API.SetPlayerTactical(this.info);
|
||||
}
|
||||
|
||||
//获取指定位置
|
||||
getItem(index:number){
|
||||
return this.info.roles[index];
|
||||
}
|
||||
|
||||
//获取初始化上阵信息
|
||||
getTacticalInfo():number[]{
|
||||
return [0,0,0,0,0,0,0,0,0]
|
||||
}
|
||||
|
||||
}
|
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"ver": "4.0.23",
|
||||
"importer": "typescript",
|
||||
"imported": true,
|
||||
"uuid": "d2425352-add6-461a-ab20-32515cf9eb1e",
|
||||
"files": [],
|
||||
"subMetas": {},
|
||||
"userData": {}
|
||||
}
|
Reference in New Issue
Block a user