升级 消耗经验和金币,需要本地和网络同步,又要减少操作
This commit is contained in:
@@ -104,6 +104,7 @@ export class SingletonModuleComp extends ecs.Comp {
|
|||||||
*/
|
*/
|
||||||
private isWxClient(): boolean {
|
private isWxClient(): boolean {
|
||||||
// 检查是否存在微信API
|
// 检查是否存在微信API
|
||||||
|
|
||||||
return typeof wx !== 'undefined' && typeof (wx as any).getSystemInfoSync === 'function';
|
return typeof wx !== 'undefined' && typeof (wx as any).getSystemInfoSync === 'function';
|
||||||
}
|
}
|
||||||
//调试用
|
//调试用
|
||||||
|
|||||||
@@ -62,11 +62,15 @@ export class HInfoComp extends Component {
|
|||||||
oops.gui.toast("经验或金币不足")
|
oops.gui.toast("经验或金币不足")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
smc.spendGameProperty({exp:experience,gold:gold},false)
|
||||||
let result=smc.levelUpHero(this.h_uuid,experience,gold)
|
let result=smc.levelUpHero(this.h_uuid,experience,gold)
|
||||||
if(!result){
|
if(!result){
|
||||||
|
smc.addGameProperty("exp",experience,false)
|
||||||
|
smc.addGameProperty("gold",gold,false)
|
||||||
oops.gui.toast("网络出错了,升级失败,请重试")
|
oops.gui.toast("网络出错了,升级失败,请重试")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
this.update_data(this.h_uuid)
|
this.update_data(this.h_uuid)
|
||||||
oops.message.dispatchEvent(GameEvent.UpdateHero, {})
|
oops.message.dispatchEvent(GameEvent.UpdateHero, {})
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user