升级 消耗经验和金币,需要本地和网络同步,又要减少操作

This commit is contained in:
2025-08-19 08:56:18 +08:00
parent 18248fdcd7
commit 22f35893d7
2 changed files with 5 additions and 0 deletions

View File

@@ -104,6 +104,7 @@ export class SingletonModuleComp extends ecs.Comp {
*/
private isWxClient(): boolean {
// 检查是否存在微信API
return typeof wx !== 'undefined' && typeof (wx as any).getSystemInfoSync === 'function';
}
//调试用

View File

@@ -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, {})
}