409 lines
12 KiB
JavaScript
409 lines
12 KiB
JavaScript
"use strict";
|
|
cc._RF.push(module, '2c1e7feMMhAvpohtfoZsaA6', 'startower.mod');
|
|
// Scripts/mod/pve/startower/startower.mod.js
|
|
|
|
"use strict";
|
|
|
|
// --------------------------------------------------------------------
|
|
// @author: xxx@syg.com(必填, 创建模块的人员)
|
|
// @description:
|
|
// 星命塔
|
|
// <br/>Create: 2019-02-27 11:03:16
|
|
// --------------------------------------------------------------------
|
|
|
|
var BridgeController = require("bridge.controller");
|
|
var StartowerEvent = require("startower.define");
|
|
var BTC = require("battle_controller");
|
|
var StartowerController = cc.Class({
|
|
"extends": BridgeController,
|
|
ctor: function ctor() {},
|
|
// 初始化配置数据
|
|
initConfig: function initConfig() {
|
|
// 已通关的最大层数
|
|
this.max_tower = 0;
|
|
//剩余挑战次数
|
|
this.less_count = 0;
|
|
//已购买次数
|
|
this.buy_count = 0;
|
|
this.reward_list = []; //通关奖励状态
|
|
},
|
|
|
|
// 注册协议接受事件
|
|
registerProtocals: function registerProtocals() {
|
|
this.RegisterProtocal(11320, this.handle11320); //星命塔信息
|
|
this.RegisterProtocal(11321, this.handle11321); //购买挑战次数
|
|
this.RegisterProtocal(11322, this.handle11322); //挑战星命塔
|
|
this.RegisterProtocal(11323, this.handle11323); //推送星命塔结算
|
|
this.RegisterProtocal(11324, this.handle11324); //扫荡星命塔
|
|
this.RegisterProtocal(11325, this.handle11325); //请求星命塔通关录像
|
|
this.RegisterProtocal(11326, this.handle11326); //推送星命塔有解锁
|
|
this.RegisterProtocal(11333, this.handle11333); //分享通关录像
|
|
this.RegisterProtocal(11334, this.handle11334);
|
|
this.RegisterProtocal(11335, this.handle11335);
|
|
this.RegisterProtocal(11327, this.handle11327); // 星命塔排行榜
|
|
|
|
this.RegisterProtocal(11328, this.handle11328); //通关奖励
|
|
this.RegisterProtocal(11329, this.handle11329);
|
|
},
|
|
// 从服务器初始化数据
|
|
reqBaseFromServer: function reqBaseFromServer(_cb) {
|
|
var _this = this;
|
|
// 配置加载
|
|
var cfgs = ["star_tower_data"];
|
|
this.loadConfigs(cfgs, function (_ret, _data) {
|
|
_this.reqTowerInitData(_cb);
|
|
});
|
|
},
|
|
reqTowerInitData: function reqTowerInitData(_cb) {
|
|
// 功能解锁检查
|
|
var is_open = this.checkIsOpen();
|
|
|
|
// 锁定中不请求数据
|
|
if (nx.dt.objNEmpty(is_open)) {
|
|
nx.dt.fnInvoke(_cb, true);
|
|
return;
|
|
}
|
|
this.CB11320 = _cb;
|
|
this.SendProtocal(11320, {}, _cb);
|
|
},
|
|
checkIsOpen: function checkIsOpen() {
|
|
if (!game.configs.star_tower_data) return;
|
|
var open_config = game.configs.star_tower_data.data_tower_const.open_floor;
|
|
if (open_config == null) return null;
|
|
var ret = nx.bridge.checkConditions(open_config.val);
|
|
return ret;
|
|
},
|
|
//打开主界面
|
|
openMainView: function openMainView(bool) {
|
|
nx.bridge.createPanel("WndStartower", {});
|
|
},
|
|
//打开挑战主界面
|
|
openStarTowerMainView: function openStarTowerMainView(bool, data) {
|
|
nx.bridge.createPanel("WndStartowerInfo", data);
|
|
},
|
|
//打开奖励总览
|
|
openAwardWindow: function openAwardWindow(bool) {
|
|
if (bool) {
|
|
nx.bridge.createPanel("WndStartowerAward", {});
|
|
} else {
|
|
nx.bridge.closePanel("WndStartowerAward");
|
|
}
|
|
},
|
|
//星命塔结算
|
|
getResultWindow: function getResultWindow() {
|
|
return this.result_window;
|
|
},
|
|
//--打开tips界面
|
|
openTipsWindow: function openTipsWindow(bool, data) {
|
|
if (bool == true) {
|
|
if (this.tips_window == null) {
|
|
this.tips_window = Utils.createClass("star_tower_tips_window", this);
|
|
}
|
|
this.tips_window.open(data);
|
|
} else {
|
|
if (this.tips_window) {
|
|
this.tips_window.close();
|
|
this.tips_window = null;
|
|
}
|
|
}
|
|
},
|
|
//请求星命塔数据
|
|
sender11320: function sender11320() {
|
|
this.SendProtocal(11320, {});
|
|
},
|
|
handle11320: function handle11320(data) {
|
|
// 功能解锁检查
|
|
var is_open = this.checkIsOpen();
|
|
|
|
// 锁定中不请求数据
|
|
if (nx.dt.objNEmpty(is_open)) {
|
|
// nx.dt.fnInvoke( _cb, true );
|
|
return;
|
|
}
|
|
|
|
// 失败判定
|
|
if (!this.isGoodData(data)) {
|
|
return;
|
|
}
|
|
this.setStarTowerData(data);
|
|
},
|
|
//购买挑战次数
|
|
sender11321: function sender11321() {
|
|
var protocal = {};
|
|
this.SendProtocal(11321, protocal);
|
|
},
|
|
handle11321: function handle11321(data) {
|
|
// 失败判定
|
|
if (!this.isGoodData(data)) {
|
|
return;
|
|
}
|
|
this.updateLessCount(data);
|
|
},
|
|
//挑战星命塔
|
|
sender11322: function sender11322(tower, isauto) {
|
|
var protocal = {};
|
|
protocal.tower = tower;
|
|
protocal.isauto = isauto;
|
|
this.SendProtocal(11322, protocal);
|
|
},
|
|
handle11322: function handle11322(data) {
|
|
// 失败判定
|
|
if (!this.isGoodData(data)) {
|
|
return;
|
|
}
|
|
},
|
|
//推送星命塔结算
|
|
handle11323: function handle11323(data) {
|
|
nx.bridge.vset("ResultInfo", data);
|
|
require("battle_controller").getInstance().pushSpecialRetInfo(data.combat_type, data);
|
|
},
|
|
refrreshNewTower: function refrreshNewTower(data) {
|
|
if (data.result == 1) {
|
|
if (data.is_skip == 1) {//--是否跳过战斗打开怪物逃跑界面
|
|
// this.openTipsWindow(true,data)
|
|
}
|
|
this.updateMaxTower(data);
|
|
this.updateLessCount(data);
|
|
this.sender11334();
|
|
}
|
|
},
|
|
//扫荡星命塔
|
|
sender11324: function sender11324(tower) {
|
|
var protocal = {};
|
|
protocal.tower = tower;
|
|
this.SendProtocal(11324, protocal);
|
|
},
|
|
handle11324: function handle11324(data) {
|
|
// 失败判定
|
|
if (!this.isGoodData(data)) {
|
|
return;
|
|
}
|
|
this.updateLessCount(data);
|
|
},
|
|
//请求星命塔通关录像
|
|
sender11325: function sender11325(tower) {
|
|
var protocal = {};
|
|
protocal.tower = tower;
|
|
this.SendProtocal(11325, protocal);
|
|
},
|
|
handle11325: function handle11325(data) {
|
|
// 失败判定
|
|
if (!this.isGoodData(data)) {
|
|
return;
|
|
}
|
|
gcore.GlobalEvent.fire(StartowerEvent.Video_Data_Event, data);
|
|
},
|
|
handle11326: function handle11326(data) {
|
|
this.show_data = data;
|
|
this.is_show_lock = true;
|
|
},
|
|
//分享通关录像
|
|
sender11333: function sender11333(replay_id, channel, tower) {
|
|
var protocal = {};
|
|
protocal.replay_id = replay_id;
|
|
protocal.channel = channel;
|
|
protocal.tower = tower;
|
|
this.SendProtocal(11333, protocal);
|
|
},
|
|
handle11333: function handle11333(data) {
|
|
// 失败判定
|
|
if (!this.isGoodData(data)) {
|
|
return;
|
|
}
|
|
if (data.result == 1) {
|
|
this.openVideoWindow(false);
|
|
}
|
|
},
|
|
sender11334: function sender11334() {
|
|
this.SendProtocal(11334, {});
|
|
},
|
|
handle11334: function handle11334(data) {
|
|
//from_floor,target_floor
|
|
// 失败判定
|
|
// if( !this.isGoodData( data ) ) {
|
|
// return;
|
|
// }
|
|
if (data.result == 1) {
|
|
gcore.GlobalEvent.fire(StartowerEvent.Update_Jump_Floor, data);
|
|
}
|
|
},
|
|
sender11335: function sender11335() {
|
|
this.SendProtocal(11335, {});
|
|
},
|
|
handle11335: function handle11335(data) {
|
|
// 失败判定
|
|
if (!this.isGoodData(data)) {
|
|
return;
|
|
}
|
|
if (data.result == 1) {
|
|
//max_tower
|
|
BTC.getInstance().openOtherFinish(7);
|
|
// let result = nx.bridge.vget( "ResultInfo" );
|
|
// this.refrreshNewTower(result);
|
|
}
|
|
},
|
|
|
|
requestStarTowerRank: function requestStarTowerRank() {
|
|
this.SendProtocal(11327, {});
|
|
},
|
|
handle11327: function handle11327(data) {
|
|
// 失败判定
|
|
if (!this.isGoodData(data)) {
|
|
return;
|
|
}
|
|
gcore.GlobalEvent.fire(StartowerEvent.Update_Top3_rank, data.rank_lists);
|
|
},
|
|
//领取通关奖励
|
|
sender11328: function sender11328(id) {
|
|
var proto = {};
|
|
proto.id = id;
|
|
this.SendProtocal(11328, proto);
|
|
},
|
|
handle11328: function handle11328(data) {
|
|
// 失败判定
|
|
if (!this.isGoodData(data)) {
|
|
return;
|
|
}
|
|
if (data.result == 1) {
|
|
gcore.GlobalEvent.fire(StartowerEvent.Update_Reward_Event);
|
|
}
|
|
},
|
|
handle11329: function handle11329(data) {
|
|
// 失败判定
|
|
if (!this.isGoodData(data)) {
|
|
return;
|
|
}
|
|
this.setRewardData(data.award_list);
|
|
gcore.GlobalEvent.fire(StartowerEvent.Update_First_Reward_Msg);
|
|
},
|
|
////////////////////////////////////////
|
|
setStarTowerData: function setStarTowerData(data) {
|
|
var tempsort = {
|
|
0: 2,
|
|
// 0 未领取放中间
|
|
1: 1,
|
|
// 1 可领取放前面
|
|
2: 3 // 2 已领取放最后
|
|
};
|
|
|
|
this.max_tower = data.max_tower || 0;
|
|
this.less_count = data.count || 0;
|
|
this.buy_count = data.buy_count || 0;
|
|
var is_reward = false;
|
|
if (Utils.next(data.award_list) != null) {
|
|
for (var i in data.award_list) {
|
|
var tab = {};
|
|
tab.id = data.award_list[i].id;
|
|
tab.status = data.award_list[i].status;
|
|
tab.sort = tempsort[tab.status];
|
|
this.reward_list[data.award_list[i].id - 1] = tab;
|
|
if (tab.status == 1) {
|
|
is_reward = true;
|
|
}
|
|
}
|
|
}
|
|
this.reward_list.sort(Utils.tableLowerSorter(["sort", "id"]));
|
|
//更新红点
|
|
nx.mTip.openTip("pve.tower.reward", is_reward);
|
|
gcore.GlobalEvent.fire(StartowerEvent.Update_All_Data);
|
|
},
|
|
setRewardData: function setRewardData(data) {
|
|
if (!this.reward_list || !data[0]) return;
|
|
var tempsort = {
|
|
0: 2,
|
|
// 0 未领取放中间
|
|
1: 1,
|
|
// 1 可领取放前面
|
|
2: 3 // 2 已领取放最后
|
|
};
|
|
|
|
var is_reward = false;
|
|
for (var i in this.reward_list) {
|
|
if (this.reward_list[i].id == data[0].id) {
|
|
this.reward_list[i].status = data[0].status;
|
|
this.reward_list[i].sort = tempsort[data[0].status];
|
|
if (data[0].status == 1) {
|
|
is_reward = true;
|
|
}
|
|
break;
|
|
}
|
|
}
|
|
nx.mTip.openTip("pve.tower.reward", is_reward);
|
|
this.reward_list.sort(Utils.tableLowerSorter(["sort", "id"]));
|
|
},
|
|
sortFunc: function sortFunc(data) {
|
|
data.sort(function (objA, objB) {
|
|
if (objA.sort != objB.sort) {
|
|
if (objA.sort && objB.sort) {
|
|
return objA.sort - objB.sort;
|
|
} else {
|
|
return false;
|
|
}
|
|
} else {
|
|
return objA.id - objB.id;
|
|
}
|
|
});
|
|
return data;
|
|
},
|
|
getRewardData: function getRewardData(id) {
|
|
if (!this.reward_list) return;
|
|
if (id == null) {
|
|
return this.reward_list || {};
|
|
} else {
|
|
return this.reward_list[id] || {};
|
|
}
|
|
},
|
|
getRewardDataById: function getRewardDataById(id) {
|
|
if (!this.reward_list) return;
|
|
if (!id) return null;
|
|
for (var i = 0; i < this.reward_list.length; i++) {
|
|
if (this.reward_list[i].id == id) {
|
|
return this.reward_list[i];
|
|
}
|
|
}
|
|
return null;
|
|
},
|
|
checkRedPoint: function checkRedPoint() {
|
|
var is_open = this.checkIsOpen();
|
|
if (!is_open) return;
|
|
var status = false;
|
|
for (var i in this.reward_list) {
|
|
if (this.reward_list[i].status == 1) {
|
|
status = true;
|
|
break;
|
|
}
|
|
}
|
|
status = status || this.less_count > 0;
|
|
},
|
|
updateMaxTower: function updateMaxTower(data) {
|
|
if (data && data.max_tower && this.max_tower < data.max_tower) {
|
|
this.max_tower = data.max_tower;
|
|
}
|
|
gcore.GlobalEvent.fire(StartowerEvent.Fight_Success_Event);
|
|
},
|
|
updateLessCount: function updateLessCount(data) {
|
|
if (data.count != null) {
|
|
this.less_count = data.count || 0;
|
|
//更新红点
|
|
}
|
|
|
|
if (data.buy_count != null) {
|
|
this.buy_count = data.buy_count;
|
|
}
|
|
gcore.GlobalEvent.fire(StartowerEvent.Count_Change_Event);
|
|
},
|
|
getNowTowerId: function getNowTowerId() {
|
|
return this.max_tower || 0;
|
|
},
|
|
getTowerLessCount: function getTowerLessCount() {
|
|
return this.less_count;
|
|
},
|
|
getBuyCount: function getBuyCount() {
|
|
return this.buy_count;
|
|
}
|
|
////////////////////////////////////////
|
|
});
|
|
|
|
module.exports = StartowerController;
|
|
|
|
cc._RF.pop(); |