diff --git a/assets/script/game/common/SingletonModuleComp.ts b/assets/script/game/common/SingletonModuleComp.ts index 741810fe..20d5401a 100644 --- a/assets/script/game/common/SingletonModuleComp.ts +++ b/assets/script/game/common/SingletonModuleComp.ts @@ -104,6 +104,7 @@ export class SingletonModuleComp extends ecs.Comp { */ private isWxClient(): boolean { // 检查是否存在微信API + return typeof wx !== 'undefined' && typeof (wx as any).getSystemInfoSync === 'function'; } //调试用 diff --git a/assets/script/game/map/HInfoComp.ts b/assets/script/game/map/HInfoComp.ts index ff95ad46..e7fdca88 100644 --- a/assets/script/game/map/HInfoComp.ts +++ b/assets/script/game/map/HInfoComp.ts @@ -62,11 +62,15 @@ export class HInfoComp extends Component { oops.gui.toast("经验或金币不足") return } + smc.spendGameProperty({exp:experience,gold:gold},false) let result=smc.levelUpHero(this.h_uuid,experience,gold) if(!result){ + smc.addGameProperty("exp",experience,false) + smc.addGameProperty("gold",gold,false) oops.gui.toast("网络出错了,升级失败,请重试") return } + this.update_data(this.h_uuid) oops.message.dispatchEvent(GameEvent.UpdateHero, {}) }