|
|
@@ -10,7 +10,6 @@ import PlayerUpdateResponse from "../net/msg/PlayerUpdateResponse";
|
|
|
import { Dictionary } from "../utils/Dictionary";
|
|
|
import BarrackVO from "../vo/BarrackVO";
|
|
|
import BuffVO from "../vo/BuffVO";
|
|
|
-import CommanderSkillVO from "../vo/CommanderSkillVO";
|
|
|
import FetterVO from "../vo/FetterVO";
|
|
|
import GeneralVO from "../vo/GeneralVO";
|
|
|
import MissionVO from "../vo/MissionVO";
|
|
|
@@ -52,11 +51,11 @@ export default class GameData {
|
|
|
private skill_data: any;
|
|
|
private star_data: any;
|
|
|
private item_data: any;
|
|
|
- private barrack_data: Dictionary<number, BarrackVO> = new Dictionary<number, BarrackVO>();
|
|
|
- private barrack_json: any;
|
|
|
+ private turntable_data: any;
|
|
|
+ private barrack_data: Dictionary<number, BarrackVO>;
|
|
|
db_data: any;
|
|
|
help_data: any;
|
|
|
- server_data: any;
|
|
|
+ serverConfig_data: any;
|
|
|
commanderskill_data: any;
|
|
|
private task_data: any;
|
|
|
|
|
|
@@ -76,16 +75,15 @@ export default class GameData {
|
|
|
this.mission_data = await GameController.resM.loadRemoteJson('https://xcx-box.oss-cn-hangzhou.aliyuncs.com/hotgame/h5game/tower_sanguo/data/mission_data.json?v=' + new Date().getTime());
|
|
|
this.star_data = await GameController.resM.loadRemoteJson('https://xcx-box.oss-cn-hangzhou.aliyuncs.com/hotgame/h5game/tower_sanguo/data/star_data.json?v=' + new Date().getTime());
|
|
|
this.item_data = await GameController.resM.loadRemoteJson('https://xcx-box.oss-cn-hangzhou.aliyuncs.com/hotgame/h5game/tower_sanguo/data/item_data.json?v=' + new Date().getTime());
|
|
|
- this.barrack_json = await GameController.resM.loadRemoteJson('https://xcx-box.oss-cn-hangzhou.aliyuncs.com/hotgame/h5game/tower_sanguo/data/barrack_data.json?v=' + new Date().getTime());
|
|
|
+ this.barrack_data = await GameController.resM.loadRemoteJson('https://xcx-box.oss-cn-hangzhou.aliyuncs.com/hotgame/h5game/tower_sanguo/data/barrack_data.json?v=' + new Date().getTime());
|
|
|
this.db_data = await GameController.resM.loadRemoteJson('https://xcx-box.oss-cn-hangzhou.aliyuncs.com/hotgame/h5game/tower_sanguo/data/db_data.json?v=' + new Date().getTime());
|
|
|
- this.server_data = await GameController.resM.loadRemoteJson('https://xcx-box.oss-cn-hangzhou.aliyuncs.com/hotgame/h5game/tower_sanguo/data/serverConfig_data.json?v=' + new Date().getTime());
|
|
|
+ this.serverConfig_data = await GameController.resM.loadRemoteJson('https://xcx-box.oss-cn-hangzhou.aliyuncs.com/hotgame/h5game/tower_sanguo/data/serverConfig_data.json?v=' + new Date().getTime());
|
|
|
this.help_data = await GameController.resM.loadRemoteJson('https://xcx-box.oss-cn-hangzhou.aliyuncs.com/hotgame/h5game/tower_sanguo/data/help_data.json?v=' + new Date().getTime());
|
|
|
this.commanderskill_data = await GameController.resM.loadRemoteJson('https://xcx-box.oss-cn-hangzhou.aliyuncs.com/hotgame/h5game/tower_sanguo/data/commanderskill_data.json?v=' + new Date().getTime());
|
|
|
- this.task_data = await GameController.resM.loadRemoteJson('https://xcx-box.oss-cn-hangzhou.aliyuncs.com/hotgame/h5game/tower_sanguo/data/task_data.json?v=' + new Date().getTime());
|
|
|
- turntableModel.Instance.turntable_data = await GameController.resM.loadRemoteJson('https://xcx-box.oss-cn-hangzhou.aliyuncs.com/hotgame/h5game/tower_sanguo/data/turntable_data.json?v=' + new Date().getTime());
|
|
|
+ this.turntable_data = await GameController.resM.loadRemoteJson('https://xcx-box.oss-cn-hangzhou.aliyuncs.com/hotgame/h5game/tower_sanguo/data/turntable_data.json?v=' + new Date().getTime());
|
|
|
|
|
|
// this.db_data = cc.loader.getRes("data/db_data", cc.JsonAsset).json;
|
|
|
- // this.server_data = cc.loader.getRes("data/serverConfig_data", cc.JsonAsset).json;
|
|
|
+ // this.serverConfig_data = cc.loader.getRes("data/serverConfig_data", cc.JsonAsset).json;
|
|
|
// this.fetter_data = cc.loader.getRes("data/fetter_data", cc.JsonAsset).json;
|
|
|
// this.buff_data = cc.loader.getRes("data/buff_data", cc.JsonAsset).json;
|
|
|
// this.skill_data = cc.loader.getRes("data/skill_data", cc.JsonAsset).json;
|
|
|
@@ -93,12 +91,12 @@ export default class GameData {
|
|
|
// this.monster_data = cc.loader.getRes("data/monster_data", cc.JsonAsset).json;
|
|
|
// this.mission_data = cc.loader.getRes("data/mission_data", cc.JsonAsset).json;
|
|
|
// this.item_data = cc.loader.getRes("data/item_data", cc.JsonAsset).json;
|
|
|
- // this.barrack_json = cc.loader.getRes("data/barrack_data", cc.JsonAsset).json;
|
|
|
+ // this.barrack_data = cc.loader.getRes("data/barrack_data", cc.JsonAsset).json;
|
|
|
// this.star_data = cc.loader.getRes("data/star_data", cc.JsonAsset).json;
|
|
|
// this.help_data = cc.loader.getRes("data/help_data", cc.JsonAsset).json;
|
|
|
+ // this.turntable_data = cc.loader.getRes("data/turntable_data", cc.JsonAsset).json;
|
|
|
// this.commanderskill_data = cc.loader.getRes("data/commanderskill_data", cc.JsonAsset).json;
|
|
|
- this.task_data = cc.loader.getRes("data/task_data", cc.JsonAsset).json;
|
|
|
- // turntableModel.Instance.turntable_data = cc.loader.getRes("data/turntable_data", cc.JsonAsset).json;
|
|
|
+
|
|
|
this.initJsonData();
|
|
|
}
|
|
|
else {
|
|
|
@@ -108,45 +106,7 @@ export default class GameData {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- jsons = ['buff', 'fetter', 'skill', 'general', 'monster', 'mission', 'star', 'item', 'barrack', 'db', 'serverConfig', 'help'];
|
|
|
- count = 0;
|
|
|
-
|
|
|
- loadConfig(err = null, data = null) {
|
|
|
- if (err) {
|
|
|
- console.log(err, data);
|
|
|
- }
|
|
|
- let json = this.jsons[this.count];
|
|
|
- if (data) {
|
|
|
- if (json == "serverConfig") {
|
|
|
- json = 'server'
|
|
|
- }
|
|
|
- if (json == 'barrack') {
|
|
|
- this.barrack_json = data;
|
|
|
- }
|
|
|
- else {
|
|
|
- this[json + "_data"] = data;
|
|
|
- }
|
|
|
- this.count++;
|
|
|
- json = this.jsons[this.count];
|
|
|
- }
|
|
|
-
|
|
|
- if (json == null) {
|
|
|
- if (GameController.servertest) {
|
|
|
- GameController.servertest.init();
|
|
|
- }
|
|
|
-
|
|
|
- this.initJsonData();
|
|
|
-
|
|
|
- // GameController.initSDK();
|
|
|
- return;
|
|
|
- }
|
|
|
- let url = 'https://xcx-box.oss-cn-hangzhou.aliyuncs.com/hotgame/h5game/tower_sanguo/data/' + json + '_data.json?v=' + new Date().getTime()
|
|
|
- cc.loader.load({ url: url, type: "json" }, this.loadConfig.bind(this));
|
|
|
- }
|
|
|
-
|
|
|
initZip(buffer) {
|
|
|
- console.log("initZIP:start");
|
|
|
-
|
|
|
var self = this;
|
|
|
JSZip.loadAsync(buffer).then((zip) => {
|
|
|
let total = 0;
|
|
|
@@ -158,7 +118,6 @@ export default class GameData {
|
|
|
let dataname = key.slice(5, key.length - 5);
|
|
|
self[dataname] = JSON.parse(data);
|
|
|
count++;
|
|
|
- console.log("zip.file:" + count + "..." + total);
|
|
|
if (count == total) {
|
|
|
this.initJsonData();
|
|
|
}
|
|
|
@@ -168,8 +127,6 @@ export default class GameData {
|
|
|
}
|
|
|
|
|
|
private initJsonData() {
|
|
|
- console.log("initJsonData");
|
|
|
-
|
|
|
if (GameController.servertest) {
|
|
|
GameController.servertest.init();
|
|
|
}
|
|
|
@@ -316,16 +273,13 @@ export default class GameData {
|
|
|
}
|
|
|
|
|
|
//兵营
|
|
|
- for (let i in this.barrack_json) {
|
|
|
- let o = this.barrack_json[i];
|
|
|
+ let temp_data = this.barrack_data;
|
|
|
+ this.barrack_data = new Dictionary<number, BarrackVO>();
|
|
|
+ for (let i in temp_data) {
|
|
|
+ let o = temp_data[i];
|
|
|
let vo = new BarrackVO();
|
|
|
vo.campLv = o.campLv;
|
|
|
- if (o.cost) {
|
|
|
- vo.cost = parseInt(o.cost.split(':')[1]);
|
|
|
- }
|
|
|
- else {
|
|
|
- vo.cost = o.cost;
|
|
|
- }
|
|
|
+ vo.cost = o.cost;
|
|
|
vo.unlockHero = [];
|
|
|
if (o.unlockHero.length > 0) {
|
|
|
let arr: string[] = o.unlockHero.split(",");
|
|
|
@@ -336,23 +290,7 @@ export default class GameData {
|
|
|
this.barrack_data.setValue(vo.campLv, vo);
|
|
|
}
|
|
|
|
|
|
- for (let i in this.commanderskill_data) {
|
|
|
- let o = this.commanderskill_data[i];
|
|
|
- let csvo = new CommanderSkillVO();
|
|
|
- csvo.id = o.id;
|
|
|
- let tempstars = o.starcount.split(":");
|
|
|
- for (let i = 0; i < tempstars.length; i++) {
|
|
|
- csvo.unlockstarcount.push(parseInt(tempstars[i]));
|
|
|
- }
|
|
|
- this.commanderskill_data[i] = csvo;
|
|
|
- console.log("index: " + i + " d: ", o);
|
|
|
- }
|
|
|
-
|
|
|
- console.log("commanderskill_data: ", this.commanderskill_data);
|
|
|
- console.log("skill_data: ", this.skill_data);
|
|
|
-
|
|
|
- // 任务
|
|
|
- this.initTaskData();
|
|
|
+ turntableModel.Instance.turntable_data = this.turntable_data;
|
|
|
|
|
|
GameController.initSDK();
|
|
|
}
|
|
|
@@ -503,11 +441,7 @@ export default class GameData {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- this.initScheduler();
|
|
|
-
|
|
|
GameController.loadMain();
|
|
|
-
|
|
|
- console.log("____________loadMain");
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -590,19 +524,6 @@ export default class GameData {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- private initScheduler() {
|
|
|
- let self = this;
|
|
|
- let count = 0;
|
|
|
- let a = cc.director.getScheduler().schedule(() => {
|
|
|
- count++;
|
|
|
- if (count % 5 == 0) {
|
|
|
- count = 1;
|
|
|
- let vo: MissionVO = self.getMissionByID(self.player.current_mission);
|
|
|
- self.updateProp(PLAYERPROP.FOOD, Math.floor(vo.foodRecover * 5), true);
|
|
|
- }
|
|
|
- }, this, 1);
|
|
|
- }
|
|
|
-
|
|
|
/**
|
|
|
* 兵营等级更新后,更新开放武将及下个开放武将
|
|
|
* @param barrackLv
|