diff --git a/assets/script/game/common/SingletonModuleComp.ts b/assets/script/game/common/SingletonModuleComp.ts index 195065e0..df8f6efe 100644 --- a/assets/script/game/common/SingletonModuleComp.ts +++ b/assets/script/game/common/SingletonModuleComp.ts @@ -61,6 +61,19 @@ export class SingletonModuleComp extends ecs.Comp { current_guide:number=0 fight_hero: number = 5001; // 单个出战英雄 heros:any= [5001] + + collection: { + talents: Record; + player_level: number; + player_exp: number; + talent_points: number; + } = { + talents: {}, // 存储各个天赋的等级: { talent_id: level } + player_level: 1, // 玩家等级 + player_exp: 0, // 玩家当前经验 + talent_points: 0, // 当前可用天赋点 + }; + vmdata: any = { game_over:false, game_pause:false, @@ -131,13 +144,6 @@ export class SingletonModuleComp extends ecs.Comp { } as GameScoreStats, gold: 0, // 金币数据(MVVM绑定字段) - - collection: { - talents: {}, // 存储各个天赋的等级: { talent_id: level } - player_level: 1, // 玩家等级 - player_exp: 0, // 玩家当前经验 - talent_points: 0, // 当前可用天赋点 - }, }; @@ -260,7 +266,7 @@ export class SingletonModuleComp extends ecs.Comp { if(CloudData.data.fight_hero) this.fight_hero=CloudData.data.fight_hero // 恢复收集记录 if(CloudData.data.collection) { - this.vmdata.collection = CloudData.data.collection; + this.collection = CloudData.data.collection; } } @@ -273,7 +279,7 @@ export class SingletonModuleComp extends ecs.Comp { gold:this.vmdata.gold, heros:this.heros, fight_hero:this.fight_hero, - collection: this.vmdata.collection + collection: this.collection } } addHero(hero_uuid:number){ diff --git a/assets/script/game/map/TalentsComp.ts b/assets/script/game/map/TalentsComp.ts index 5b50f1a7..c6e3c969 100644 --- a/assets/script/game/map/TalentsComp.ts +++ b/assets/script/game/map/TalentsComp.ts @@ -98,7 +98,7 @@ export class TalentsComp extends CCComp { /** 更新玩家等级、经验、天赋点信息 */ private updatePlayerInfo() { - const collection = smc.vmdata.collection; + const collection = smc.collection; let level = collection.player_level || 1; let exp = collection.player_exp || 0; let points = collection.talent_points || 0; @@ -137,7 +137,7 @@ export class TalentsComp extends CCComp { private updateTalentList() { if (!this.talents_content || !this.prefab_talent_item) return; - const collection = smc.vmdata.collection; + const collection = smc.collection; if (!collection.talents) collection.talents = {}; // 如果内容为空,则实例化预制体 @@ -180,7 +180,7 @@ export class TalentsComp extends CCComp { let isMax = currentLevel >= talentInfo.maxLevel; let cost = isMax ? 0 : TalentConfig.costPerLevel[currentLevel]; - let points = smc.vmdata.collection.talent_points || 0; + let points = smc.collection.talent_points || 0; if (lblCost) { lblCost.string = isMax ? "已满级" : `消耗: ${cost}点`; @@ -198,7 +198,7 @@ export class TalentsComp extends CCComp { /** 点击升级按钮 */ private onUpgradeClicked(talentId: number, currentLevel: number, cost: number) { - const collection = smc.vmdata.collection; + const collection = smc.collection; let points = collection.talent_points || 0; if (points >= cost && currentLevel < 5) { @@ -224,7 +224,7 @@ export class TalentsComp extends CCComp { // 看广告回调(预留) this.watch_ad().then(success => { if (success) { - const collection = smc.vmdata.collection; + const collection = smc.collection; // 计算已消耗的天赋点总和 let refundedPoints = 0; for (let id in collection.talents) {