金币经验掉落
This commit is contained in:
@@ -4,7 +4,7 @@ import { Initialize } from "../initialize/Initialize";
|
||||
import { GameMap } from "../map/GameMap";
|
||||
import { HeroUI, VmInfo } from "./config/Mission";
|
||||
import { oops } from "../../../../extensions/oops-plugin-framework/assets/core/Oops";
|
||||
import { WxCloudApi } from "../wx_clound_client_api/WxCloudApi";
|
||||
import { GameData, WxCloudApi } from "../wx_clound_client_api/WxCloudApi";
|
||||
import { gameDataSyncManager } from "./GameDataSyncManager";
|
||||
import { GameSet } from "./config/BoxSet";
|
||||
import { Test } from "./Test";
|
||||
@@ -166,17 +166,63 @@ export class SingletonModuleComp extends ecs.Comp {
|
||||
* @param autoSave 是否自动保存 (默认true)
|
||||
* @returns 操作结果
|
||||
*/
|
||||
async addGameProperty(property: string, value: any, autoSave: boolean = true): Promise<any> {
|
||||
const currentValue = this.data[property] || 0;
|
||||
const newValue = currentValue + value;
|
||||
|
||||
this.data[property] = newValue;
|
||||
this.vmdata.data[property] = newValue;
|
||||
|
||||
console.log(`[SMC]: 增加游戏数据 ${property} = ${value}, 当前值: ${newValue}`);
|
||||
return newValue;
|
||||
addExp(exp:number,autoSave:boolean=true){
|
||||
this.data.exp+=exp
|
||||
this.vmdata.data.exp+=exp
|
||||
if(this.isWxClient()){
|
||||
this.gameDataSyncManager.addGameProperty("exp",exp)
|
||||
}
|
||||
}
|
||||
|
||||
addGold(gold:number,autoSave:boolean=true){
|
||||
this.data.gold+=gold
|
||||
this.vmdata.data.gold+=gold
|
||||
if(this.isWxClient()){
|
||||
this.gameDataSyncManager.addGameProperty("gold",gold)
|
||||
}
|
||||
}
|
||||
addDiamond(diamond:number,autoSave:boolean=true){
|
||||
this.data.diamond+=diamond
|
||||
this.vmdata.data.diamond+=diamond
|
||||
if(this.isWxClient()){
|
||||
this.gameDataSyncManager.addGameProperty("diamond",diamond)
|
||||
}
|
||||
}
|
||||
addMission(mission:number,autoSave:boolean=true){
|
||||
this.data.mission+=mission
|
||||
this.vmdata.data.mission+=mission
|
||||
if(this.isWxClient()){
|
||||
this.gameDataSyncManager.addGameProperty("mission",mission)
|
||||
}
|
||||
}
|
||||
spendMission(mission:number,autoSave:boolean=true){
|
||||
this.data.mission-=mission
|
||||
this.vmdata.data.mission-=mission
|
||||
if(this.isWxClient()){
|
||||
this.gameDataSyncManager.spendGameProperty("mission",mission)
|
||||
}
|
||||
}
|
||||
spendExp(exp:number,autoSave:boolean=true){
|
||||
this.data.exp-=exp
|
||||
this.vmdata.data.exp-=exp
|
||||
if(this.isWxClient()){
|
||||
this.gameDataSyncManager.spendGameProperty("exp",exp)
|
||||
}
|
||||
}
|
||||
spendGold(gold:number,autoSave:boolean=true){
|
||||
this.data.gold-=gold
|
||||
this.vmdata.data.gold-=gold
|
||||
if(this.isWxClient()){
|
||||
this.gameDataSyncManager.spendGameProperty("gold",gold)
|
||||
}
|
||||
}
|
||||
spendDiamond(diamond:number,autoSave:boolean=true){
|
||||
this.data.diamond-=diamond
|
||||
this.vmdata.data.diamond-=diamond
|
||||
if(this.isWxClient()){
|
||||
this.gameDataSyncManager.spendGameProperty("diamond",diamond)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 消耗游戏数据属性(统一接口)
|
||||
* - 支持单个字段:spendGameProperty('gold', 10)
|
||||
@@ -228,6 +274,7 @@ export class SingletonModuleComp extends ecs.Comp {
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
addItem(item_uuid:number,count:number,autoSave:boolean=true){
|
||||
if(this.isWxClient()){
|
||||
this.gameDataSyncManager.addItem(item_uuid,count);
|
||||
|
||||
Reference in New Issue
Block a user