开始商店 脚本和ui
This commit is contained in:
@@ -65,9 +65,6 @@ export class GameDataSyncManager {
|
||||
console.log(`[Initialize]: 装备数据已从${dataSource}覆盖`);
|
||||
}
|
||||
|
||||
// 同步ViewModel数据
|
||||
smc.syncData();
|
||||
|
||||
// 保存到本地存储(确保数据持久化)
|
||||
// smc.saveGameData();
|
||||
|
||||
@@ -457,10 +454,7 @@ export class GameDataSyncManager {
|
||||
smc.items = cloudData.items;
|
||||
smc.tals = cloudData.tals;
|
||||
smc.equips = cloudData.equips;
|
||||
|
||||
// 同步vmdata
|
||||
smc.syncData();
|
||||
|
||||
|
||||
console.log(`[GameDataSyncManager]: 云端数据加载成功,本地数据已同步`);
|
||||
return true;
|
||||
} else {
|
||||
|
||||
@@ -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}`);
|
||||
}
|
||||
|
||||
|
||||
24
assets/script/game/common/config/Goods.ts
Normal file
24
assets/script/game/common/config/Goods.ts
Normal file
@@ -0,0 +1,24 @@
|
||||
import { Items } from "./Items";
|
||||
|
||||
export enum GType{
|
||||
ITEM=1, //物品
|
||||
GOLD=2, //金币
|
||||
DIAMOND=3, //钻石
|
||||
EXP=4, //经验
|
||||
MEAT=5, //能量
|
||||
}
|
||||
export enum CType{
|
||||
GOLD=1, //金币
|
||||
DIAMOND=2, //钻石
|
||||
FREE=3, //免费
|
||||
AD=4, //广告
|
||||
}
|
||||
export const Goods={
|
||||
1001:{i_uuid:Items[9001].uuid,num:10000,cast:0,type:GType.GOLD,c_type:CType.FREE},
|
||||
1002:{i_uuid:Items[9002].uuid,num:100000,cast:0,type:GType.GOLD,c_type:CType.AD,},
|
||||
1003:{i_uuid:Items[9003].uuid,num:500000,cast:100,type:GType.GOLD,c_type:CType.DIAMOND},
|
||||
1004:{i_uuid:Items[9004].uuid,num:100,cast:0,type:GType.DIAMOND,c_type:CType.FREE},
|
||||
1005:{i_uuid:Items[9005].uuid,num:200,cast:0,type:GType.DIAMOND,c_type:CType.FREE},
|
||||
1006:{i_uuid:Items[9006].uuid,num:300,cast:0,type:GType.DIAMOND,c_type:CType.AD},
|
||||
1007:{i_uuid:Items[9007].uuid,num:500,cast:0,type:GType.DIAMOND,c_type:CType.AD},
|
||||
}
|
||||
9
assets/script/game/common/config/Goods.ts.meta
Normal file
9
assets/script/game/common/config/Goods.ts.meta
Normal file
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"ver": "4.0.24",
|
||||
"importer": "typescript",
|
||||
"imported": true,
|
||||
"uuid": "0ca1e413-6bfd-4e8a-95cc-56fb3e54075a",
|
||||
"files": [],
|
||||
"subMetas": {},
|
||||
"userData": {}
|
||||
}
|
||||
@@ -33,6 +33,15 @@ export const Items={
|
||||
1006:{uuid: 1006,path: "1006",type:1,quality:QualitySet.BLUE,name: "铜钥匙",info:"解锁稀有英雄 也可以直接兑换金币", },
|
||||
1007:{uuid: 1007,path: "1007",type:1,quality:QualitySet.PURPLE,name: "银钥匙",info:"解锁史诗英雄 也可以直接兑换金币", },
|
||||
1008:{uuid: 1008,path: "1008",type:1,quality:QualitySet.ORANGE,name: "金钥匙",info:"解锁传说英雄 也可以直接兑换金币", },
|
||||
9001:{uuid: 9001,path: "9001",type:1,quality:QualitySet.GREEN,name: "金币",info:"少许金币", },
|
||||
9002:{uuid: 9002,path: "9002",type:1,quality:QualitySet.BLUE,name: "小袋金币",info:"一小袋金币", },
|
||||
9003:{uuid: 9003,path: "9003",type:1,quality:QualitySet.PURPLE,name: "大袋金币",info:"一大袋金币", },
|
||||
9004:{uuid: 9004,path: "9004",type:1,quality:QualitySet.GREEN,name: "钻石",info:"少许钻石", },
|
||||
9005:{uuid: 9005,path: "9005",type:1,quality:QualitySet.GREEN,name: "钻石",info:"少许钻石", },
|
||||
9006:{uuid: 9006,path: "9006",type:1,quality:QualitySet.BLUE,name: "小袋钻石",info:"一小袋钻石", },
|
||||
9007:{uuid: 9007,path: "9007",type:1,quality:QualitySet.BLUE,name: "大袋钻石",info:"一大袋钻石", },
|
||||
9008:{uuid: 9008,path: "9008",type:1,quality:QualitySet.PURPLE,name: "小箱钻石",info:"一小箱钻石", },
|
||||
9009:{uuid: 9009,path: "9009",type:1,quality:QualitySet.PURPLE,name: "大箱钻石",info:"一大箱钻石", },
|
||||
}
|
||||
|
||||
export enum DropKey{
|
||||
|
||||
@@ -1,9 +0,0 @@
|
||||
{
|
||||
"ver": "1.2.0",
|
||||
"importer": "directory",
|
||||
"imported": true,
|
||||
"uuid": "f6f84e06-578b-446b-b5d7-595b686efbe0",
|
||||
"files": [],
|
||||
"subMetas": {},
|
||||
"userData": {}
|
||||
}
|
||||
Reference in New Issue
Block a user