开始商店 脚本和ui

This commit is contained in:
2025-08-20 17:46:06 +08:00
parent b531948d4d
commit 1896b5fab0
22 changed files with 9189 additions and 11412 deletions

View File

@@ -8,6 +8,7 @@ import { GameData, WxCloudApi } from "../wx_clound_client_api/WxCloudApi";
import { gameDataSyncManager } from "./GameDataSyncManager";
import { GameSet } from "./config/BoxSet";
import { Test } from "./Test";
import { GameEvent } from "./config/GameEvent";
// import { Role } from "../role/Role";
@@ -76,13 +77,7 @@ export class SingletonModuleComp extends ecs.Comp {
}
// ==================== 数据管理方法 ====================
/**
* 同步数据到vmdata
*/
syncData(){
this.vmdata.data = this.data;
}
/**
* 判断是否为微信客户端
*/
@@ -152,56 +147,50 @@ export class SingletonModuleComp extends ecs.Comp {
*/
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
oops.message.dispatchEvent(GameEvent.GOLD_UPDATE)
if(this.isWxClient()){
this.gameDataSyncManager.addGameProperty("gold",gold)
}
}
addDiamond(diamond:number,autoSave:boolean=true){
this.data.diamond+=diamond
this.vmdata.data.diamond+=diamond
oops.message.dispatchEvent(GameEvent.DIAMOND_UPDATE)
if(this.isWxClient()){
this.gameDataSyncManager.addGameProperty("diamond",diamond)
}
}
addMission(mission:number,autoSave:boolean=true){
this.data.mission+=mission
this.vmdata.data.mission+=mission
oops.message.dispatchEvent(GameEvent.MISSION_UPDATE)
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
oops.message.dispatchEvent(GameEvent.GOLD_UPDATE)
if(this.isWxClient()){
this.gameDataSyncManager.spendGameProperty("gold",gold)
}
}
spendDiamond(diamond:number,autoSave:boolean=true){
this.data.diamond-=diamond
this.vmdata.data.diamond-=diamond
oops.message.dispatchEvent(GameEvent.DIAMOND_UPDATE)
if(this.isWxClient()){
this.gameDataSyncManager.spendGameProperty("diamond",diamond)
}
@@ -227,7 +216,6 @@ export class SingletonModuleComp extends ecs.Comp {
}
const newValue = currentValue - value;
this.data[property] = newValue;
this.vmdata.data[property] = newValue;
console.log(`[SMC]: 消耗游戏数据 ${property} = ${value}, 当前值: ${newValue}`);
return true;
}
@@ -252,7 +240,6 @@ export class SingletonModuleComp extends ecs.Comp {
const current = this.data[key] || 0;
const next = current - need;
this.data[key] = next;
this.vmdata.data[key] = next;
console.log(`[SMC]: 消耗游戏数据 ${key} = ${need}, 当前值: ${next}`);
}