2293 lines
92 KiB
TypeScript
2293 lines
92 KiB
TypeScript
import SKNetTask, { NetCode } from "../gear_2.3.4/net/SKNetTask";
|
|
import FGHUD from "../gear_2.3.4/fgui/FGHUD";
|
|
import SKUIUtil from "../gear_2.3.4/util/SKUIUtil";
|
|
import SKSocket, { SocketCode } from "../gear_2.3.4/net/SKSocket";
|
|
import LocalUtil from "./LocalUtil";
|
|
import JSUtil = require("../core/JSUtil");
|
|
import SKTimeUtil from "../gear_2.3.4/util/SKTimeUtil";
|
|
import HorsePanel from "../horse/HorsePanel";
|
|
import AudioManager from "../gear_2.3.4/manager/AudioManager";
|
|
import MsgAlert from "../game/msg/MsgAlert";
|
|
import Report from "../gear_2.3.4/net/Report";
|
|
import ItemUtil from "./ItemUtil";
|
|
import SkillUtil from "../game/skill/core/SkillUtil";
|
|
import SKDataUtil from "../gear_2.3.4/util/SKDataUtil";
|
|
import Ranking from "../game/role/Ranking";
|
|
import Lottery from "../bag/Lottery";
|
|
import GameUtil from "./GameUtil";
|
|
import { MsgCode, GameState } from "./EEnum";
|
|
import TeamPanel from "../team/TeamPanel";
|
|
import Arena from "../arena/Arena";
|
|
import RechargeReward from "../rechargeReward/RechargeReward";
|
|
import Contact from "../contact/Contact";
|
|
import Question from "../question/Question";
|
|
import TurnTable from "../turnTable/TurnTable";
|
|
import BtlInfo from "../btlInfo/BtlInfo";
|
|
import Welfare from "../welfare/Welfare";
|
|
import Transformation from "../transformation/Transformation";
|
|
import DebateDao from "../debateDao/DebateDao";
|
|
import Gang from "../gang/Gang";
|
|
import Appearance from "../appearance/Appearance";
|
|
import FGAlert from "../gear_2.3.4/fgui/FGAlert";
|
|
import visitingPrison from "../visitingPrison";
|
|
import FactionTalent from "../FactionTalent";
|
|
import EquipRefine from "../EquipRefine";
|
|
import DailyActivity from "../DailyActivity";
|
|
import RoleInfoAlert from "../RoleInfoAlert";
|
|
import Set from "../set";
|
|
import Shop from "../Shop";
|
|
import GuoShop from "../GuoShop";
|
|
import GangWar from "../GangWar";
|
|
import PetRefine from "../petRefine";
|
|
import Debris from "../debris";
|
|
import Bag from "../bag/Bag";
|
|
import SocketUtil from "../gear_2.3.4/net/SocketUtil";
|
|
import DrawMoney from "../drawMoney";
|
|
import zhenFa from "../zhenFa/zhenfa";
|
|
import DestinyPannel from "../nurture/DestinyPannel";
|
|
import MyModel from "./MyModel";
|
|
import TianTiPanel from "../TianTiPanel/TianTiPanel";
|
|
import TianTiPiPei from "../TianTiPanel/TianTiPiPei";
|
|
// import ChatPanel from "../ChatPanel";
|
|
|
|
export default class GameModel {
|
|
// 單例
|
|
static shared: GameModel = new GameModel();
|
|
// 遊戲版本號
|
|
static version: string = "2.5.5"; // 是否為調試模試
|
|
static isDebug: boolean = false;
|
|
// 是否隱藏坐騎
|
|
static hideRide: boolean = false;
|
|
// 是否隱藏非組隊的玩家
|
|
static hideNotTeam: boolean = false;
|
|
// 當前場景名稱
|
|
static currentScene: string;
|
|
// 協定
|
|
static pbroot: any;
|
|
// 配置
|
|
static config: any;
|
|
// 裝備數據
|
|
static equipData: any;
|
|
static autoWorldVoice: number;
|
|
static serverData: any;
|
|
static conf_skill: any;
|
|
static conf_login: any;
|
|
// 充值獎勵
|
|
static conf_charge_reward: any;
|
|
static conf_charge_reward2: any;
|
|
static conf_charge_reward3: any;
|
|
static conf_equip: any;
|
|
static conf_create_bg: any;
|
|
static conf_role_color: any;
|
|
static conf_role: any;
|
|
static conf_map: any;
|
|
static conf_charge: any;
|
|
static conf_level: any;
|
|
static conf_npc: any;
|
|
static conf_pet: any;
|
|
static conf_res_anchor: any;
|
|
static conf_task: any;
|
|
static conf_transfer: any;
|
|
static conf_map_list: any = {};
|
|
static conf_transformation: any;
|
|
static conf_playing_method: any;
|
|
static conf_game_info: any;
|
|
// 遊戲配置
|
|
static game_conf: any;
|
|
// 寶寶頭像圖集
|
|
static voiceMgr: any;
|
|
static net: any;
|
|
static notice: any;
|
|
static player: any;
|
|
// 坐騎技能
|
|
static horseSkill: any;
|
|
|
|
// 預製體
|
|
static picPercent: cc.Prefab;
|
|
static picPercent2: cc.Prefab;
|
|
static picPercent3: cc.Prefab;
|
|
static picNotice: cc.Prefab;
|
|
static role: cc.Prefab;
|
|
static npc: cc.Prefab;
|
|
static preRoleBrodcast: cc.Prefab;
|
|
static talkUI: cc.Prefab;
|
|
// 資源
|
|
static chatEmojiAtlas: cc.SpriteAtlas;
|
|
static roleHeadAtlas: cc.SpriteAtlas;
|
|
static rolePosterAtlas: cc.SpriteAtlas;
|
|
static petHeadAtlas: cc.SpriteAtlas;
|
|
static houBanHeadAtlas: cc.SpriteAtlas;
|
|
static fontRes: cc.Font;
|
|
|
|
// 舊版臨時寵物支援數據 新版移除
|
|
static petSupportTempData: any = [];
|
|
noticeNum: number = 0;
|
|
tryTimer: number = 0;
|
|
static isFight: boolean = false;
|
|
hasRelogin: boolean = false;
|
|
static needKeep: boolean = false;
|
|
static needKeepType: number = 0;
|
|
static serial: number = 0;
|
|
static paoNpc: any = null;
|
|
static towerNpc: any = null;
|
|
static towerNpcList: any = {};
|
|
constructor() {
|
|
}
|
|
|
|
// 啟動
|
|
static launch() {
|
|
SkillUtil.launch();
|
|
GameModel.shared.registerProto();
|
|
AudioManager.prefix = "Audio/";
|
|
}
|
|
|
|
static getColor(num: number): cc.Color {
|
|
let color = cc.Color.WHITE;
|
|
if (num >= 0 && num < 1000000) {
|
|
color = cc.Color.WHITE;
|
|
} else if (num >= 1000000 && num < 10000000) {
|
|
color = cc.Color.YELLOW;
|
|
} else if (num >= 10000000 && num < 100000000) {
|
|
color = cc.color(0, 255, 255, 255);
|
|
} else if (num >= 100000000 && num < 1000000000) {
|
|
color = cc.Color.GREEN;
|
|
} else if (num >= 1000000000 && num < 10000000000) {
|
|
color = cc.color(255, 0, 120, 255);
|
|
}
|
|
return color;
|
|
}
|
|
|
|
static getRoleHead(roleId: number): cc.SpriteFrame {
|
|
if (!this.roleHeadAtlas) {
|
|
return;
|
|
}
|
|
let result = this.roleHeadAtlas.getSpriteFrame(`role_${roleId}`);
|
|
return result;
|
|
}
|
|
static getRolePosterHead(roleId: number): cc.SpriteFrame {
|
|
if (!this.rolePosterAtlas) {
|
|
return;
|
|
}
|
|
let result = this.rolePosterAtlas.getSpriteFrame(`${roleId}`);
|
|
return result;
|
|
}
|
|
static getHouBanHead(houbanId: number): cc.SpriteFrame {
|
|
if (!this.houBanHeadAtlas) {
|
|
return;
|
|
}
|
|
let result = this.houBanHeadAtlas.getSpriteFrame(`huoban_${houbanId}`);
|
|
return result;
|
|
}
|
|
|
|
getGameLogic(): any {
|
|
let scene = cc.director.getScene();
|
|
if (scene.name == 'MainScene') {
|
|
let logic = cc.find('Canvas').getComponent('GameLogic');
|
|
if (logic) {
|
|
return logic;
|
|
}
|
|
}
|
|
return null;
|
|
}
|
|
getBattleStageLogic(): any {
|
|
let scene = cc.director.getScene();
|
|
if (scene.name == 'MainScene') {
|
|
let node = cc.find("Canvas/BattleLayer/BattleStage");
|
|
if (!node) {
|
|
cc.warn(`$警告:獲得戰斗場景失敗!`);
|
|
return null;
|
|
}
|
|
let logic = node.getComponent('BattleStage');
|
|
if (logic) {
|
|
return logic;
|
|
}
|
|
}
|
|
return null;
|
|
}
|
|
// 重新登錄
|
|
relogin() {
|
|
FGHUD.hideLoading();
|
|
this.tryTimer = SKTimeUtil.cancelDelay(this.tryTimer);
|
|
if (this.hasRelogin) {
|
|
return;
|
|
}
|
|
this.hasRelogin = true;
|
|
let self = this;
|
|
this.tryTimer = SKTimeUtil.delay(() => {
|
|
self.goLogin();
|
|
}, 0.5);
|
|
}
|
|
// 跳到登錄界面
|
|
goLogin() {
|
|
let self = this;
|
|
GameModel.notice.addMsg(0, 100006, () => {
|
|
self.hasRelogin = false;
|
|
let battlelayer = cc.find('Canvas/BattleLayer');
|
|
if (battlelayer) {
|
|
battlelayer.destroyAllChildren();
|
|
}
|
|
SKUIUtil.loadScene("LoginScene", null, (sceneName) => {
|
|
GameModel.currentScene = sceneName;
|
|
});
|
|
});
|
|
|
|
}
|
|
relink1() {
|
|
FGHUD.showLoading("正在重連...");
|
|
let self = this;
|
|
let battlelayer = cc.find('Canvas/BattleLayer');
|
|
if (battlelayer) {
|
|
battlelayer.destroyAllChildren();
|
|
}
|
|
self.hasRelogin = false;
|
|
GameModel.login(GameModel.player.accountid, GameModel.player.roleid, GameModel.serverData.id);
|
|
}
|
|
// 重新連接
|
|
relink() {
|
|
FGHUD.showLoading("正在重連...");
|
|
let self = this;
|
|
SKSocket.reconnect(() => {
|
|
FGHUD.hideLoading();
|
|
self.relogin();
|
|
}, () => {
|
|
FGHUD.hideLoading();
|
|
GameModel.send('c2s_enter_game', {
|
|
accountid: GameModel.player.accountid
|
|
});
|
|
if (!GameModel.player.petInfo) {
|
|
//TODO
|
|
cc.log("fixed");
|
|
}
|
|
})
|
|
}
|
|
|
|
registerProto() {
|
|
let self = this;
|
|
SKSocket.disconnectBlock = () => {
|
|
self.relogin();
|
|
};
|
|
SKSocket.register("s2c_login", (data: any) => {
|
|
if (data.errorcode != 0) {
|
|
GameModel.notice.addMsg(0, data.errorcode, () => { });
|
|
let info = `登錄失敗[s2c_login]:${data.errorcode}`;
|
|
Report.report(info);
|
|
return;
|
|
}
|
|
let info = data.info;
|
|
if (!info) {
|
|
let info = `登錄返回無數據[s2c_login]`;
|
|
Report.report(info);
|
|
return;
|
|
}
|
|
GameModel.player.setUserInfo(info);
|
|
Report.roleId = info.roleid;
|
|
LocalUtil.setUserId(info.roleid);
|
|
SKUIUtil.loadScene("GameLoadScene", null, (sceneName) => {
|
|
GameModel.currentScene = sceneName;
|
|
});
|
|
});
|
|
SKSocket.register("s2c_operation_result", (data: any) => {
|
|
FGHUD.hideLoading();
|
|
MsgAlert.addMsg(GameUtil.msgText[data.code]);
|
|
});
|
|
SKSocket.register("s2c_otherlogin", (data: any) => {
|
|
MsgAlert.addMsg(`您的帳號在其他設備登錄了!`);
|
|
SKSocket.close();
|
|
});
|
|
SKSocket.register("s2c_change_map", (data: any) => {
|
|
let logic = this.getGameLogic()
|
|
if (logic) {
|
|
logic.mapLogic.changeMap(data.mapid, JSON.parse(data.pos), false);
|
|
}
|
|
});
|
|
SKSocket.register("s2c_team_info", (data: any) => {
|
|
let info = JSON.parse(data.info);
|
|
GameModel.player.setTeam(info);
|
|
|
|
if (TeamPanel.Instance && TeamPanel.Instance.teamPanel) {
|
|
let teamUI = TeamPanel.Instance.teamPanel.node;
|
|
if (teamUI)
|
|
TeamPanel.Instance.openTeamMainPanel(true);
|
|
}
|
|
|
|
// let goTeamUI = cc.find('Canvas/MainUI/TeamUI');
|
|
// if (goTeamUI) {
|
|
// goTeamUI.getComponent('TeamUI').CreateCardList();
|
|
// }
|
|
});
|
|
SKSocket.register("s2c_team_invite", (data: any) => {
|
|
FGAlert.show(`玩家[color=#009900]${data.leadername}[/color]邀請你加入他的隊伍`, () => {
|
|
FGAlert.hide();
|
|
GameModel.send("c2s_oper_invite", {
|
|
roleid: GameModel.player.roleid,
|
|
leaderid: data.leaderid,
|
|
operation: 0
|
|
})
|
|
}, () => {
|
|
FGAlert.hide();
|
|
GameModel.send("c2s_oper_invite", {
|
|
roleid: GameModel.player.roleid,
|
|
leaderid: data.leaderid,
|
|
operation: 1
|
|
})
|
|
})
|
|
})
|
|
|
|
SKSocket.register("s2c_recall_team", (data: any) => {
|
|
|
|
})
|
|
SKSocket.register("s2c_recall_role", (data: any) => {
|
|
if (data.roleid == GameModel.player.roleid) {
|
|
FGAlert.show("是否同意歸隊?", () => {
|
|
FGAlert.hide();
|
|
}, () => {
|
|
FGAlert.hide();
|
|
GameModel.send('c2s_recall_confirm', {
|
|
roleid: data.roleid
|
|
});
|
|
GameModel.player.tempLeave = false
|
|
})
|
|
}
|
|
})
|
|
SKSocket.register("s2c_team_list", (data: any) => {
|
|
let list = JSON.parse(data.list);
|
|
// let goTeamUI = cc.find('Canvas/MainUI/TeamUI');
|
|
// if (goTeamUI && goTeamUI.getChildByName('teamList').active) {
|
|
// goTeamUI.getChildByName('teamList').getComponent('TeamList').showTeamList(list);
|
|
// }
|
|
if (TeamPanel.Instance && TeamPanel.Instance.matchHallPanel) {
|
|
TeamPanel.Instance.openMatchHallPanel(null, null, list, true);
|
|
}
|
|
});
|
|
SKSocket.register("s2c_issue_recruit", (data: any) => {
|
|
console.log(data)
|
|
});
|
|
SKSocket.register("s2c_team_join", (data: any) => {
|
|
if (TeamPanel.Instance && TeamPanel.Instance.teamPanel) {
|
|
let teamUI = TeamPanel.Instance.teamPanel.node;
|
|
if (teamUI)
|
|
GameModel.send('c2s_team_requeslist', {});
|
|
else {
|
|
let uilogic = GameModel.player.getMainUILogic();
|
|
if (uilogic) {
|
|
uilogic.joinTeamWarn();
|
|
}
|
|
}
|
|
} else {
|
|
let uilogic = GameModel.player.getMainUILogic();
|
|
if (uilogic) {
|
|
uilogic.joinTeamWarn();
|
|
}
|
|
}
|
|
});
|
|
SKSocket.register("s2c_transfer_team_requst", (data: any) => {
|
|
let uilogic = GameModel.player.getMainUILogic();
|
|
if (uilogic) {
|
|
uilogic.transferTeamDlg(data);
|
|
}
|
|
});
|
|
SKSocket.register("s2c_team_requeslist", (data: any) => {
|
|
let list = data.list;
|
|
if (TeamPanel.Instance && TeamPanel.Instance.teamPanel) {
|
|
TeamPanel.Instance.requestList = list;
|
|
if (TeamPanel.Instance.requestListPanel && TeamPanel.Instance.requestListPanel.node) {
|
|
TeamPanel.Instance.openRequestList()
|
|
} else if (TeamPanel.Instance.teamPanel && TeamPanel.Instance.teamPanel.node) {
|
|
TeamPanel.Instance.openTeamMainPanel(true);
|
|
}
|
|
}
|
|
// let goTeamUI = cc.find('Canvas/MainUI/TeamUI');
|
|
// if (goTeamUI != null && goTeamUI.getChildByName('requestList').active == true) {
|
|
// goTeamUI.getChildByName('requestList').getComponent('TeamRequestList').showRequestList(list);
|
|
// }
|
|
});
|
|
SKSocket.register("s2c_charge", (data: any) => {
|
|
if (data.jade) {
|
|
GameModel.player.gameData.jade = data.jade;
|
|
}
|
|
if (data.chargesum) {
|
|
GameModel.player.chargesum = data.chargesum;
|
|
let mainUI = GameModel.player.getMainUILogic();
|
|
if (mainUI) {
|
|
mainUI.setVIPLevel();
|
|
mainUI.gameLogic.resetSelfPlayerTitle();
|
|
}
|
|
}
|
|
MsgAlert.addMsg(`玩家充值${data.money}人民幣成功!`);
|
|
let canvas = cc.find('Canvas');
|
|
let webUI = cc.find("ChargeWebUI", canvas);
|
|
if (webUI) {
|
|
webUI.removeFromParent();
|
|
}
|
|
|
|
if (!Welfare.Instance) return
|
|
Welfare.Instance.dayMap = SKDataUtil.jsonBy(data.dayMap);
|
|
});
|
|
SKSocket.register("s2c_charge_reward", (data: any) => {
|
|
if (RechargeReward.Instance.rewardPanel && RechargeReward.Instance.rewardPanel.node) {
|
|
if (data.flag == MsgCode.FAILED) {
|
|
RechargeReward.Instance.isRewarding = false;
|
|
return;
|
|
}
|
|
if (RechargeReward.Instance.panelType == 1) {
|
|
RechargeReward.Instance.dropItemsToBag();
|
|
}
|
|
if (RechargeReward.Instance.panelType == 2) {
|
|
}
|
|
}
|
|
});
|
|
SKSocket.register("s2c_prison_time", (data: any) => {
|
|
GameModel.player.changePrisonTime(data.time);
|
|
});
|
|
SKSocket.register("s2c_player_pos", (data: any) => {
|
|
let logic = this.getGameLogic()
|
|
if (logic) {
|
|
logic.synPlayerPos(data);
|
|
}
|
|
});
|
|
SKSocket.register("s2c_aoi_pinfo", (data: any) => {
|
|
let logic = this.getGameLogic();
|
|
if (logic) {
|
|
logic.synPlayerByFrame(data.list);
|
|
}
|
|
});
|
|
SKSocket.register("s2c_aoi_stop", (data: any) => {
|
|
let logic = this.getGameLogic();
|
|
if (logic) {
|
|
logic.synPlayerStop(data);
|
|
}
|
|
});
|
|
SKSocket.register("s2c_aoi_exit", (data: any) => {
|
|
let logic = this.getGameLogic();
|
|
if (logic) {
|
|
logic.synPlayerExit(data);
|
|
}
|
|
});
|
|
SKSocket.register("s2c_player_data", (data: any) => {
|
|
let logic = this.getGameLogic()
|
|
if (logic) {
|
|
logic.synPlayerData(data);
|
|
}
|
|
if (Shop.Instance)
|
|
Shop.Instance.refreshTopMoneyByType();
|
|
if (GuoShop.Instance)
|
|
GuoShop.Instance.refreshTopMoneyByType();
|
|
});
|
|
SKSocket.register("s2c_getZhenFaInfo", (data: any) => {
|
|
var info = SKDataUtil.jsonBy(data.info)
|
|
let mainUI = GameModel.player.getMainUILogic();
|
|
if (!!mainUI) {
|
|
mainUI.updateZhenFa(info);
|
|
}
|
|
});
|
|
SKSocket.register("s2c_active_zhenfa_info", (data: any) => {
|
|
MsgAlert.addMsg(`陣法激活${(0 == data.code) ? "成功" : "失敗"}!`);
|
|
});
|
|
SKSocket.register("s2c_upLevelZhenFa", (data: any) => {
|
|
MsgAlert.addMsg(`陣法升級成功!`);
|
|
let mainUI = GameModel.player.getMainUILogic();
|
|
if (!!mainUI) {
|
|
mainUI.updateZhenFa();
|
|
}
|
|
});
|
|
SKSocket.register("s2c_game_chat", (data: any) => {
|
|
// 測試文曲星
|
|
// data = {
|
|
// scale: 6,
|
|
// msg: JSON.stringify({ msg: "{eq:'sds',ea:'sd',eb:'sa',ec:'ds',ed:'s'}" })
|
|
// }
|
|
if (data.scale == 6 && Question.Instance) {
|
|
if (data.msg == '{"type":1000}') {
|
|
// 文曲星答題結束
|
|
Question.Instance.closeQuestionPanel();
|
|
return
|
|
}
|
|
// 激活文曲星答題
|
|
let time = new Date();
|
|
Question.Instance.openQuestionPanel(data.msg, time)
|
|
|
|
return
|
|
}
|
|
// if (data.scale == 3 && data.msg.indexOf("獲得在線獎勵")) return;
|
|
// ChatPanel.Instance.addMsg(data);
|
|
let logic = this.getGameLogic()
|
|
if (logic) {
|
|
logic.synChatInfo(data);
|
|
}
|
|
});
|
|
SKSocket.register("c2s_message", (data: any) => {
|
|
console.log(data)
|
|
});
|
|
SKSocket.register("s2c_close_exam", (data: any) => {
|
|
if (Question.Instance)
|
|
// 文曲星答題結束
|
|
Question.Instance.closeQuestionPanel();
|
|
});
|
|
SKSocket.register("s2c_friends_info", (data: any) => {
|
|
let logic = this.getGameLogic()
|
|
if (logic != null) {
|
|
logic.synGetFriendList(data.list);
|
|
}
|
|
});
|
|
SKSocket.register("s2c_search_friends", (data: any) => {
|
|
let logic = this.getGameLogic()
|
|
if (logic) {
|
|
logic.synSearchFriendList(data.list);
|
|
}
|
|
});
|
|
SKSocket.register("s2c_friend_chat", (data: any) => {
|
|
let logic = this.getGameLogic()
|
|
if (logic != null) {
|
|
logic.synFriendChatInfo(data);
|
|
}
|
|
});
|
|
SKSocket.register("s2c_friend_apply", (data: any) => {
|
|
let logic = this.getGameLogic()
|
|
if (logic != null) {
|
|
logic.synFriendAddTip();
|
|
}
|
|
});
|
|
SKSocket.register("s2c_mail_list", (data: any) => {
|
|
if (Contact.Instance.contactPanel && Contact.Instance.contactPanel.node) {
|
|
Contact.Instance.openContactPanel(data.list, true)
|
|
}
|
|
if (Contact.Instance)
|
|
Contact.Instance.checkHasNoRead(data.list)
|
|
})
|
|
SKSocket.register("s2c_run_action", (data: any) => {
|
|
if (Contact.Instance.contactPanel && Contact.Instance.contactPanel.node) {
|
|
GameModel.send("c2s_mail_list", {})
|
|
}
|
|
});
|
|
SKSocket.register("s2c_partner_exp", (data: any) => {
|
|
});
|
|
SKSocket.register("s2c_partner_exchange_exp_ok", (data: any) => {
|
|
JSUtil.s2c_partner_exchange_exp_ok(data);
|
|
});
|
|
SKSocket.register("s2c_partner_list", (data: any) => {
|
|
JSUtil.s2c_partner_list(data);
|
|
});
|
|
SKSocket.register("s2c_partner_info", (data: any) => {
|
|
JSUtil.s2c_partner_info(data);
|
|
});
|
|
SKSocket.register("c2s_other_info", (data: any) => {
|
|
let goMainUI = cc.find('Canvas/MainUI');
|
|
if (null == goMainUI) {
|
|
return;
|
|
}
|
|
cc.loader.loadRes(`Prefabs/PlayerFunUI`, cc.Prefab, (err, prefab) => {
|
|
let goFunUI = GameModel.createSubNode(goMainUI, {
|
|
nX: 0,
|
|
nY: 0
|
|
}, prefab, 'PlayerFunUI');
|
|
goFunUI.getComponent('PlayerFunUI').PlayerFunUI_Init2(data.nResID, data.nLevel, data.nRoleID, data.nRelive, data.strName, data.strBangName);
|
|
});
|
|
});
|
|
SKSocket.register("s2c_role_task_list", (data: any) => {
|
|
JSUtil.s2c_role_task_list(data);
|
|
});
|
|
SKSocket.register("s2c_notice", (data: any) => {
|
|
FGHUD.hideLoading();
|
|
MsgAlert.addMsg(data.strRichText);
|
|
|
|
if (data.strRichText = "變身時間到期,您的變身卡效果消失了") {
|
|
GameModel.player.tResid = 0;
|
|
}
|
|
if (RechargeReward.Instance && RechargeReward.Instance.rewardPanel && RechargeReward.Instance.rewardPanel.node) {
|
|
if (RechargeReward.Instance.isRewarding && data.strRichText == "你已領過該階段的獎勵了") {
|
|
RechargeReward.Instance.isRewarding = false;
|
|
RechargeReward.Instance.rewardIdx = -1;
|
|
}
|
|
}
|
|
});
|
|
SKSocket.register("s2c_screen_msg", (data: any) => {
|
|
JSUtil.createScreenNotice(data.strRichText, data.bInsertFront);
|
|
});
|
|
SKSocket.register("s2c_npc_notice", (data: any) => {
|
|
JSUtil.createNpcNotice(data.nNpcConfigID, data.strRichText);
|
|
});
|
|
SKSocket.register("s2c_star_waiting", (data: any) => {
|
|
GameUtil.createWaitTip('正在選擇對手', 2, null);
|
|
});
|
|
SKSocket.register("s2c_daily_info", (data: any) => {
|
|
var list = JSON.parse(data.strJson).mapActiveScore;
|
|
var score = 0
|
|
for (let i in list) {
|
|
score += list[i]
|
|
}
|
|
GameModel.player.todayActive = score;
|
|
DailyActivity.Instance.OnReceiveDailyInfo(SKDataUtil.jsonBy(data.strJson))
|
|
|
|
JSUtil.findAndDoUIFunction('DailyUI', 'OnReceiveDailyInfo', data.strJson);
|
|
|
|
if (TeamPanel.Instance && TeamPanel.Instance.teamTargetPanel) {
|
|
let teamUI = TeamPanel.Instance.teamTargetPanel.node;
|
|
if (teamUI) {
|
|
var list = SKDataUtil.jsonBy(data.strJson).mapDailyCnt;
|
|
TeamPanel.Instance.openTeamTargetPanel(list, true);
|
|
}
|
|
}
|
|
if (TeamPanel.Instance && TeamPanel.Instance.matchHallPanel) {
|
|
let teamUI = TeamPanel.Instance.matchHallPanel.node;
|
|
if (teamUI) {
|
|
var list = SKDataUtil.jsonBy(data.strJson).mapDailyCnt;
|
|
TeamPanel.Instance.openMatchHallPanel(list, true);
|
|
}
|
|
}
|
|
});
|
|
SKSocket.register("s2c_you_get_item", (data: any) => {
|
|
let itemData = ItemUtil.getItemData(data.nItem);
|
|
let icon = ItemUtil.getFGuiIcon(itemData);
|
|
let msg = ``;
|
|
let color = "#F4610C";
|
|
if (itemData.type == 0) {
|
|
color = "#24CC74"
|
|
} else if (itemData.type == 1) {
|
|
color = "#24ECE9"
|
|
} else if (itemData.type == 2) {
|
|
color = "#F5412E"
|
|
} else if (itemData.type <= 11) {
|
|
color = "#D02B32"
|
|
} else if (itemData.type <= 13) {
|
|
color = "#CD26C4"
|
|
}
|
|
if (data.nNum > 0) {
|
|
msg += `你獲得了[img]ui://main_ui/${icon}[/img][color=${color}][${itemData.name}][/color]${Math.abs(data.nNum)}個]`;
|
|
} else {
|
|
msg += `你消耗你[img]ui://main_ui/${icon}[/img][color=${color}][${itemData.name}][/color]${Math.abs(data.nNum)}個]`;
|
|
}
|
|
MsgAlert.addMsg(msg);
|
|
});
|
|
SKSocket.register("s2c_create_task_npc", (data: any) => {
|
|
});
|
|
SKSocket.register("s2c_paihang", (data: any) => {
|
|
let info = JSON.parse(data.vecRow);
|
|
let selfInfo = null;
|
|
if (data.brole)
|
|
selfInfo = JSON.parse(data.brole);
|
|
if (Ranking.shared.main) {
|
|
Ranking.shared.refresh(data.rankKind, info, selfInfo);
|
|
}
|
|
|
|
if (Arena.Instance && Arena.Instance.arenaPanel) {
|
|
if (Arena.Instance.arenaPanel.node)
|
|
Arena.Instance.openArenaPanel(info, selfInfo, true);
|
|
}
|
|
});
|
|
SKSocket.register("s2c_jingji_battleres", (data: any) => {
|
|
console.log(data)
|
|
});
|
|
|
|
SKSocket.register("s2c_roles_goods", (data: any) => {
|
|
JSUtil.setVecMyGoods(data.vecGoods);
|
|
JSUtil.findAndDoUIFunction('ShopUI', 'OnReceiveMyGoods', 0);
|
|
JSUtil.findAndDoUIFunction('ShangJiaUI', 'ShowSellingItem', 0);
|
|
});
|
|
SKSocket.register("s2c_goods", (data: any) => {
|
|
let goShopUI = cc.find('Canvas/MainUI/ShopUI');
|
|
if (!goShopUI) {
|
|
return;
|
|
}
|
|
let comShopUI = goShopUI.getComponent('ShopUI');
|
|
comShopUI.InitGoodList(data.vecGoods);
|
|
});
|
|
SKSocket.register("s2c_add_exp", (data: any) => {
|
|
let str = cc.js.formatStr('你獲得了%s', "[img]ui://main_ui/ui_common_icon_exp[/img][color=#00FF00]" + data.addexp + "[/color]");
|
|
MsgAlert.addMsg(str);
|
|
if (data.onlyid == GameModel.player.onlyid) {
|
|
GameModel.player.changeExp(data.curexp)
|
|
}
|
|
});
|
|
SKSocket.register("s2c_level_up", (data: any) => {
|
|
if (data.onlyid == GameModel.player.onlyid) {
|
|
GameModel.player.levelUp(data.curlevel);
|
|
}
|
|
});
|
|
SKSocket.register("s2c_you_money", (data: any) => {
|
|
let kind = data.nKind;
|
|
let nNum = data.nNum;
|
|
let nAdd = data.nChange;
|
|
let szKind = ['銀兩', '仙玉', '綁定仙玉', '', '', '競技場積分', '幫貢', '師貢', '地宮積分', '除魔積分', '郭氏積分'];
|
|
if (kind == 0 || kind == 1 || kind == 2 || kind == 5 || kind == 6 || kind == 7 || kind == 8 || kind == 9 || kind == 10) {
|
|
let strTip = szKind[kind] + (nAdd >= 0 ? ` +${nAdd}` : ` ${nAdd}`);
|
|
if (data.flag == MsgCode.SUCCESS)
|
|
MsgAlert.addMsg(strTip);
|
|
}
|
|
switch (kind) {
|
|
case 0:
|
|
GameModel.player.gameData.money = nNum;
|
|
break;
|
|
case 1:
|
|
GameModel.player.gameData.jade = nNum;
|
|
break;
|
|
case 2:
|
|
GameModel.player.gameData.bindjade = nNum;
|
|
break;
|
|
case 3:
|
|
GameModel.player.gameData.shuilugj = nNum;
|
|
break;
|
|
// case 4:
|
|
// GameModel.player.gameData.shuilugj = nNum;
|
|
// break;
|
|
case 5:
|
|
GameModel.player.gameData.jpoint = nNum;
|
|
break;
|
|
case 6:
|
|
GameModel.player.gameData.bangscore = nNum;
|
|
break;
|
|
case 7:
|
|
GameModel.player.gameData.shiscore = nNum;
|
|
break;
|
|
case 8:
|
|
GameModel.player.gameData.discore = nNum;
|
|
break;
|
|
case 9:
|
|
GameModel.player.gameData.xiuscore = nNum;
|
|
break;
|
|
case 10:
|
|
GameModel.player.gameData.guoscore = nNum;
|
|
break;
|
|
}
|
|
JSUtil.findAndDoUIFunction('ShopUI', 'SetMoneyInfo', 0);
|
|
JSUtil.findAndDoUIFunction('BagPanel', 'SetMoneyInfo', 0);
|
|
JSUtil.findAndDoUIFunction('DailyUI', 'SetMoneyInfo', 0);
|
|
JSUtil.findAndDoUIFunction('RolePanel', 'SetMoneyInfo', 0);
|
|
JSUtil.findAndDoUIFunction('NpcShopUI', 'SetMoneyInfo', 0);
|
|
if (Bag.Instance)
|
|
Bag.Instance.refreshTopMoney();
|
|
if (Shop.Instance)
|
|
Shop.Instance.refreshTopMoney();
|
|
if (GuoShop.Instance)
|
|
GuoShop.Instance.refreshTopMoneyByType();
|
|
});
|
|
SKSocket.register("s2c_bagitem", (data: any) => {
|
|
if (data == null) return
|
|
let logic = this.getGameLogic()
|
|
if (logic) {
|
|
logic.synBagItemList(data);
|
|
}
|
|
if (GuoShop.Instance) {
|
|
// GuoShop.Instance.refreshSaleView()
|
|
}
|
|
});
|
|
//開啟背包格子
|
|
SKSocket.register("s2c_open_backpack_grid", (data: any) => {
|
|
let logic = this.getGameLogic()
|
|
if (logic) {
|
|
logic.synbackpackNum(data);
|
|
}
|
|
});
|
|
SKSocket.register("s2c_debris_mall", (data: any) => {
|
|
Debris.Instance.refreshPanel(SKDataUtil.jsonBy(data.debris))
|
|
});
|
|
SKSocket.register("s2c_debris_mall_convert", (data: any) => {
|
|
if (data.state == MsgCode.SUCCESS) {
|
|
var itemData = ItemUtil.getItemData(data.serial);
|
|
MsgAlert.addMsg(`成功兌換${itemData.name}`);
|
|
Debris.Instance.refreshDebrisNum(data.num);
|
|
}
|
|
});
|
|
SKSocket.register("s2c_mallitems", (data: any) => {
|
|
Shop.Instance.initDuoBaoGeData(JSON.parse(data.info))
|
|
// let goShopUI = cc.find('Canvas/MainUI/ShopUI');
|
|
// if (goShopUI == null) {
|
|
// return;
|
|
// }
|
|
// let comShopUI = goShopUI.getComponent('ShopUI');
|
|
// comShopUI.InitMallList(data);
|
|
});
|
|
SKSocket.register("s2c_integralmall", (data: any) => {
|
|
Shop.Instance.initJiFenData(JSON.parse(data.info))
|
|
GuoShop.Instance.initShopData(JSON.parse(data.info))
|
|
});
|
|
SKSocket.register("s2c_npc_shop_item", (data: any) => {
|
|
|
|
let goNpcShopUI = cc.find('Canvas/MainUI/NpcShopUI');
|
|
if (goNpcShopUI) {
|
|
console.log("s2c_npc_shop_item go to goNpcShopUI")
|
|
let comNpcShopUI = goNpcShopUI.getComponent('NpcShopUI');
|
|
comNpcShopUI.InitNpcShopGoodsList(data);
|
|
}
|
|
// 競技場,新做購物界面
|
|
if (Arena.Instance && Arena.Instance.convertPanel) {
|
|
if (Arena.Instance.convertPanel.node)
|
|
Arena.Instance.openConvertPanel(JSON.parse(data.info).goods, true);
|
|
}
|
|
});
|
|
SKSocket.register("s2c_lottery_info", (data: any) => {
|
|
Lottery.shared.refresh(data.strJson);
|
|
GameModel.player.getLogic().playStop();
|
|
});
|
|
SKSocket.register("s2c_lottery_result", (data: any) => {
|
|
Lottery.shared.dugEnd(data);
|
|
});
|
|
SKSocket.register("s2c_relive_list", (data: any) => {
|
|
JSUtil.findAndDoUIFunction('RestoryUI', 'Init', data.strJson);
|
|
});
|
|
SKSocket.register("s2c_level_reward", (data: any) => {
|
|
if (data.level) {
|
|
let item = GameModel.conf_level[data.level];
|
|
for (let reward of item.reward_item.split(';')) {
|
|
reward = reward.split(':');
|
|
let item = ItemUtil.getItemData(reward[0]);
|
|
let icon = ItemUtil.getFGuiIcon(item);
|
|
let msg = `獲得[img]ui://main_ui/${icon}[/img][${item.name}]x${reward[1]}`;
|
|
MsgAlert.addMsg(msg);
|
|
}
|
|
if (GameModel.player.level_reward == '')
|
|
GameModel.player.level_reward += data.level;
|
|
else
|
|
GameModel.player.level_reward += ':' + data.level;
|
|
if (Welfare.Instance) {
|
|
if (Welfare.Instance.levelRewardView && Welfare.Instance.levelRewardView.node) {
|
|
Welfare.Instance.openLevelRewardView();
|
|
}
|
|
}
|
|
}
|
|
});
|
|
SKSocket.register("s2c_lockeritem", (data: any) => {
|
|
let logic = this.getGameLogic()
|
|
if (logic != null) {
|
|
logic.synLockerItemList(data);
|
|
}
|
|
});
|
|
SKSocket.register("s2c_incense_state", (data: any) => {
|
|
let logic = this.getGameLogic()
|
|
if (logic != null) {
|
|
logic.synIncenseState(data);
|
|
}
|
|
});
|
|
SKSocket.register("s2c_getbanglist", (data: any) => {
|
|
// let logic = this.getGameLogic()
|
|
// if (logic != null) {
|
|
// logic.synBangList(data.list);
|
|
// }
|
|
if (!SKUIUtil.isFGUIValid(Gang.Instance.gangListPanel)) return;
|
|
Gang.Instance.refreshGangListPanel(data.list);
|
|
});
|
|
SKSocket.register("s2c_join_bang", (data: any) => {
|
|
let uilogic = GameModel.player.getMainUILogic();
|
|
if (uilogic) {
|
|
uilogic.joinBangWarn();
|
|
}
|
|
});
|
|
SKSocket.register("s2c_getbanginfo", (data: any) => {
|
|
// let logic = this.getGameLogic()
|
|
// if (logic != null) {
|
|
// logic.synBangInfo(data);
|
|
// logic.resetSelfPlayerTitle();
|
|
// }
|
|
GameModel.player.bangid = data.info.bangid;
|
|
Gang.Instance.refreshGangPanel(data);
|
|
});
|
|
SKSocket.register("s2c_getbangrequest", (data: any) => {
|
|
// let logic = this.getGameLogic()
|
|
// if (logic != null) {
|
|
// logic.synBangRequest(data);
|
|
// }
|
|
Gang.Instance.refreshGangRequest(data.requestlist);
|
|
});
|
|
|
|
SKSocket.register("s2c_dial_info", (data: any) => {
|
|
if (TurnTable.Instance && TurnTable.Instance.node) {
|
|
TurnTable.Instance.openTurnTable(true, data)
|
|
}
|
|
});
|
|
|
|
SKSocket.register("s2c_dial_result", (data: any) => {
|
|
if (TurnTable.Instance && TurnTable.Instance.node) {
|
|
TurnTable.Instance.onlyRefreshTimes(data)
|
|
TurnTable.Instance.dropItemToBag()
|
|
}
|
|
});
|
|
SKSocket.register("s2c_getbangrequest_info", (data: any) => {
|
|
let uilogic = GameModel.player.getMainUILogic();
|
|
if (uilogic) {
|
|
uilogic.bangInfo(data);
|
|
}
|
|
});
|
|
SKSocket.register("s2c_new_pet", (data: any) => {
|
|
let logic = this.getGameLogic()
|
|
if (logic != null) {
|
|
logic.choosePet(data);
|
|
}
|
|
});
|
|
SKSocket.register("s2c_get_petlist", (data: any) => {
|
|
let logic = this.getGameLogic()
|
|
if (logic) {
|
|
logic.synPetInfo(data);
|
|
}
|
|
});
|
|
SKSocket.register("s2c_change_pet", (data: any) => {
|
|
let logic = this.getGameLogic()
|
|
if (logic != null) {
|
|
logic.synChangePet(data);
|
|
}
|
|
});
|
|
SKSocket.register("s2c_del_pet", (data: any) => {
|
|
let logic = this.getGameLogic()
|
|
if (logic != null) {
|
|
logic.synDelPet(data);
|
|
}
|
|
});
|
|
SKSocket.register("s2c_pet_info", (data: any) => {
|
|
let logic = this.getGameLogic()
|
|
if (logic != null) {
|
|
logic.synUpdatePet(data);
|
|
}
|
|
});
|
|
SKSocket.register("s2c_update_pet", (data: any) => {
|
|
let logic = this.getGameLogic()
|
|
if (logic != null) {
|
|
logic.synUpdatePet(data);
|
|
}
|
|
});
|
|
SKSocket.register("s2c_pet_changeSskill", (data: any) => {
|
|
let logic = this.getGameLogic()
|
|
if (logic != null) {
|
|
logic.updatePetSSkill(data.petid, data.skillid);
|
|
}
|
|
});
|
|
SKSocket.register("s2c_pet_skill_grid", (data: any) => {
|
|
data.info = JSON.parse(data.petInfo)
|
|
let logic = this.getGameLogic()
|
|
if (logic != null) {
|
|
logic.synUpdatePet(data);
|
|
}
|
|
});
|
|
SKSocket.register("s2c_wash_petproperty", (data: any) => {
|
|
let washnode = cc.find('Canvas/MainUI/PetPanel/washProperty');
|
|
if (washnode) {
|
|
let logic = washnode.getComponent('WashProperty');
|
|
logic.washProperty(data);
|
|
}
|
|
});
|
|
SKSocket.register("s2c_highwash_petproperty", (data: any) => {
|
|
let washnode = cc.find('Canvas/MainUI/PetPanel/washProperty');
|
|
let logic = null;
|
|
if (washnode)
|
|
logic = washnode.getComponent('WashProperty');
|
|
|
|
PetRefine.Instance.openEquipRefinePanel(SKDataUtil.jsonBy(data.data), logic.curLevel)
|
|
});
|
|
SKSocket.register("s2c_save_petproperty", (data: any) => {
|
|
// console.log(data)
|
|
let washnode = cc.find('Canvas/MainUI/PetPanel/washProperty');
|
|
if (washnode) {
|
|
let logic = washnode.getComponent('WashProperty');
|
|
logic.saveProperty(data);
|
|
}
|
|
});
|
|
SKSocket.register("s2c_equip_list", (data: any) => {
|
|
let logic = this.getGameLogic()
|
|
if (logic) {
|
|
logic.synEquipList(data);
|
|
}
|
|
});
|
|
SKSocket.register("s2c_next_equip", (data: any) => {
|
|
let logic = this.getGameLogic()
|
|
if (logic != null) {
|
|
logic.synNextEquip(data);
|
|
}
|
|
});
|
|
SKSocket.register("s2c_equip_info", (data: any) => {
|
|
let logic = this.getGameLogic()
|
|
if (logic) {
|
|
logic.synEquipInfo(data);
|
|
}
|
|
});
|
|
SKSocket.register("s2c_equip_property", (data: any) => {
|
|
let logic = this.getGameLogic()
|
|
if (logic) {
|
|
logic.synEquipProperty(data);
|
|
}
|
|
});
|
|
SKSocket.register("s2c_attribute_score", (data: any) => {
|
|
let logic = this.getGameLogic()
|
|
if (logic) {
|
|
logic.synEquipPropertyScore(data.attributeScore);
|
|
}
|
|
});
|
|
// 佩飾鑑定
|
|
SKSocket.register("s2c_acc_authenticate", (data: any) => {
|
|
let logic = this.getGameLogic()
|
|
if (logic) {
|
|
logic.authenticate(data);
|
|
}
|
|
});
|
|
SKSocket.register("s2c_change_weapon", (data: any) => {
|
|
let logic = this.getGameLogic()
|
|
if (logic != null) {
|
|
logic.synChangeWeapon(data.weapon);
|
|
}
|
|
});
|
|
SKSocket.register("s2c_xianqi_list", (data: any) => {
|
|
let logic = this.getGameLogic()
|
|
if (logic != null) {
|
|
logic.synXianQiList(data);
|
|
}
|
|
});
|
|
SKSocket.register("s2c_btl", (data: any) => {
|
|
GameModel.isFight = true;
|
|
// 檢查 水陸大會
|
|
console.log(SKDataUtil.clone(data))
|
|
JSUtil.shuiLuMgr().destroyShuiLuReadyBtl();
|
|
let gamelogic = this.getGameLogic();
|
|
|
|
gamelogic.enterBattle(data.teamS, data.teamE, data.petlist);
|
|
|
|
// 戰鬥開始回合置零
|
|
if (BtlInfo.Instance) {
|
|
BtlInfo.Instance.btlRound = 0;
|
|
}
|
|
if (Arena.Instance && !Arena.Instance.isBtlHide && Arena.Instance.arenaPanel) {
|
|
Arena.Instance.hideArenaPanel();
|
|
}
|
|
|
|
if (GangWar.Instance) {
|
|
GangWar.Instance.hideMainPanel()
|
|
}
|
|
});
|
|
//pk標題
|
|
SKSocket.register("s2c_pktitle", (data: any) => {
|
|
let battleui = cc.find('Canvas/BattleUILayer/BattleUI');
|
|
if (battleui != null) {
|
|
let btlUIlogic = battleui.getComponent('BattleUI');
|
|
btlUIlogic.changePkTitle(data.info);
|
|
}
|
|
});
|
|
//請求PK
|
|
SKSocket.register("s2c_exchange_views", (data: any) => {
|
|
let uilogic = GameModel.player.getMainUILogic();
|
|
if (uilogic) {
|
|
uilogic.exchangeViews(data);
|
|
}
|
|
});
|
|
SKSocket.register("s2c_report_info", (data: any) => {
|
|
if (Arena.Instance && Arena.Instance.arenaPanel) {
|
|
if (Arena.Instance.arenaPanel.node)
|
|
Arena.Instance.openReportPanel(JSON.parse(data.report), true);
|
|
}
|
|
});
|
|
|
|
SKSocket.register("s2c_btl_roundbegin", (data: any) => {
|
|
let btllogic = this.getBattleStageLogic();
|
|
if (btllogic) {
|
|
btllogic.btlRoundBegin(data);
|
|
}
|
|
|
|
if (BtlInfo.Instance)
|
|
BtlInfo.Instance.addRoundInfo()
|
|
});
|
|
SKSocket.register("s2c_btl_round", (data: any) => {
|
|
console.log("\n\n\n本輪戰鬥執行操作數據修改前", SKDataUtil.clone(data))
|
|
if (data.acts) {
|
|
for (let i = 0; i < data.acts.length; i++) {
|
|
// 如果存在act列表
|
|
if (data.acts[i].act && data.acts[i].act.length > 0) {
|
|
for (let j = 0; j < data.acts[i].act.length; j++) {
|
|
// 龍族變身處理
|
|
if (data.acts[i].act[j].targetid == 1045) {
|
|
data.acts[i].act.splice(j, 1);
|
|
let item = { actid: data.acts[i].actid, actionid: 1045, action: 1, actbef: null, act: [] }
|
|
data.acts.splice(i, 0, item)
|
|
i++;
|
|
}
|
|
// else
|
|
// if (data.acts[i].act[j].targetid != 0) {
|
|
// data.acts[i].act[j].fan = 0
|
|
// data.acts[i].act[j].selfid = data.acts[i].actid
|
|
// data.acts[i].act[j].selfdead = 0
|
|
// data.acts[i].act[j].selfhp = 0
|
|
// data.acts[i].act[j].selfactaffix = "{}"
|
|
// }
|
|
}
|
|
}
|
|
}
|
|
// 去掉防禦
|
|
for (let i = 0; i < data.acts.length; i++) {
|
|
if (data.acts[i].actionid == 1002) {
|
|
data.acts.splice(i, 1)
|
|
i--;
|
|
}
|
|
}
|
|
}
|
|
|
|
console.log("\n\n\n本輪戰鬥執行操作數據", SKDataUtil.clone(data))
|
|
console.log("\n\n")
|
|
let btllogic = this.getBattleStageLogic();
|
|
if (btllogic) {
|
|
btllogic.btlRound(data);
|
|
}
|
|
});
|
|
SKSocket.register("s2c_btl_end", (data: any) => {
|
|
GameModel.isFight = false;
|
|
let gamelogic = this.getGameLogic();
|
|
if (gamelogic) {
|
|
gamelogic.exitBattle(data);
|
|
}
|
|
let battleui = cc.find('Canvas/BattleUILayer/BattleUI');
|
|
if (battleui != null) {
|
|
let btlUIlogic = battleui.getComponent('BattleUI');
|
|
btlUIlogic.hidePkTitle(data.info);
|
|
}
|
|
if (BtlInfo.Instance) {
|
|
BtlInfo.Instance.closePanel();
|
|
}
|
|
if (Arena.Instance && Arena.Instance.isBtlHide && Arena.Instance.arenaPanel) {
|
|
Arena.Instance.showArenaPanel();
|
|
}
|
|
if (GangWar.Instance)
|
|
GangWar.Instance.showMainPanel()
|
|
});
|
|
SKSocket.register("s2c_btl_act", (data: any) => {
|
|
let btllogic = this.getBattleStageLogic();
|
|
if (btllogic) {
|
|
btllogic.playerAction(data);
|
|
}
|
|
});
|
|
SKSocket.register("s2c_relive", (data: any) => {
|
|
let relive_layer = cc.find('Canvas/relivelayer');
|
|
if (relive_layer) {
|
|
relive_layer.destroy();
|
|
}
|
|
if (data.result == 0) {
|
|
GameModel.player.setUserInfo(data.info);
|
|
let rolelogic = GameModel.player.getLogic();
|
|
rolelogic.setInfo(GameModel.player);
|
|
let logic = this.getGameLogic()
|
|
if (logic != null) {
|
|
logic.synPlayerData(data.data);
|
|
}
|
|
let uilogic = GameModel.player.getMainUILogic();
|
|
uilogic.setHeadIcon(GameModel.player.resid);
|
|
let battleui = cc.find('Canvas/BattleUILayer/BattleUI');
|
|
if (battleui != null) {
|
|
let btlUIlogic = battleui.getComponent('BattleUI');
|
|
btlUIlogic.initSkillPanel();
|
|
}
|
|
}
|
|
});
|
|
SKSocket.register("s2c_changerace", (data: any) => {
|
|
let changerace_layer = cc.find('Canvas/changeracelayer');
|
|
if (changerace_layer) {
|
|
changerace_layer.destroy();
|
|
}
|
|
if (data.result == 0) {
|
|
GameModel.player.setUserInfo(data.info);
|
|
let rolelogic = GameModel.player.getLogic();
|
|
rolelogic.setInfo(GameModel.player);
|
|
let logic = this.getGameLogic()
|
|
if (logic != null) {
|
|
logic.synPlayerData(data.data);
|
|
}
|
|
let uilogic = GameModel.player.getMainUILogic();
|
|
uilogic.setHeadIcon(GameModel.player.resid);
|
|
let battleui = cc.find('Canvas/BattleUILayer/BattleUI');
|
|
if (battleui != null) {
|
|
let btlUIlogic = battleui.getComponent('BattleUI');
|
|
btlUIlogic.initSkillPanel();
|
|
}
|
|
// 重置 戰鬥自動技能
|
|
LocalUtil.set('battle_r_skill', 0);
|
|
}
|
|
});
|
|
SKSocket.register("s2c_hongbao_open", (data: any) => {
|
|
let uilogic = GameModel.player.getMainUILogic();
|
|
if (uilogic) {
|
|
uilogic.showHongBaoIcon();
|
|
}
|
|
});
|
|
SKSocket.register("s2c_hongbao_result", (data: any) => {
|
|
let uilogic = GameModel.player.getMainUILogic();
|
|
if (uilogic) {
|
|
uilogic.hideHongBaoPanel();
|
|
uilogic.hideHongBaoIcon();
|
|
}
|
|
if (data.errorcode != 0) {
|
|
MsgAlert.addMsg(data.errorcode);
|
|
}
|
|
});
|
|
SKSocket.register("s2c_remunerate", (data: any) => {
|
|
if (data.errorcode != 0) {
|
|
if (data.errorcode == MsgCode.GIFT_HAS_GOT) {
|
|
MsgAlert.addMsg(`沒有禮包或者已經領過了!`);
|
|
}
|
|
} else {
|
|
Welfare.Instance.refreshFirshCharge()
|
|
}
|
|
});
|
|
SKSocket.register("s2c_shuilu_sign", (data: any) => {
|
|
if (data.errorcode == 0) {
|
|
MsgAlert.addMsg('已報名,請不要離開比武場,離開即視為放棄!');
|
|
JSUtil.shuiLuMgr().changeState(data.shuilustate);
|
|
} else {
|
|
MsgAlert.addMsg(data.errorcode);
|
|
}
|
|
});
|
|
SKSocket.register("s2c_shuilu_unsign", (data: any) => {
|
|
if (data.errorcode == 0) {
|
|
MsgAlert.addMsg('離開比武場,自動放棄水陸大會');
|
|
JSUtil.shuiLuMgr().destroyShuiLuIcon();
|
|
JSUtil.shuiLuMgr().destroyShuiLuPanel();
|
|
} else {
|
|
MsgAlert.addMsg(data.errorcode);
|
|
}
|
|
});
|
|
SKSocket.register("s2c_shuilu_info", (data: any) => {
|
|
JSUtil.shuiLuMgr().showShuiLuPanel(data);
|
|
});
|
|
SKSocket.register("s2c_world_reward_list", (data: any) => {
|
|
JSUtil.worldRewardMgr().showLoadList(data);
|
|
});
|
|
SKSocket.register("s2c_shuilu_match", (data: any) => {
|
|
JSUtil.shuiLuMgr().showReadyBattle(data);
|
|
});
|
|
SKSocket.register("s2c_shuilu_state", (data: any) => {
|
|
JSUtil.shuiLuMgr().changeState(data.slstate);
|
|
});
|
|
SKSocket.register("s2c_shuilu_battleres", (data: any) => {
|
|
JSUtil.shuiLuMgr().showBtlEnd(data);
|
|
});
|
|
SKSocket.register("s2c_title_info", (data: any) => {
|
|
JSUtil.setRoleTitleUIMgr().initTitles(data);
|
|
});
|
|
SKSocket.register("s2c_title_change", (data: any) => {
|
|
JSUtil.setRoleTitleUIMgr().onRoleTitleChanged(data);
|
|
});
|
|
SKSocket.register("s2c_leavebang", (data: any) => {
|
|
let logic = this.getGameLogic()
|
|
if (logic && data.ecode == 0) {
|
|
logic.clearSelfRoleTitleInfo();
|
|
// logic.closeBangList();
|
|
// logic.resetSelfPlayerTitle();
|
|
}
|
|
});
|
|
SKSocket.register("s2c_linghou_fight", (data: any) => {
|
|
if (data.errorcode != 0) {
|
|
MsgAlert.addMsg(data.ecode);
|
|
}
|
|
});
|
|
SKSocket.register("s2c_update_shop_info", (data: any) => {
|
|
let npcShopUI = cc.find('Canvas/MainUI/NpcShopUI');
|
|
if (npcShopUI) {
|
|
let npcShopUIScript = npcShopUI.getComponent('NpcShopUI');
|
|
npcShopUIScript.updateGoodsInfo(data);
|
|
}
|
|
});
|
|
SKSocket.register("s2c_palace_fight", (data: any) => {
|
|
console.log('s2c_palace_fight', data);
|
|
let pficon = cc.find('Canvas/MainUI/PalaceFightIcon');
|
|
if (pficon) {
|
|
let notice = null;
|
|
let node = cc.find('Canvas/PalaceNotice');
|
|
if (node) {
|
|
notice = node.getComponent('PalaceNotice');
|
|
}
|
|
if (data.type == 1) {
|
|
if (data.recipient.state == 2 && data.sponsor.state == 1) { // 有玩家放棄決鬥
|
|
let strRichText = `<color=#00FF00>玩家</c><color=#FFFF00>[${data.recipient.name}]${data.recipient.roleid}</c><color=#00FF00>放棄了玩家</c><color=#FFFF00>[${data.sponsor.name}]${data.sponsor.roleid}</c><color=#00FF00>與玩家</c><color=#FFFF00>[${data.recipient.name}]${data.recipient.roleid}</c><color=#00FF00>的皇城決鬥,真是聳! </c>`;
|
|
if (notice) {
|
|
notice.addStrToList(strRichText);
|
|
}
|
|
}
|
|
if (data.recipient.state == 0 && data.sponsor.state == 1) { // 有玩家決鬥
|
|
let strRichText = '';
|
|
if (data.msg.length > 0) {
|
|
strRichText = `<color=#00FF00>玩家</c><color=#FFFF00>[${data.sponsor.name}]${data.sponsor.roleid}</c><color=#00FF00>邀請玩家</c><color=#FFFF00>[${data.recipient.name}]${data.recipient.roleid}</c><color=#00FF00>進行皇城決鬥,並寫下戰書:</c><color=#FF0000>${data.msg}</c>`;
|
|
} else {
|
|
strRichText = `<color=#00FF00>玩家</c><color=#FFFF00>[${data.sponsor.name}]${data.sponsor.roleid}</c><color=#00FF00>邀請玩家</c><color=#FFFF00>[${data.recipient.name}]${data.recipient.roleid}</c><color=#00FF00>進行皇城決鬥! </c>`;
|
|
}
|
|
if (notice) {
|
|
notice.addStrToList(strRichText);
|
|
}
|
|
}
|
|
if (data.win == 1) { // 決鬥結果
|
|
let strRichText = `<color=#00FF00>玩家</c><color=#FFFF00>[${data.sponsor.name}]${data.sponsor.roleid}</c><color=#00FF00>與玩家</c><color=#FFFF00>[${data.recipient.name}]${data.recipient.roleid}</c><color=#00FF00 >的皇城決鬥,玩家</c><color=#FFFF00>[${data.sponsor.name}]${data.sponsor.roleid}</c><color=#00FF00>取得了勝利,玩家</c><color=#FFFF00>[${data.recipient.name}]${data.recipient.roleid}</c><color=#00FF00>被打敗! </c>`;
|
|
if (notice) {
|
|
notice.addStrToList(strRichText);
|
|
}
|
|
} else if (data.win == 2) {
|
|
let strRichText = `<color=#00FF00>玩家</c><color=#FFFF00>[${data.sponsor.name}]${data.sponsor.roleid}</c><color=#00FF00>與玩家</c><color=#FFFF00>[${data.recipient.name}]${data.recipient.roleid}</c><color=#00FF00 >的皇城決鬥,玩家</c><color=#FFFF00>[${data.recipient.name}]${data.recipient.roleid}</c><color=#00FF00>取得了勝利,玩家</c><color=#FFFF00>[${data.sponsor.name}]${data.sponsor.roleid}</c><color=#00FF00>被打敗! </c>`;
|
|
if (notice) {
|
|
notice.addStrToList(strRichText);
|
|
}
|
|
}
|
|
}
|
|
let logic = pficon.getComponent('PalaceFightIcon');
|
|
if (data.recipient.roleid == GameModel.player.roleid || data.sponsor.roleid == GameModel.player.roleid) {
|
|
logic.syncPalaceFightData(data);
|
|
}
|
|
}
|
|
});
|
|
SKSocket.register("s2c_palace_rolelist", (data: any) => {
|
|
let palaceFightIcon = cc.find('Canvas/MainUI/PalaceFightIcon');
|
|
let iconlogic = palaceFightIcon.getComponent('PalaceFightIcon');
|
|
if (iconlogic.canShowPalaceFightPanel() && !cc.find('Canvas/MainUI/PalaceFightPanel')) {
|
|
cc.loader.loadRes('Prefabs/PalaceFightPanel', cc.Prefab, (err, prefab) => {
|
|
let palaceFightPanel = cc.instantiate(prefab);
|
|
palaceFightPanel.parent = cc.find('Canvas/MainUI');
|
|
let palaceLogic = palaceFightPanel.getComponent('PalaceFightPanel');
|
|
palaceLogic.showTwoList(data);
|
|
palaceLogic.showCloseButton(iconlogic.canClosePalaceFight());
|
|
});
|
|
}
|
|
});
|
|
SKSocket.register("s2c_relation_apply_res", (data: any) => {
|
|
if (data.ecode == 0) {
|
|
let inputUI = cc.find('Canvas/MainUI/RelationInputUI');
|
|
if (inputUI) {
|
|
inputUI.destroy();
|
|
}
|
|
} else {
|
|
let errStr = '申請結拜關係錯誤';
|
|
if (data.errorMsg && data.errorMsg != '') {
|
|
switch (Number(data.errorMsg)) {
|
|
case 1:
|
|
errStr = '名稱已經存在,請重新輸入';
|
|
break;
|
|
case 2:
|
|
errStr = '當前結拜關係已存在';
|
|
break;
|
|
case 3:
|
|
errStr = '結拜人數超過上限';
|
|
break;
|
|
case 4:
|
|
errStr = '每人最多與他人結拜三次';
|
|
break;
|
|
case 5:
|
|
errStr = '所有成員必須在線,才能結拜';
|
|
break;
|
|
}
|
|
}
|
|
MsgAlert.addMsg(errStr);
|
|
}
|
|
});
|
|
SKSocket.register("s2c_relation_apply_info", (data: any) => {
|
|
let mainUILogic = GameModel.player.getMainUILogic();
|
|
if (mainUILogic) {
|
|
mainUILogic.onOpenRelationApplyUI(data);
|
|
}
|
|
});
|
|
SKSocket.register("s2c_relation_apply_answer", (data: any) => {
|
|
let relationApplyUI = cc.find('Canvas/MainUI/RelationApplyUI');
|
|
if (relationApplyUI) {
|
|
let relationApplyLogic = relationApplyUI.getComponent('RelationApplyPanel');
|
|
if (relationApplyLogic) {
|
|
relationApplyLogic.updateAgreeInfo(data);
|
|
}
|
|
}
|
|
});
|
|
SKSocket.register("s2c_relation_created", (data: any) => {
|
|
if (data.ecode == 0) {
|
|
let applyUI = cc.find('Canvas/MainUI/RelationApplyUI');
|
|
if (applyUI)
|
|
applyUI.destroy();
|
|
|
|
let listUI = cc.find('Canvas/MainUI/RelationListUI');
|
|
if (listUI)
|
|
listUI.destroy();
|
|
MsgAlert.addMsg('恭喜結拜成功');
|
|
//播放場景動畫效果
|
|
cc.loader.loadRes('Prefabs/RelationShowUI', cc.Prefab, (err, prefab) => {
|
|
let createShowUI = GameModel.createSubNode(cc.find('Canvas/MainUI'), {
|
|
nX: 0,
|
|
nY: 0
|
|
}, prefab, 'RelationShowUI');
|
|
if (createShowUI) {
|
|
createShowUI.getComponent('RelationShowPanel').playBrotherCreateShow(data);
|
|
}
|
|
});
|
|
} else {
|
|
MsgAlert.addMsg(data.errorMsg);
|
|
}
|
|
});
|
|
SKSocket.register("s2c_relation_List", (data: any) => {
|
|
if (data.ecode == 0) {
|
|
let listUILogic = cc.find('Canvas/MainUI/RelationListUI').getComponent('RelationListPanel');
|
|
if (listUILogic) {
|
|
listUILogic.initRelationList(data);
|
|
}
|
|
} else {
|
|
MsgAlert.addMsg(data.errorMsg);
|
|
}
|
|
});
|
|
SKSocket.register("s2c_relation_leave", (data: any) => {
|
|
if (data.ecode == 0) {
|
|
let listUI = cc.find('Canvas/MainUI/RelationListUI');
|
|
if (listUI) {
|
|
let listUILogic = listUI.getComponent('RelationListPanel');
|
|
if (listUILogic) {
|
|
listUILogic.leaveRelation(data);
|
|
}
|
|
}
|
|
if (data.leaveRoleId == GameModel.player.roleid) {
|
|
MsgAlert.addMsg('你已脫離結拜關係:');
|
|
if (data.titleId == GameModel.player.titleid) {
|
|
GameModel.player.titleid = -1;
|
|
GameModel.player.titletype = -1;
|
|
GameModel.player.titleval = '';
|
|
|
|
let logic = this.getGameLogic();
|
|
if (logic != null)
|
|
logic.resetSelfPlayerTitle();
|
|
}
|
|
}
|
|
} else {
|
|
MsgAlert.addMsg(data.errorMsg);
|
|
}
|
|
});
|
|
SKSocket.register("s2c_relation_destroy", (data: any) => {
|
|
console.log('關係刪除');
|
|
if (data.ecode == 0) {
|
|
let listUI = cc.find('Canvas/MainUI/RelationListUI');
|
|
if (listUI) {
|
|
let listUILogic = listUI.getComponent('RelationListPanel');
|
|
if (listUILogic) {
|
|
listUILogic.deleteRelationItem(data);
|
|
}
|
|
}
|
|
if (data.titleId == GameModel.player.titleid) {
|
|
GameModel.player.titleid = -1;
|
|
GameModel.player.titletype = -1;
|
|
GameModel.player.titleval = '';
|
|
let logic = this.getGameLogic()
|
|
if (logic != null)
|
|
logic.resetSelfPlayerTitle();
|
|
}
|
|
} else {
|
|
MsgAlert.addMsg(data.errorMsg);
|
|
}
|
|
});
|
|
SKSocket.register("s2c_relation_reject", (data: any) => {
|
|
let relationApplyUI = cc.find('Canvas/MainUI/RelationApplyUI');
|
|
if (relationApplyUI) {
|
|
MsgAlert.addMsg('結拜操作需要所有成員都同意');
|
|
relationApplyUI.destroy();
|
|
}
|
|
});
|
|
SKSocket.register("s2c_scheme_List", (data: any) => {
|
|
let schemePanel = cc.find('Canvas/MainUI/SchemePanel');
|
|
if (schemePanel) {
|
|
let schemeListLogic = schemePanel.getChildByName('schemeNode').getComponent('SchemeListPanel');
|
|
if (schemeListLogic)
|
|
schemeListLogic.initSchemeList(data);
|
|
}
|
|
});
|
|
SKSocket.register("s2c_scheme_create", (data: any) => {
|
|
if (data.ecode == 0) {
|
|
let schemePanel = cc.find('Canvas/MainUI/SchemePanel');
|
|
if (schemePanel) {
|
|
let schemeListLogic = schemePanel.getChildByName('schemeNode').getComponent('SchemeListPanel');
|
|
if (schemeListLogic) {
|
|
schemeListLogic.appendSchemeList(data);
|
|
}
|
|
}
|
|
} else {
|
|
MsgAlert.addMsg('名稱重複,請重新輸入');
|
|
}
|
|
});
|
|
SKSocket.register("s2c_scheme_info", (data: any) => {
|
|
if (data.ecode == 0) {
|
|
let schemePanel = cc.find('Canvas/MainUI/SchemePanel');
|
|
if (schemePanel) {
|
|
let schemeInputUI = schemePanel.getChildByName('schemeNode').getChildByName('SchemeInputUI');
|
|
if (schemeInputUI)
|
|
schemeInputUI.active = false;
|
|
|
|
let listpanel = schemePanel.getChildByName('schemeNode');
|
|
listpanel.active = true;
|
|
let schemeLogic = listpanel.getComponent('SchemeListPanel');
|
|
if (schemeLogic) {
|
|
schemeLogic.setSchemeInfo(data);
|
|
}
|
|
}
|
|
} else {
|
|
MsgAlert.addMsg('屬性方案信息有誤');
|
|
}
|
|
});
|
|
SKSocket.register("s2c_scheme_updateEquip", (data: any) => {
|
|
if (data.ecode == 0) {
|
|
let schemePanel = cc.find('Canvas/MainUI/SchemePanel');
|
|
if (schemePanel) {
|
|
let equipsNode = schemePanel.getChildByName('schemeNode').getChildByName('EquipsNode');
|
|
let equipsLogic = equipsNode.getComponent('SchemeEquipsPanel');
|
|
if (equipsLogic) {
|
|
equipsLogic.updateEquips(data);
|
|
}
|
|
}
|
|
} else {
|
|
MsgAlert.addMsg('屬性方案裝備更新失敗');
|
|
}
|
|
});
|
|
SKSocket.register("s2c_scheme_changeName", (data: any) => {
|
|
if (data.ecode == 0) {
|
|
let schemePanel = cc.find('Canvas/MainUI/SchemePanel');
|
|
if (schemePanel) {
|
|
let schemeInputUI = schemePanel.getChildByName('schemeNode').getChildByName('SchemeInputUI');
|
|
if (schemeInputUI)
|
|
schemeInputUI.active = false;
|
|
let schemeLogic = schemePanel.getChildByName('schemeNode').getComponent('SchemeListPanel');
|
|
if (schemeLogic) {
|
|
schemeLogic.setSchemeName(data);
|
|
}
|
|
}
|
|
} else {
|
|
MsgAlert.addMsg('屬性方案改名失敗');
|
|
}
|
|
});
|
|
SKSocket.register("s2c_scheme_use", (data: any) => {
|
|
if (data.ecode == 0) {
|
|
let schemePanel = cc.find('Canvas/MainUI/SchemePanel');
|
|
if (schemePanel) {
|
|
let schemeUseUI = schemePanel.getChildByName('schemeNode').getChildByName('SchemeUseUI');
|
|
if (schemeUseUI)
|
|
schemeUseUI.active = false;
|
|
let schemeLogic = schemePanel.getChildByName('schemeNode').getComponent('SchemeListPanel');
|
|
if (schemeLogic) {
|
|
schemeLogic.useScheme(data);
|
|
}
|
|
}
|
|
} else {
|
|
MsgAlert.addMsg('屬性方案改名失敗');
|
|
}
|
|
});
|
|
SKSocket.register("s2c_scheme_activate", (data: any) => {
|
|
if (data.ecode == 0) {
|
|
let schemePanel = cc.find('Canvas/MainUI/SchemePanel');
|
|
if (schemePanel) {
|
|
let schemeLogic = schemePanel.getChildByName('schemeNode').getComponent('SchemeListPanel');
|
|
if (schemeLogic) {
|
|
schemeLogic.onActivateScheme(data);
|
|
}
|
|
}
|
|
}
|
|
});
|
|
SKSocket.register("s2c_scheme_resetXiulianPoint", (data: any) => {
|
|
if (data.ecode == 0) {
|
|
let schemePanel = cc.find('Canvas/MainUI/SchemePanel');
|
|
if (schemePanel) {
|
|
let kangxingNode = schemePanel.getChildByName('schemeNode').getChildByName('kangxingNode');
|
|
let kangxingLogic = kangxingNode.getComponent('SchemeDefendPanel');
|
|
if (kangxingLogic) {
|
|
kangxingLogic.onResetXiuLianPoint();
|
|
}
|
|
}
|
|
} else {
|
|
MsgAlert.addMsg(data.errorMsg);
|
|
}
|
|
});
|
|
SKSocket.register("s2c_change_role_color", (data: any) => {
|
|
GameModel.player.color1 = data.color1;
|
|
GameModel.player.color2 = data.color2;
|
|
// console.log('s2c_change_role_color', data);
|
|
let gamelogic = this.getGameLogic();
|
|
let role = GameModel.player.getNode();
|
|
if (role) {
|
|
let logic = role.getComponent('role');
|
|
logic.showColorMask();
|
|
let name = logic.getCurAnimateName();
|
|
if (name) {
|
|
logic.playAnimation(name);
|
|
}
|
|
}
|
|
let coloringRolePanel = cc.find('Canvas/MainUI/ColoringRolePanel');
|
|
if (coloringRolePanel) {
|
|
let logic = coloringRolePanel.getComponent('ColoringRolePanel');
|
|
logic.setCurColor();
|
|
}
|
|
});
|
|
SKSocket.register("s2c_bell_msg", (data: any) => {
|
|
let str = `<color=#00FF00>玩家</c><color=#FFFF00>[${data.name}]</c> : <color=#00FF00>${data.msg}</c>`;
|
|
let node = cc.find('Canvas/PalaceNotice');
|
|
if (node) {
|
|
let notice = node.getComponent('PalaceNotice');
|
|
if (notice) {
|
|
notice.addStrToList(str);
|
|
}
|
|
}
|
|
});
|
|
SKSocket.register("s2c_safepass_msg", (data: any) => {
|
|
GameModel.player.safe_password = data.pass;
|
|
GameModel.player.safe_lock = data.lock;
|
|
Set.Instance.initSafeCom()
|
|
// let set_panel = cc.find('Canvas/SetPanel');
|
|
// if (set_panel) {
|
|
// let safe_logic = cc.find('SafeNode', set_panel).getComponent('SafeNode');
|
|
// safe_logic.init();
|
|
// }
|
|
});
|
|
SKSocket.register("s2c_sync_ride", (data: any) => {
|
|
let logic = this.getGameLogic()
|
|
if (logic) {
|
|
logic.syncRide(data);
|
|
}
|
|
});
|
|
SKSocket.register("s2c_sync_get_down", (data: any) => {
|
|
let logic = this.getGameLogic()
|
|
if (logic) {
|
|
logic.syncGetDown(data);
|
|
}
|
|
});
|
|
SKSocket.register("s2c_sync_race", (data: any) => {
|
|
let logic = this.getGameLogic()
|
|
if (logic) {
|
|
logic.syncRace(data);
|
|
}
|
|
});
|
|
// 接收坐騎列表
|
|
SKSocket.register("s2c_horse_list", (data: any) => {
|
|
HorsePanel.shared.syncHorseList(data);
|
|
});
|
|
// 接收坐騎技能
|
|
SKSocket.register("s2c_horse_skill", (data: any) => {
|
|
HorsePanel.shared.syncHorseSkill(data);
|
|
});
|
|
// 接收每日充值獎勵結果
|
|
SKSocket.register("s2c_day_reward", (data: any) => {
|
|
if (Welfare.Instance) {
|
|
Welfare.Instance.dayMap = SKDataUtil.jsonBy(data.dayMap);
|
|
if (Welfare.Instance.firstChargeView && Welfare.Instance.firstChargeView.node && Welfare.Instance.firstChargeView.visible) {
|
|
Welfare.Instance.openFirstChargeView();
|
|
} else if (Welfare.Instance.dayChargeView && Welfare.Instance.dayChargeView.node && Welfare.Instance.dayChargeView.visible) {
|
|
Welfare.Instance.openDayFirstChargeView();
|
|
}
|
|
}
|
|
});
|
|
// 接收VIP每日獎勵結果
|
|
SKSocket.register("s2c_vip_reward", (data: any) => {
|
|
Welfare.Instance.dayMap = SKDataUtil.jsonBy(data.dayMap);
|
|
Welfare.Instance.openVipView();
|
|
});
|
|
// 接收每日簽到結果
|
|
SKSocket.register("s2c_sign_in", (data: any) => {
|
|
if (Welfare.Instance) {
|
|
Welfare.Instance.showDailySignInTip(data);
|
|
if (Welfare.Instance.signInView && Welfare.Instance.signInView.node) {
|
|
Welfare.Instance.openSignInView(null, true, data)
|
|
}
|
|
}
|
|
});
|
|
// 接收簽到結果
|
|
SKSocket.register("s2c_check_in", (data: any) => {
|
|
try {
|
|
var data = JSON.parse(data.signInData)
|
|
if (data.flag > 0) {
|
|
GameModel.send(`c2c_sign_in`, { roleId: GameModel.player.roleid });
|
|
GameModel.player.mendDate = new Date().toLocaleDateString();
|
|
Welfare.Instance.dropItemToBag(data.prop);
|
|
}
|
|
} catch (err) {
|
|
console.log(err)
|
|
}
|
|
|
|
});
|
|
// 接收挖寶列表
|
|
SKSocket.register("s2c_dug_list", (data: any) => {
|
|
Welfare.Instance.dayMap = SKDataUtil.jsonBy(data.dayMap);
|
|
Welfare.Instance.openDugView();
|
|
});
|
|
// 接收挖寶結果
|
|
SKSocket.register("s2c_dug", (data: any) => {
|
|
Welfare.Instance.dugEnd(data);
|
|
});
|
|
// 今日存檔被清除
|
|
SKSocket.register("s2c_clear_day", (data: any) => {
|
|
if (!data.dayMap) return
|
|
if (!Welfare.Instance) return
|
|
Welfare.Instance.dayMap = SKDataUtil.jsonBy(data.dayMap);
|
|
if (Welfare.Instance) {
|
|
Welfare.Instance.dayMap = SKDataUtil.jsonBy(data.dayMap);
|
|
Welfare.Instance.closeAll();
|
|
}
|
|
});
|
|
|
|
SKSocket.register("s2s_goods_info", (data: any) => {
|
|
let logic = this.getGameLogic()
|
|
if (logic) {
|
|
logic.syncChatGoodsInfo(data);
|
|
}
|
|
});
|
|
|
|
SKSocket.register("s2c_post_message", (data: any) => {
|
|
console.log(data)
|
|
});
|
|
SKSocket.register("s2c_convert", (data: any) => {
|
|
console.log(data)
|
|
});
|
|
|
|
// 變身卡
|
|
SKSocket.register("s2c_become", (data: any) => {
|
|
console.log(data)
|
|
});
|
|
SKSocket.register("s2c_become_info", (data: any) => {
|
|
console.log(data)
|
|
});
|
|
SKSocket.register("s2c_five_phases", (data: any) => {
|
|
if (Transformation.Instance) {
|
|
Transformation.Instance.practiceData = JSON.parse(data.vecRow);
|
|
if (Transformation.Instance.practicePanel && Transformation.Instance.practicePanel.node) {
|
|
Transformation.Instance.initPracticeLeftInfo(JSON.parse(data.vecRow));
|
|
}
|
|
}
|
|
});
|
|
SKSocket.register("s2c_detail_page", (data: any) => {
|
|
let logic = this.getGameLogic()
|
|
if (logic) {
|
|
logic.showTransInfo(JSON.parse(data.card));
|
|
}
|
|
});
|
|
// 證道報名大會
|
|
SKSocket.register("s2c_join_say_sign", (data: any) => {
|
|
if (data.code == 0 && data.sayState == GameState.Sign) {
|
|
// 跳轉到證道谷
|
|
let comMapLogic = cc.find('Canvas/MapUI').getComponent('GameMapLogic');
|
|
comMapLogic.changeMap(4004);
|
|
DebateDao.Instance.openDebateDaoPanel()
|
|
} else {
|
|
MsgAlert.addMsg(data.code);
|
|
}
|
|
});
|
|
// 返回證道大會戰鬥信息通知
|
|
SKSocket.register("s2c_match_battles", (data: any) => {
|
|
if (data.isWin == 1)
|
|
DebateDao.Instance.openWinPanel(data);
|
|
else
|
|
DebateDao.Instance.openLosePanel(data);
|
|
DebateDao.Instance.setScore(data.matchScore, data.satScore, data.peak, data.type);
|
|
});
|
|
// 證道大會戰鬥信息
|
|
SKSocket.register("s2c_say_stage", (data: any) => {
|
|
DebateDao.Instance.setCutDownTime(data.countDown);
|
|
DebateDao.Instance.setTitle(data.type);
|
|
});
|
|
// 證道大會隊員信息及分數信息
|
|
SKSocket.register("s2c_say_team_info", (data: any) => {
|
|
if (!DebateDao.Instance.battlePanel || !DebateDao.Instance.battlePanel.node)
|
|
DebateDao.Instance.openDebateDaoPanel()
|
|
DebateDao.Instance.refreshBattlePanel(data)
|
|
});
|
|
// 證道大會積分榜信息
|
|
SKSocket.register("s2c_say_integral_info", (data: any) => {
|
|
DebateDao.Instance.refreshSortPanel(data.scoreboard)
|
|
});
|
|
// 離開證道大會
|
|
SKSocket.register("s2c_leave_sat", (data: any) => {
|
|
if (data.code == MsgCode.SUCCESS)
|
|
DebateDao.Instance.leaveSuccess();
|
|
});
|
|
// 證道巔峰對決雙方隊伍信息
|
|
SKSocket.register("s2c_sat_match", (data: any) => {
|
|
if (!cc.find('Canvas/MainUI/PalaceFightPanel')) {
|
|
cc.loader.loadRes('Prefabs/PalaceFightPanel', cc.Prefab, (err, prefab) => {
|
|
let palaceFightPanel = cc.instantiate(prefab);
|
|
palaceFightPanel.parent = cc.find('Canvas/MainUI');
|
|
let palaceLogic = palaceFightPanel.getComponent('PalaceFightPanel');
|
|
data.sponsorlist = data.teamS;
|
|
data.recipientlist = data.teamE;
|
|
palaceLogic.showTwoList(data, true);
|
|
});
|
|
}
|
|
});
|
|
// 改變惡鬼積分為巔峰積分
|
|
SKSocket.register("s2c_update_say_peak", (data: any) => {
|
|
DebateDao.Instance.updateSayPeakScore(data.score)
|
|
});
|
|
// 涿鹿勝利通知
|
|
SKSocket.register("s2c_sat_win", (data: any) => {
|
|
DebateDao.Instance.openWinNoticePanel(JSON.parse(data.info))
|
|
});
|
|
// 幫戰報名大會
|
|
SKSocket.register("s2c_gang_wars", (data: any) => {
|
|
if (data.code == 0 && data.state == GameState.Sign) {
|
|
}
|
|
GangWar.Instance.openBattleMainPanel()
|
|
});
|
|
SKSocket.register("s2c_detail_statistics", (data: any) => {
|
|
if (data.type == 0) {
|
|
GangWar.Instance.isStart = false
|
|
GangWar.Instance.refreshReady(data);
|
|
}
|
|
else {
|
|
if (!GangWar.Instance.isStart) {
|
|
GangWar.Instance.isStart = true
|
|
GangWar.Instance.changeBtnType(data)
|
|
GangWar.Instance.changeGameHp({ gateHpL: data.factionEnemy, gateHpR: data.factionSide })
|
|
}
|
|
GangWar.Instance.refreshHistory(data)
|
|
}
|
|
});
|
|
SKSocket.register("s2c_faction_war_over", (data: any) => {
|
|
if (data.type == 1) {
|
|
// 勝利
|
|
GangWar.Instance.openWinPanel(data);
|
|
} else {
|
|
// 失敗
|
|
GangWar.Instance.openLosePanel(data);
|
|
}
|
|
});
|
|
// 對決雙方隊伍信息
|
|
SKSocket.register("s2c_match", (data: any) => {
|
|
if (!cc.find('Canvas/MainUI/PalaceFightPanel')) {
|
|
cc.loader.loadRes('Prefabs/PalaceFightPanel', cc.Prefab, (err, prefab) => {
|
|
let palaceFightPanel = cc.instantiate(prefab);
|
|
palaceFightPanel.parent = cc.find('Canvas/MainUI');
|
|
let palaceLogic = palaceFightPanel.getComponent('PalaceFightPanel');
|
|
data.sponsorlist = data.teamS;
|
|
data.recipientlist = data.teamE;
|
|
palaceLogic.showTwoList(data, true);
|
|
});
|
|
}
|
|
if (GameModel.player.mapid == 3001) {
|
|
GameUtil.breakWaitTip2()
|
|
}
|
|
});
|
|
|
|
SKSocket.register("s2c_gang_tower", (data: any) => {
|
|
if (SKDataUtil.hasProperty(data, "durable")) {
|
|
var tower = GameModel.towerNpcList[`${data.towerId}`]
|
|
if (tower)
|
|
tower.changeHp(data.durable)
|
|
if (data.durable == 0) {
|
|
GameModel.towerNpc = null
|
|
return
|
|
}
|
|
if (GameModel.towerNpc) {
|
|
GameModel.towerNpc.towerGangid = data.bangId
|
|
GameModel.towerNpc.OpenTowerFunctionUI(data);
|
|
}
|
|
}
|
|
});
|
|
SKSocket.register("s2c_gang_tower_info", (data: any) => {
|
|
if (SKDataUtil.hasProperty(data, "durable")) {
|
|
var tower = GameModel.towerNpcList[`${data.towerId}`]
|
|
if (tower)
|
|
tower.changeHp(data.durable)
|
|
}
|
|
});
|
|
SKSocket.register("s2c_ask_fortifications", (data: any) => {
|
|
if (data.state == MsgCode.FAILED) {//蓄力失敗
|
|
if (GameModel.needKeep) //被打斷
|
|
GameUtil.breakWaitTip2()
|
|
else { //未蓄力成功
|
|
MsgAlert.addMsg("蓄力未成功");
|
|
}
|
|
return;
|
|
}
|
|
if (data.type == 1) {
|
|
//大砲
|
|
if (GameModel.paoNpc)
|
|
GameModel.paoNpc.OnPaoClickCB();
|
|
}
|
|
else {
|
|
//塔
|
|
if (GameModel.towerNpc)
|
|
GameModel.towerNpc.OnTowerKeepCB();
|
|
else {
|
|
console.log("沒有找到塔")
|
|
}
|
|
}
|
|
});
|
|
// 幫戰地圖轟擊
|
|
SKSocket.register("s2c_bombard_site", (data: any) => {
|
|
if (data.type == 1) {
|
|
// 龍神大砲
|
|
var pao = GameModel.paoNpc;
|
|
if (pao) {
|
|
pao.paoBoom(data)
|
|
}
|
|
var mapUI = cc.find('Canvas/MapUI')
|
|
let comMapLogic = null;
|
|
if (mapUI) {
|
|
comMapLogic = mapUI.getComponent('GameMapLogic');
|
|
}
|
|
if (comMapLogic)
|
|
comMapLogic.boomGangMap(data)
|
|
}
|
|
else {
|
|
// 烈火 玄冰 攻擊動畫
|
|
var tower = GameModel.towerNpcList[`${data.serial}`]
|
|
if (tower) {
|
|
tower.loadEff(`shap/${tower.resid}/run_1_ef`, false, -5, 75, () => {
|
|
tower.loadEff(`shap/${tower.resid}/stand_1_ef`, true, -5, 75, null)
|
|
})
|
|
}
|
|
|
|
// 烈火 玄冰 攻擊地點動畫
|
|
var mapUI = cc.find('Canvas/MapUI')
|
|
let comMapLogic = null;
|
|
if (mapUI) {
|
|
comMapLogic = mapUI.getComponent('GameMapLogic');
|
|
}
|
|
if (comMapLogic)
|
|
comMapLogic.boomGangMap(data)
|
|
}
|
|
});
|
|
// 通知城門血條改變
|
|
SKSocket.register("s2c_gate_hp", (data: any) => {
|
|
let comMapLogic = cc.find('Canvas/MapUI').getComponent('GameMapLogic');
|
|
GangWar.Instance.changeBtnType(data)
|
|
GangWar.Instance.changeGameHp(data)
|
|
|
|
if (SKDataUtil.jsonBy(data.gateHpR).gateHp <= 5000 * 0.3)
|
|
comMapLogic.showGangBattleGateDie_right(true)
|
|
else if (SKDataUtil.jsonBy(data.gateHpR).gateHp <= 5000 * 0.5)
|
|
comMapLogic.showGangBattleGateDie_right()
|
|
|
|
if (SKDataUtil.jsonBy(data.gateHpL).gateHp <= 5000 * 0.3)
|
|
comMapLogic.showGangBattleGateDie_left(true)
|
|
else if (SKDataUtil.jsonBy(data.gateHpL).gateHp <= 5000 * 0.5)
|
|
comMapLogic.showGangBattleGateDie_left()
|
|
});
|
|
|
|
// 幫戰玄冰塔擊中通知
|
|
SKSocket.register("s2c_wars_player_state", (data: any) => {
|
|
var lgc = GameModel.player.getLogic()
|
|
if (data.type == 1) {
|
|
// 冰凍
|
|
if (lgc) {
|
|
lgc.isBing = true;
|
|
lgc.loadEff("effect/bing", true, 0, 0, null)
|
|
}
|
|
} else {
|
|
if (lgc) {
|
|
lgc.isBing = false;
|
|
lgc.deleteEffNode()
|
|
}
|
|
}
|
|
});
|
|
// 地圖傳送
|
|
SKSocket.register("s2c_map_transfer", (data: any) => {
|
|
if (data.mapId > 0) {
|
|
let comMapLogic = cc.find('Canvas/MapUI').getComponent('GameMapLogic');
|
|
if (data.coordx > 0 && data.coordy > 0) {
|
|
comMapLogic.changeMapXY(data.mapId, { x: data.coordx, y: data.coordy });
|
|
} else {
|
|
comMapLogic.changeMap(data.mapId);
|
|
}
|
|
}
|
|
});
|
|
|
|
// 特效列表
|
|
SKSocket.register("s2c_has_seffect", (data: any) => {
|
|
var temp = SKDataUtil.jsonBy(data.seffectlist);
|
|
Appearance.Instance.haveEffList = temp;
|
|
Appearance.Instance.refreshList();
|
|
});
|
|
|
|
// 寵物支援列表
|
|
SKSocket.register("s2c_support_list", (data: any) => {
|
|
var temp = SKDataUtil.jsonBy(data.supportlist);
|
|
temp.sort((a, b) => {
|
|
return a.sorder - b.sorder;
|
|
});
|
|
console.log(temp)
|
|
GameModel.petSupportTempData = temp;
|
|
let logic = this.getGameLogic()
|
|
if (logic) {
|
|
logic.synPetSupportPanel();
|
|
}
|
|
});
|
|
SKSocket.register("s2c_days_prisoner", (data: any) => {
|
|
visitingPrison.Instance.prisonList = SKDataUtil.jsonBy(data.prisoner);
|
|
visitingPrison.Instance.refreshList();
|
|
})
|
|
SKSocket.register("s2c_bindinfo", (data: any) => {
|
|
if (data.playerinfo) {
|
|
GameModel.player.bindInfo = SKDataUtil.jsonBy(data.playerinfo)
|
|
GameModel.player.bplayerinfo = SKDataUtil.jsonBy(data.bplayerinfo)
|
|
}
|
|
});
|
|
|
|
SKSocket.register("s2c_ofuda_list", (data: any) => {
|
|
FactionTalent.Instance.factionTalentList = SKDataUtil.jsonBy(data.list);
|
|
FactionTalent.Instance.factionTalentLevel = data.level;
|
|
FactionTalent.Instance.initWithType(FactionTalent.Instance.currentType);
|
|
})
|
|
SKSocket.register("s2c_open_levelup", (data: any) => {
|
|
FactionTalent.Instance.factionTalentLevel = data.level;
|
|
FactionTalent.Instance.initWithType(FactionTalent.Instance.currentType);
|
|
FactionTalent.Instance.recoverOnce();
|
|
FactionTalent.Instance.refreshLevelUpPanel();
|
|
});
|
|
SKSocket.register("s2c_own_ofuda", (data: any) => {
|
|
var tempList = SKDataUtil.jsonBy(data.list);
|
|
if (ItemUtil.getBagItemCount(100323) > 0) {
|
|
tempList.unshift({
|
|
roleid: 0,
|
|
ofudaid: "",
|
|
oftype: 0,
|
|
name: "待鑑定的御獸符",
|
|
grade: 3,
|
|
addition: 0,
|
|
skillid: 0,
|
|
itemid: 100323,
|
|
number: ItemUtil.getBagItemCount(100323)
|
|
})
|
|
}
|
|
if (ItemUtil.getBagItemCount(100322) > 0) {
|
|
tempList.unshift({
|
|
roleid: 0,
|
|
ofudaid: "",
|
|
oftype: 0,
|
|
name: "待鑑定的載物符",
|
|
grade: 2,
|
|
addition: 0,
|
|
skillid: 0,
|
|
itemid: 100322,
|
|
number: ItemUtil.getBagItemCount(100322)
|
|
})
|
|
}
|
|
if (ItemUtil.getBagItemCount(100321) > 0) {
|
|
tempList.unshift({
|
|
roleid: 0,
|
|
ofudaid: "",
|
|
oftype: 0,
|
|
name: "待鑑定的千鈞符",
|
|
grade: 1,
|
|
addition: 0,
|
|
skillid: 0,
|
|
itemid: 100321,
|
|
number: ItemUtil.getBagItemCount(100321)
|
|
})
|
|
}
|
|
if (ItemUtil.getBagItemCount(100320) > 0) {
|
|
tempList.unshift({
|
|
roleid: 0,
|
|
ofudaid: "",
|
|
oftype: 0,
|
|
name: "天策符碎片",
|
|
grade: 0,
|
|
addition: 0,
|
|
skillid: 0,
|
|
itemid: 100320,
|
|
number: ItemUtil.getBagItemCount(100320)
|
|
})
|
|
}
|
|
FactionTalent.Instance.fcFuList = tempList;
|
|
FactionTalent.Instance.refreshFcBagPanel();
|
|
FactionTalent.Instance.initUsedFu();
|
|
});
|
|
|
|
SKSocket.register("s2c_authenticate_ofuda", (data: any) => {
|
|
FactionTalent.Instance.identifyRes = SKDataUtil.jsonBy(data.ofudainfo)
|
|
FactionTalent.Instance.identifyShowRes = SKDataUtil.jsonBy(data.ofudainfo)
|
|
FactionTalent.Instance.openIdentifyPanel();
|
|
})
|
|
SKSocket.register("s2c_high_refine", (data: any) => {
|
|
EquipRefine.Instance.openEquipRefinePanel(SKDataUtil.jsonBy(data.list))
|
|
})
|
|
SKSocket.register("s2c_paihang_playerinfo", (data: any) => {
|
|
RoleInfoAlert.show(SKDataUtil.jsonBy(data.info))
|
|
})
|
|
SKSocket.register("s2c_whitelist_interface", (data: any) => {
|
|
SocketUtil.updateWhiteList(SKDataUtil.jsonBy(data.list));
|
|
})
|
|
SKSocket.register("s2c_information", (data: any) => {
|
|
DrawMoney.Instance.reciveList(data);
|
|
})
|
|
SKSocket.register("s2c_mondrop", (data: any) => {
|
|
let uilogic = GameModel.player.getMainUILogic();
|
|
if (uilogic) {
|
|
uilogic.showMondrop(data.mondrop);
|
|
}
|
|
})
|
|
SKSocket.register('s2c_getXwAttrInfo', (data: any) => {
|
|
let mainUILogic = GameModel.player.getMainUILogic();
|
|
if (mainUILogic) {
|
|
mainUILogic.updateXWInfo(data);
|
|
}
|
|
})
|
|
SKSocket.register('s2c_xw_normal_succinct', (data: any) => {
|
|
let mainUILogic = GameModel.player.getMainUILogic();
|
|
if (mainUILogic) {
|
|
mainUILogic.updateNewXWInfo(data);
|
|
}
|
|
})
|
|
SKSocket.register('s2c_replaceattribute', (data: any) => {
|
|
let mainUILogic = GameModel.player.getMainUILogic();
|
|
if (mainUILogic) {
|
|
mainUILogic.updateXWUI(data)
|
|
}
|
|
})
|
|
SKSocket.register('s2c_getNewAttrInfo', (data: any) => {
|
|
let mainUILogic = GameModel.player.getMainUILogic();
|
|
if (mainUILogic) {
|
|
mainUILogic.updateNewXWInfo(data);
|
|
}
|
|
})
|
|
SKSocket.register('s2c_getAttrInfo', (data: any) => {
|
|
let mainUILogic = GameModel.player.getMainUILogic();
|
|
if (mainUILogic) {
|
|
mainUILogic.updateXWAllInfo(data);
|
|
}
|
|
})
|
|
SKSocket.register('s2c_getBabySkillConfig', (data: any) => {
|
|
let msg = JSON.parse(data)
|
|
MyModel.shared.BabyList.SaveSkillConfig(msg)
|
|
})
|
|
|
|
SKSocket.register('s2c_adoptBaby', (data: any) => {
|
|
MyModel.shared.BabyList.AdoptBaby(data)
|
|
})
|
|
|
|
SKSocket.register('s2c_babyBattle', (data: any) => {
|
|
MyModel.shared.BabyList.BabyBattle(data)
|
|
})
|
|
|
|
SKSocket.register('s2c_babySkillBless', (data: any) => {
|
|
MyModel.shared.BabyList.BabySkillBless(data)
|
|
})
|
|
|
|
SKSocket.register('s2c_babySkillUpgrade', (data: any) => {
|
|
MyModel.shared.BabyList.BabySkillUpgrade(data)
|
|
})
|
|
|
|
SKSocket.register('s2c_babySkillBattle', (data: any) => {
|
|
MyModel.shared.BabyList.BabySkillBattle(data)
|
|
})
|
|
|
|
SKSocket.register('s2c_babyPracticeConfig', (data: any) => {
|
|
MyModel.shared.BabyList.UpdateBabyPracticeConfig(data)
|
|
})
|
|
|
|
SKSocket.register('s2c_babyPractice', (data: any) => {
|
|
MyModel.shared.BabyList.BabyPractice(data)
|
|
})
|
|
|
|
SKSocket.register("s2c_upgradeStar", (data: any) => {
|
|
MyModel.shared.StarData.UpgradeStar(data)
|
|
})
|
|
|
|
SKSocket.register("s2c_getNewStarAttr", (data: any) => {
|
|
MyModel.shared.StarData.GetNewStarAttr(data)
|
|
})
|
|
|
|
SKSocket.register("s2c_replaceStarAttr", (data: any) => {
|
|
MyModel.shared.StarData.ReplaceStarAttr(data)
|
|
})
|
|
|
|
SKSocket.register("s2c_equipStar", (data: any) => {
|
|
MyModel.shared.StarData.EquipStar(data)
|
|
})
|
|
//返回天梯數據
|
|
SKSocket.register("s2c_TianTi_info", (data: any) => {
|
|
if (TianTiPanel.Instance && TianTiPanel.Instance.node) {
|
|
GameModel.player.tianti_integral = data.tiantijizhenshifen;
|
|
TianTiPanel.Instance.openTianTiPanel(true, data)
|
|
}
|
|
});
|
|
//返回天梯獎勵數據
|
|
SKSocket.register("s2c_TianTijiangli_info", (data: any) => {
|
|
|
|
if (TianTiPanel.Instance && TianTiPanel.Instance.node) {
|
|
TianTiPanel.Instance.initshop(true, data)
|
|
}
|
|
});
|
|
|
|
// 天梯報名大會
|
|
SKSocket.register("s2c_join_tianti_sign", (data: any) => {
|
|
console.log('天梯報名大會')
|
|
if (data.code == 0 && data.sayState == GameState.Sign) {
|
|
// 跳轉到天梯
|
|
TianTiPiPei.Instance.openTianTiPiPeiPanel(false, null)
|
|
} else {
|
|
if (data.code == 9016 || data.code == 9017) {
|
|
MsgAlert.addMsg('天梯匹配失敗, 天梯決戰時間為每天中午12點');
|
|
} else if (data.code == 9004) {
|
|
MsgAlert.addMsg('您不是對戰無法開啟天梯決戰');
|
|
} else if (data.code == 9002) {
|
|
MsgAlert.addMsg('您已經報名過天梯決戰了');
|
|
} else {
|
|
MsgAlert.addMsg('天梯匹配失敗');
|
|
}
|
|
}
|
|
});
|
|
|
|
// 天梯巔峰對決雙方隊伍信息
|
|
SKSocket.register("s2c_tiantisat_match", (data: any) => {
|
|
TianTiPiPei.Instance.reShow(data);
|
|
});
|
|
}
|
|
|
|
// 登入
|
|
static login(accountId: number, roleId: number, serverId: number) {
|
|
this.shared.login(accountId, roleId, serverId);
|
|
}
|
|
|
|
static send(prefix: string, properties: any) {
|
|
SKSocket.send(prefix, properties);
|
|
}
|
|
|
|
// 獲得寶寶頭像
|
|
static getPetHead(resId: string): cc.SpriteFrame {
|
|
// 先從fgui讀取
|
|
let icon = ItemUtil.getItemIcon(resId)
|
|
if (icon) return icon;
|
|
|
|
if (!this.petHeadAtlas) {
|
|
return null;
|
|
}
|
|
let result = this.petHeadAtlas.getSpriteFrame(resId);
|
|
return result;
|
|
}
|
|
|
|
private login(accountId: number, roleId: number, serverId: number) {
|
|
SKNetTask.getWithJson("/to_server", { accountId: accountId, roleId: roleId, serverId: serverId }, (code, result) => {
|
|
// 網絡錯誤處理
|
|
if (code != NetCode.SUCCESS) {
|
|
FGHUD.hideLoading();
|
|
MsgAlert.addMsg(`登錄請求失敗,請稍候登錄!`);
|
|
return;
|
|
}
|
|
// 邏輯錯誤處理
|
|
if (result.code && result.code != MsgCode.SUCCESS) {
|
|
FGHUD.hideLoading();
|
|
if (result.msg) {
|
|
MsgAlert.addMsg(result.msg);
|
|
} else {
|
|
MsgAlert.addMsg(`登錄請求失敗,請稍候登錄!`);
|
|
}
|
|
return;
|
|
}
|
|
// 檢查服務器參數
|
|
if (!result.ip || !result.port) {
|
|
FGHUD.hideLoading();
|
|
GameModel.notice.addMsg(0, `服務器重啟中,請稍候重試!`, () => {
|
|
SKUIUtil.loadScene("LoginScene", null, (sceneName) => {
|
|
GameModel.currentScene = sceneName;
|
|
});
|
|
});
|
|
return;
|
|
}
|
|
console.log("to server ............................")
|
|
console.log(code, result)
|
|
let ip = result.ip;
|
|
let port = result.port;
|
|
let token = result.token;
|
|
SKSocket.connect(ip, port, (code: SocketCode) => {
|
|
}, () => {
|
|
SKSocket.send("c2s_login", { accountid: accountId, roleid: roleId, token: token });
|
|
});
|
|
});
|
|
}
|
|
|
|
static createSubNode(vParent: any, stPos: any, strPrefab: any, strName: any) {
|
|
let goItem = cc.instantiate(strPrefab);
|
|
goItem.parent = vParent;
|
|
goItem.name = strName;
|
|
goItem.setPosition(cc.v2(stPos.nX, stPos.nY));
|
|
return goItem;
|
|
}
|
|
|
|
static test() {
|
|
let logic = this.shared.getGameLogic();
|
|
if (logic) {
|
|
logic.synChatInfo({
|
|
voice: "notice",
|
|
scale: 3,
|
|
msg: "test",
|
|
});
|
|
}
|
|
}
|
|
} |