初始版本可以去申请电子版权和软著了

This commit is contained in:
2025-08-21 13:54:28 +08:00
parent 0a654d130a
commit 1b56cb7a8c
12 changed files with 1816 additions and 185 deletions

File diff suppressed because it is too large Load Diff

View File

@@ -13743,7 +13743,7 @@
"value": {
"__type__": "cc.Vec3",
"x": 0,
"y": -74.475,
"y": 3,
"z": 0
}
},
@@ -14112,7 +14112,7 @@
"value": {
"__type__": "cc.Vec3",
"x": 0,
"y": -74.475,
"y": 3,
"z": 0
}
},
@@ -14481,7 +14481,7 @@
"value": {
"__type__": "cc.Vec3",
"x": 0,
"y": -74.475,
"y": 3,
"z": 0
}
},
@@ -14850,7 +14850,7 @@
"value": {
"__type__": "cc.Vec3",
"x": 0,
"y": -74.475,
"y": 3,
"z": 0
}
},
@@ -16380,7 +16380,7 @@
"value": {
"__type__": "cc.Vec3",
"x": 0,
"y": -74.475,
"y": 3,
"z": 0
}
},
@@ -16946,7 +16946,7 @@
"value": {
"__type__": "cc.Vec3",
"x": 0,
"y": -74.475,
"y": 3,
"z": 0
}
},
@@ -17512,7 +17512,7 @@
"value": {
"__type__": "cc.Vec3",
"x": 0,
"y": -74.475,
"y": 3,
"z": 0
}
},
@@ -18078,7 +18078,7 @@
"value": {
"__type__": "cc.Vec3",
"x": 0,
"y": -74.475,
"y": 3,
"z": 0
}
},
@@ -18644,7 +18644,7 @@
"value": {
"__type__": "cc.Vec3",
"x": 0,
"y": -74.475,
"y": 3,
"z": 0
}
},
@@ -19210,7 +19210,7 @@
"value": {
"__type__": "cc.Vec3",
"x": 0,
"y": -74.475,
"y": 3,
"z": 0
}
},
@@ -19776,7 +19776,7 @@
"value": {
"__type__": "cc.Vec3",
"x": 0,
"y": -74.475,
"y": 3,
"z": 0
}
},
@@ -20342,7 +20342,7 @@
"value": {
"__type__": "cc.Vec3",
"x": 0,
"y": -74.475,
"y": 3,
"z": 0
}
},
@@ -24113,7 +24113,7 @@
},
"_lpos": {
"__type__": "cc.Vec3",
"x": -289,
"x": -142,
"y": 0,
"z": 0
},
@@ -25051,7 +25051,7 @@
},
{
"__type__": "cc.Node",
"_name": "heros",
"_name": "fight",
"_objFlags": 0,
"__editorExtras__": {},
"_parent": {
@@ -25079,7 +25079,7 @@
},
"_lpos": {
"__type__": "cc.Vec3",
"x": -142,
"x": 5,
"y": 0,
"z": 0
},
@@ -25239,7 +25239,7 @@
},
{
"__type__": "cc.CompPrefabInfo",
"fileId": "66aRnMzUNJT7JfmjGwQKaT"
"fileId": "24CllqOIRNbp7s1IW4j0uU"
},
{
"__type__": "cc.Sprite",
@@ -25264,7 +25264,7 @@
"a": 255
},
"_spriteFrame": {
"__uuid__": "49c583b3-d566-4c79-9e4c-bd0ca4a4b717@864ce",
"__uuid__": "49c583b3-d566-4c79-9e4c-bd0ca4a4b717@ceee5",
"__expectedType__": "cc.SpriteFrame"
},
"_type": 0,
@@ -25284,7 +25284,7 @@
},
{
"__type__": "cc.CompPrefabInfo",
"fileId": "404j0IpaFLap9Fy8jf2s5C"
"fileId": "571wESdL9Ch5Aga22pMiOB"
},
{
"__type__": "cc.PrefabInfo",
@@ -25294,7 +25294,7 @@
"asset": {
"__id__": 0
},
"fileId": "ceuhLCdJBJpo7n0PYDcCnl",
"fileId": "00lvUE1TVIr5IJdUtl2KYh",
"instance": null,
"targetOverrides": null,
"nestedPrefabInstanceRoots": null
@@ -25325,7 +25325,7 @@
},
{
"__type__": "cc.CompPrefabInfo",
"fileId": "acvWGdl+FCz49w9mrZvAyL"
"fileId": "d9I3+60/JAH62yMJ/YCQc2"
},
{
"__type__": "cc.Sprite",
@@ -25370,7 +25370,7 @@
},
{
"__type__": "cc.CompPrefabInfo",
"fileId": "775O/jIEZFDJJWO95yOSqW"
"fileId": "ce3MO/ALxKS6CECBmzKUeQ"
},
{
"__type__": "cc.Widget",
@@ -25406,7 +25406,7 @@
},
{
"__type__": "cc.CompPrefabInfo",
"fileId": "2fkiaXCEhNabWOjHF9Egng"
"fileId": "1bjoS7XVZKC7untXSJCRQ1"
},
{
"__type__": "cc.PrefabInfo",
@@ -25416,7 +25416,7 @@
"asset": {
"__id__": 0
},
"fileId": "00Gy6Lv5VDrbtQldm2T+Ee",
"fileId": "eblW2XA4tBf6SV/oGAOQaW",
"instance": null,
"targetOverrides": null,
"nestedPrefabInstanceRoots": null
@@ -25557,7 +25557,7 @@
},
{
"__type__": "cc.CompPrefabInfo",
"fileId": "26BrlSRDVCkpi2ui5yIv8E"
"fileId": "ecXrazZPxEHJnUFMi9YYDI"
},
{
"__type__": "cc.Sprite",
@@ -25582,7 +25582,7 @@
"a": 255
},
"_spriteFrame": {
"__uuid__": "49c583b3-d566-4c79-9e4c-bd0ca4a4b717@864ce",
"__uuid__": "49c583b3-d566-4c79-9e4c-bd0ca4a4b717@ceee5",
"__expectedType__": "cc.SpriteFrame"
},
"_type": 0,
@@ -25602,7 +25602,7 @@
},
{
"__type__": "cc.CompPrefabInfo",
"fileId": "1aYbkTiyZHM73DdqVex/VP"
"fileId": "9eMR9M5uBMg6hUMwVlNGOx"
},
{
"__type__": "cc.PrefabInfo",
@@ -25612,7 +25612,7 @@
"asset": {
"__id__": 0
},
"fileId": "055UbZLjhDoK+n6A4TtgGE",
"fileId": "514wN4XnROFrTZsHG02NaE",
"instance": null,
"targetOverrides": null,
"nestedPrefabInstanceRoots": null
@@ -25693,7 +25693,7 @@
},
{
"__type__": "cc.CompPrefabInfo",
"fileId": "52gC9yGyBA16JEZXIpGsaz"
"fileId": "1080gTuGJAj6NyUWSuWJ8L"
},
{
"__type__": "cc.Label",
@@ -25717,7 +25717,7 @@
"b": 255,
"a": 255
},
"_string": "英雄",
"_string": "战斗",
"_horizontalAlign": 1,
"_verticalAlign": 1,
"_actualFontSize": 25,
@@ -25761,7 +25761,7 @@
},
{
"__type__": "cc.CompPrefabInfo",
"fileId": "81fMHOlHhNWoUd6OWVWTSV"
"fileId": "ceEdeMablGt4AP0tFEI/VO"
},
{
"__type__": "cc.PrefabInfo",
@@ -25771,7 +25771,7 @@
"asset": {
"__id__": 0
},
"fileId": "535buBkgFF976vfLYXPiJW",
"fileId": "f2GqKr+KhGDYVFRGQ66hwq",
"instance": null,
"targetOverrides": null,
"nestedPrefabInstanceRoots": null
@@ -25802,7 +25802,7 @@
},
{
"__type__": "cc.CompPrefabInfo",
"fileId": "abSAFPTB9FQp3DaDTN3um/"
"fileId": "c5hHeNcQpC4pbaGmROTCFs"
},
{
"__type__": "cc.Sprite",
@@ -25847,7 +25847,7 @@
},
{
"__type__": "cc.CompPrefabInfo",
"fileId": "52ZUkZ8ahLDYv00qXLuIBe"
"fileId": "f2LE7uQZZKEq+JHQsvTuG7"
},
{
"__type__": "cc.Widget",
@@ -25883,7 +25883,7 @@
},
{
"__type__": "cc.CompPrefabInfo",
"fileId": "cdJWrH5SpAdqaCjwZdBY4P"
"fileId": "beAmjTm9NHV5Zcm66Lw5TZ"
},
{
"__type__": "cc.PrefabInfo",
@@ -25893,7 +25893,7 @@
"asset": {
"__id__": 0
},
"fileId": "3cUPE46lZDFpIoIEa5SKtH",
"fileId": "50V4KrAplBdpEu34KxASqU",
"instance": null,
"targetOverrides": null,
"nestedPrefabInstanceRoots": null
@@ -25924,7 +25924,7 @@
},
{
"__type__": "cc.CompPrefabInfo",
"fileId": "5fdCvllLREuogKgB0x8O69"
"fileId": "f3WGDj8lZGL4ph5tNYqAs/"
},
{
"__type__": "cc.Button",
@@ -25984,7 +25984,7 @@
},
{
"__type__": "cc.CompPrefabInfo",
"fileId": "a8F6hzq39Dwrxs35dF97yA"
"fileId": "48+/XTINJBgbqup+dSL/9D"
},
{
"__type__": "cc.ClickEvent",
@@ -25994,7 +25994,7 @@
"component": "",
"_componentId": "11498TbVJpO6qmZ8m9k55Zx",
"handler": "btn_func",
"customEventData": "heros"
"customEventData": "fight"
},
{
"__type__": "cc.PrefabInfo",
@@ -26004,14 +26004,14 @@
"asset": {
"__id__": 0
},
"fileId": "2f00V76bdDG6jYeodHvdkw",
"fileId": "9elmcSk75AzaRXoY2+iXEn",
"instance": null,
"targetOverrides": null,
"nestedPrefabInstanceRoots": null
},
{
"__type__": "cc.Node",
"_name": "fight",
"_name": "heros",
"_objFlags": 0,
"__editorExtras__": {},
"_parent": {
@@ -26039,7 +26039,7 @@
},
"_lpos": {
"__type__": "cc.Vec3",
"x": 5,
"x": 152,
"y": 0,
"z": 0
},
@@ -26199,7 +26199,7 @@
},
{
"__type__": "cc.CompPrefabInfo",
"fileId": "24CllqOIRNbp7s1IW4j0uU"
"fileId": "66aRnMzUNJT7JfmjGwQKaT"
},
{
"__type__": "cc.Sprite",
@@ -26224,7 +26224,7 @@
"a": 255
},
"_spriteFrame": {
"__uuid__": "49c583b3-d566-4c79-9e4c-bd0ca4a4b717@ceee5",
"__uuid__": "49c583b3-d566-4c79-9e4c-bd0ca4a4b717@864ce",
"__expectedType__": "cc.SpriteFrame"
},
"_type": 0,
@@ -26244,7 +26244,7 @@
},
{
"__type__": "cc.CompPrefabInfo",
"fileId": "571wESdL9Ch5Aga22pMiOB"
"fileId": "404j0IpaFLap9Fy8jf2s5C"
},
{
"__type__": "cc.PrefabInfo",
@@ -26254,7 +26254,7 @@
"asset": {
"__id__": 0
},
"fileId": "00lvUE1TVIr5IJdUtl2KYh",
"fileId": "ceuhLCdJBJpo7n0PYDcCnl",
"instance": null,
"targetOverrides": null,
"nestedPrefabInstanceRoots": null
@@ -26285,7 +26285,7 @@
},
{
"__type__": "cc.CompPrefabInfo",
"fileId": "d9I3+60/JAH62yMJ/YCQc2"
"fileId": "acvWGdl+FCz49w9mrZvAyL"
},
{
"__type__": "cc.Sprite",
@@ -26330,7 +26330,7 @@
},
{
"__type__": "cc.CompPrefabInfo",
"fileId": "ce3MO/ALxKS6CECBmzKUeQ"
"fileId": "775O/jIEZFDJJWO95yOSqW"
},
{
"__type__": "cc.Widget",
@@ -26366,7 +26366,7 @@
},
{
"__type__": "cc.CompPrefabInfo",
"fileId": "1bjoS7XVZKC7untXSJCRQ1"
"fileId": "2fkiaXCEhNabWOjHF9Egng"
},
{
"__type__": "cc.PrefabInfo",
@@ -26376,7 +26376,7 @@
"asset": {
"__id__": 0
},
"fileId": "eblW2XA4tBf6SV/oGAOQaW",
"fileId": "00Gy6Lv5VDrbtQldm2T+Ee",
"instance": null,
"targetOverrides": null,
"nestedPrefabInstanceRoots": null
@@ -26517,7 +26517,7 @@
},
{
"__type__": "cc.CompPrefabInfo",
"fileId": "ecXrazZPxEHJnUFMi9YYDI"
"fileId": "26BrlSRDVCkpi2ui5yIv8E"
},
{
"__type__": "cc.Sprite",
@@ -26542,7 +26542,7 @@
"a": 255
},
"_spriteFrame": {
"__uuid__": "49c583b3-d566-4c79-9e4c-bd0ca4a4b717@ceee5",
"__uuid__": "49c583b3-d566-4c79-9e4c-bd0ca4a4b717@864ce",
"__expectedType__": "cc.SpriteFrame"
},
"_type": 0,
@@ -26562,7 +26562,7 @@
},
{
"__type__": "cc.CompPrefabInfo",
"fileId": "9eMR9M5uBMg6hUMwVlNGOx"
"fileId": "1aYbkTiyZHM73DdqVex/VP"
},
{
"__type__": "cc.PrefabInfo",
@@ -26572,7 +26572,7 @@
"asset": {
"__id__": 0
},
"fileId": "514wN4XnROFrTZsHG02NaE",
"fileId": "055UbZLjhDoK+n6A4TtgGE",
"instance": null,
"targetOverrides": null,
"nestedPrefabInstanceRoots": null
@@ -26653,7 +26653,7 @@
},
{
"__type__": "cc.CompPrefabInfo",
"fileId": "1080gTuGJAj6NyUWSuWJ8L"
"fileId": "52gC9yGyBA16JEZXIpGsaz"
},
{
"__type__": "cc.Label",
@@ -26677,7 +26677,7 @@
"b": 255,
"a": 255
},
"_string": "战斗",
"_string": "英雄",
"_horizontalAlign": 1,
"_verticalAlign": 1,
"_actualFontSize": 25,
@@ -26721,7 +26721,7 @@
},
{
"__type__": "cc.CompPrefabInfo",
"fileId": "ceEdeMablGt4AP0tFEI/VO"
"fileId": "81fMHOlHhNWoUd6OWVWTSV"
},
{
"__type__": "cc.PrefabInfo",
@@ -26731,7 +26731,7 @@
"asset": {
"__id__": 0
},
"fileId": "f2GqKr+KhGDYVFRGQ66hwq",
"fileId": "535buBkgFF976vfLYXPiJW",
"instance": null,
"targetOverrides": null,
"nestedPrefabInstanceRoots": null
@@ -26762,7 +26762,7 @@
},
{
"__type__": "cc.CompPrefabInfo",
"fileId": "c5hHeNcQpC4pbaGmROTCFs"
"fileId": "abSAFPTB9FQp3DaDTN3um/"
},
{
"__type__": "cc.Sprite",
@@ -26807,7 +26807,7 @@
},
{
"__type__": "cc.CompPrefabInfo",
"fileId": "f2LE7uQZZKEq+JHQsvTuG7"
"fileId": "52ZUkZ8ahLDYv00qXLuIBe"
},
{
"__type__": "cc.Widget",
@@ -26843,7 +26843,7 @@
},
{
"__type__": "cc.CompPrefabInfo",
"fileId": "beAmjTm9NHV5Zcm66Lw5TZ"
"fileId": "cdJWrH5SpAdqaCjwZdBY4P"
},
{
"__type__": "cc.PrefabInfo",
@@ -26853,7 +26853,7 @@
"asset": {
"__id__": 0
},
"fileId": "50V4KrAplBdpEu34KxASqU",
"fileId": "3cUPE46lZDFpIoIEa5SKtH",
"instance": null,
"targetOverrides": null,
"nestedPrefabInstanceRoots": null
@@ -26884,7 +26884,7 @@
},
{
"__type__": "cc.CompPrefabInfo",
"fileId": "f3WGDj8lZGL4ph5tNYqAs/"
"fileId": "5fdCvllLREuogKgB0x8O69"
},
{
"__type__": "cc.Button",
@@ -26944,7 +26944,7 @@
},
{
"__type__": "cc.CompPrefabInfo",
"fileId": "48+/XTINJBgbqup+dSL/9D"
"fileId": "a8F6hzq39Dwrxs35dF97yA"
},
{
"__type__": "cc.ClickEvent",
@@ -26954,7 +26954,7 @@
"component": "",
"_componentId": "11498TbVJpO6qmZ8m9k55Zx",
"handler": "btn_func",
"customEventData": "fight"
"customEventData": "heros"
},
{
"__type__": "cc.PrefabInfo",
@@ -26964,7 +26964,7 @@
"asset": {
"__id__": 0
},
"fileId": "9elmcSk75AzaRXoY2+iXEn",
"fileId": "2f00V76bdDG6jYeodHvdkw",
"instance": null,
"targetOverrides": null,
"nestedPrefabInstanceRoots": null
@@ -26985,7 +26985,7 @@
"__id__": 1439
}
],
"_active": true,
"_active": false,
"_components": [
{
"__id__": 1459
@@ -27945,7 +27945,7 @@
"__id__": 1480
}
],
"_active": true,
"_active": false,
"_components": [
{
"__id__": 1500
@@ -28903,7 +28903,7 @@
},
"_contentSize": {
"__type__": "cc.Size",
"width": 738,
"width": 444,
"height": 100
},
"_anchorPoint": {
@@ -28969,8 +28969,8 @@
},
"_alignFlags": 44,
"_target": null,
"_left": -9,
"_right": -9,
"_left": 138,
"_right": 138,
"_top": 1178.6190000000001,
"_bottom": 0,
"_horizontalCenter": 0,

View File

@@ -96,6 +96,7 @@ export class GameDataSyncManager {
}
} catch (error) {
console.error(`[GameDataSyncManager]: 更新出战英雄配置异常:`, error);
smc.error()
return false;
}
}
@@ -122,6 +123,7 @@ export class GameDataSyncManager {
}
} catch (error) {
console.error(`[GameDataSyncManager]: 重置出战英雄配置异常:`, error);
smc.error()
return false;
}
}
@@ -151,6 +153,7 @@ export class GameDataSyncManager {
}
} catch (error) {
console.error(`[GameDataSyncManager]: 添加英雄异常:`, error);
smc.error()
return false;
}
}
@@ -178,6 +181,7 @@ export class GameDataSyncManager {
}
} catch (error) {
console.error(`[GameDataSyncManager]: 更新英雄异常:`, error);
smc.error()
return false;
}
}
@@ -206,6 +210,7 @@ export class GameDataSyncManager {
}
} catch (error) {
console.error(`[GameDataSyncManager]: 设置英雄属性异常:`, error);
smc.error()
return false;
}
}
@@ -216,11 +221,11 @@ export class GameDataSyncManager {
* @param levels 升级级数默认1级
* @returns 是否成功
*/
async levelUpHero(heroId: number, exp:number,gold:number,levels: number = 1,): Promise<boolean> {
async levelUpHero(heroId: number,levels: number = 1,): Promise<boolean> {
try {
console.log(`[GameDataSyncManager]: 英雄升级 ID:${heroId}, 级数:${levels}`);
const result = await WxCloudApi.levelUpHero(heroId, exp,gold,levels);
const result = await WxCloudApi.levelUpHero(heroId,levels);
if (result.result.code === 200) {
// 远程修改成功,同步本地数据
@@ -233,6 +238,7 @@ export class GameDataSyncManager {
}
} catch (error) {
console.error(`[GameDataSyncManager]: 英雄升级异常:`, error);
smc.error()
return false;
}
}
@@ -260,6 +266,7 @@ export class GameDataSyncManager {
}
} catch (error) {
console.error(`[GameDataSyncManager]: 增加道具异常:`, error);
smc.error()
return false;
}
}
@@ -289,6 +296,7 @@ export class GameDataSyncManager {
}
} catch (error) {
console.error(`[GameDataSyncManager]: 消耗道具异常:`, error);
smc.error()
return false;
}
}
@@ -318,6 +326,7 @@ export class GameDataSyncManager {
}
} catch (error) {
console.error(`[GameDataSyncManager]: 增加天赋点异常:`, error);
smc.error()
return false;
}
}
@@ -345,6 +354,7 @@ export class GameDataSyncManager {
}
} catch (error) {
console.error(`[GameDataSyncManager]: 消耗天赋点异常:`, error);
smc.error()
return false;
}
}
@@ -372,6 +382,7 @@ export class GameDataSyncManager {
}
} catch (error) {
console.error(`[GameDataSyncManager]: 增加装备异常:`, error);
smc.error()
return false;
}
}
@@ -399,11 +410,13 @@ export class GameDataSyncManager {
}
} catch (error) {
console.error(`[GameDataSyncManager]: 消耗装备异常:`, error);
smc.error()
return false;
}
}
async addGameProperty(property: string, value: any): Promise<boolean> {
try {
console.log(`[GameDataSyncManager]: 增加游戏数据 ${property} = ${value}`);
@@ -417,11 +430,12 @@ export class GameDataSyncManager {
}
} catch (error) {
console.error(`[GameDataSyncManager]: 增加游戏数据异常:`, error);
smc.error()
return false;
}
}
async spendGameProperty(property: string, value: any): Promise<boolean> {
async spendGameProperty(property: string|Record<string, number>, value: any = undefined ): Promise<boolean> {
try {
console.log(`[GameDataSyncManager]: 消耗游戏数据 ${property} = ${value}`);
const result = await WxCloudApi.spendGameDataField(property, value);
@@ -431,6 +445,7 @@ export class GameDataSyncManager {
}
} catch (error) {
console.error(`[GameDataSyncManager]: 消耗游戏数据异常:`, error);
smc.error()
return false;
}
}
@@ -463,6 +478,7 @@ export class GameDataSyncManager {
}
} catch (error) {
console.error(`[GameDataSyncManager]: 加载云端数据异常:`, error);
smc.error()
return false;
}
}

View File

@@ -9,6 +9,8 @@ import { gameDataSyncManager } from "./GameDataSyncManager";
import { GameSet } from "./config/BoxSet";
import { Test } from "./Test";
import { GameEvent } from "./config/GameEvent";
import { Items } from "./config/Items";
import { HeroInfo } from "./config/heroSet";
// import { Role } from "../role/Role";
@@ -94,6 +96,8 @@ export class SingletonModuleComp extends ecs.Comp {
return typeof wx !== 'undefined' && typeof (wx as any).getSystemInfoSync === 'function';
}
//调试用
syncDataFromLocal(){
if(this.isWxClient()) return
@@ -101,6 +105,18 @@ export class SingletonModuleComp extends ecs.Comp {
this.gameDataSyncManager.overrideLocalDataWithRemote(loginResult, "本地调试");
}
addHero(hero_uuid:number,autoSave:boolean=true){
if(this.isWxClient()){
if(this.gameDataSyncManager.addHero(hero_uuid)){
this.heros[hero_uuid]={ uuid:hero_uuid, lv:1, }
return true
}
return false
}
this.heros[hero_uuid]={ uuid:hero_uuid, lv:1, }
return true
}
setFightHero(position:number,heroId:number,autoSave:boolean=true){
this.fight_heros[position] = heroId;
if(this.isWxClient()){
@@ -121,9 +137,11 @@ export class SingletonModuleComp extends ecs.Comp {
}
return heros_uuid
}
levelUpHero(heroId:number,exp:number,gold:number){
levelUpHero(heroId:number){
if(this.isWxClient()){
let result=this.gameDataSyncManager.levelUpHero(heroId,exp,gold);
let result=this.gameDataSyncManager.levelUpHero(heroId);
if(result){
this.heros[heroId].lv++;
return true
@@ -136,98 +154,112 @@ export class SingletonModuleComp extends ecs.Comp {
}
}
// ==================== 统一的数据操作接口 ====================
/**
* 增加游戏数据属性(统一接口)
* @param property 属性名
* property list:
* ***gold:金币
* ***diamond:钻石
* ***meat:肉
* ***exp:经验
* ***score:分数
* ***mission:关卡
* @param value 增加的值
* @param autoSave 是否自动保存 (默认true)
* @returns 操作结果
*/
error(){
oops.gui.toast("数据处理异常,请重试或重新登录")
}
addExp(exp:number,autoSave:boolean=true){
this.data.exp+=exp
if(this.isWxClient()){
this.gameDataSyncManager.addGameProperty("exp",exp)
if(this.gameDataSyncManager.addGameProperty("exp",exp)){
this.data.exp+=exp
return true
}
return false
}
this.data.exp+=exp
return true
}
addGold(gold:number,autoSave:boolean=true){
if(this.isWxClient()){
if(this.gameDataSyncManager.addGameProperty("gold",gold)){
this.data.gold+=gold
oops.message.dispatchEvent(GameEvent.GOLD_UPDATE)
return true
}
this.error()
return false
}
this.data.gold+=gold
oops.message.dispatchEvent(GameEvent.GOLD_UPDATE)
if(this.isWxClient()){
this.gameDataSyncManager.addGameProperty("gold",gold)
}
return true
}
addDiamond(diamond:number,autoSave:boolean=true){
if(this.isWxClient()){
if(this.gameDataSyncManager.addGameProperty("diamond",diamond)){
this.data.diamond+=diamond
oops.message.dispatchEvent(GameEvent.DIAMOND_UPDATE)
return true
}
return false
}
this.data.diamond+=diamond
oops.message.dispatchEvent(GameEvent.DIAMOND_UPDATE)
if(this.isWxClient()){
this.gameDataSyncManager.addGameProperty("diamond",diamond)
}
return true
}
addMission(mission:number,autoSave:boolean=true){
if(this.isWxClient()){
if(this.gameDataSyncManager.addGameProperty("mission",mission)){
this.data.mission+=mission
oops.message.dispatchEvent(GameEvent.MISSION_UPDATE)
return true
}
return false
}
this.data.mission+=mission
oops.message.dispatchEvent(GameEvent.MISSION_UPDATE)
if(this.isWxClient()){
this.gameDataSyncManager.addGameProperty("mission",mission)
}
return true
}
spendExp(exp:number,autoSave:boolean=true){
this.data.exp-=exp
if(this.isWxClient()){
this.gameDataSyncManager.spendGameProperty("exp",exp)
if(this.gameDataSyncManager.spendGameProperty("exp",exp)){
this.data.exp-=exp
return true
}
return false
}
this.data.exp-=exp
return true
}
spendGold(gold:number,autoSave:boolean=true){
if(this.isWxClient()){
if(this.gameDataSyncManager.spendGameProperty("gold",gold)){
this.data.gold-=gold
oops.message.dispatchEvent(GameEvent.GOLD_UPDATE)
return true
}
return false
}
this.data.gold-=gold
oops.message.dispatchEvent(GameEvent.GOLD_UPDATE)
if(this.isWxClient()){
this.gameDataSyncManager.spendGameProperty("gold",gold)
}
return true
}
spendDiamond(diamond:number,autoSave:boolean=true){
if(this.isWxClient()){
if(this.gameDataSyncManager.spendGameProperty("diamond",diamond)){
this.data.diamond-=diamond
oops.message.dispatchEvent(GameEvent.DIAMOND_UPDATE)
return true
}
return false
}
this.data.diamond-=diamond
oops.message.dispatchEvent(GameEvent.DIAMOND_UPDATE)
if(this.isWxClient()){
this.gameDataSyncManager.spendGameProperty("diamond",diamond)
}
return true
}
/**
* 消耗游戏数据属性(统一接口)
* - 支持单个字段spendGameProperty('gold', 10)
* - 支持多个字段spendGameProperty({ gold: 10, exp: 5 })
* 只有当所有字段都满足扣除条件时,才会一次性扣减
* @param property 属性名或属性映射
* @param value 消耗的值(当 property 为字符串时有效)
* @param autoSave 是否自动保存 (默认true)
* @returns 是否成功消耗
* 处理多个字段spendGameProperty({ gold: 10, exp: 5 })
*/
async spendGameProperty(property: string | Record<string, number>, value: any = undefined, autoSave: boolean = true): Promise<boolean> {
// 单字段扣除
if (typeof property === 'string') {
const currentValue = this.data[property] || 0;
if (currentValue < value) {
console.warn(`[SMC]: ${property} 不足,当前: ${currentValue}, 需要: ${value}`);
return false;
async spendGameProperty(property: Record<string, number>, autoSave: boolean = true): Promise<boolean> {
if(this.isWxClient()){
if(this.gameDataSyncManager.spendGameProperty(property)){
return true
}
const newValue = currentValue - value;
this.data[property] = newValue;
console.log(`[SMC]: 消耗游戏数据 ${property} = ${value}, 当前值: ${newValue}`);
return true;
return false
}
// 多字段扣除(原子性:全部满足才扣)
const deductions = property as Record<string, number>;
// 1) 校验是否全部满足
@@ -237,10 +269,10 @@ export class SingletonModuleComp extends ecs.Comp {
const current = this.data[key] || 0;
if (current < need) {
console.warn(`[SMC]: ${key} 不足,当前: ${current}, 需要: ${need}`);
oops.gui.toast(`${key} 不足,当前: ${current}, 需要: ${need}`)
return false;
}
}
// 2) 统一扣减
for (const key in deductions) {
if (!Object.prototype.hasOwnProperty.call(deductions, key)) continue;
@@ -250,18 +282,32 @@ export class SingletonModuleComp extends ecs.Comp {
this.data[key] = next;
console.log(`[SMC]: 消耗游戏数据 ${key} = ${need}, 当前值: ${next}`);
}
return true;
}
addItem(item_uuid:number,count:number,autoSave:boolean=true){
if(this.isWxClient()){
this.gameDataSyncManager.addItem(item_uuid,count);
}
else{
this.items[item_uuid] = (this.items[item_uuid] || 0) + count;
if(this.gameDataSyncManager.addItem(item_uuid,count)){
this.items[item_uuid] = (this.items[item_uuid] || 0) + count;
return true
}
return false
}
this.items[item_uuid] = (this.items[item_uuid] || 0) + count;
return true
}
spendItem(item_uuid:number,count:number,autoSave:boolean=true){
if(this.isWxClient()){
if(this.gameDataSyncManager.consumeItem(item_uuid,count)){
this.items[item_uuid] = (this.items[item_uuid] || 0) - count;
return true
}
return false
}
this.items[item_uuid] = (this.items[item_uuid] || 0) - count;
return true
}
}

View File

@@ -1,6 +1,7 @@
import { v3 } from "cc"
import { FacSet, QualitySet } from "./BoxSet"
import { smc } from "../SingletonModuleComp"
import { Items } from "./Items"
/**
* kind 1:烈焰 2:寒冰 3:自然 4:暗影 5:神圣
**/
@@ -30,7 +31,19 @@ export enum HType {
remote = 1,
mage = 2,
}
/**
* 解锁英雄所需物品
* 绿色:铜钥匙*100 item:1006 num:100
* 蓝色:银钥匙*200 item:1007 num:200
* 紫色:金钥匙*100 item:1008 num:100
* 橙色:金钥匙*100 item:1009 num:100
*/
export const unlockHeroCost={
[QualitySet.GREEN]:{i_uuid:Items[1006].uuid,num:100},
[QualitySet.BLUE]:{i_uuid:Items[1006].uuid,num:200},
[QualitySet.PURPLE]:{i_uuid:Items[1007].uuid,num:100},
[QualitySet.ORANGE]:{i_uuid:Items[1008].uuid,num:100},
}
//fac:FacSet.HERO
export const getHeroList = (quality:number=0)=>{
const filteredHeros = Object.values(HeroInfo).filter(item=>{

View File

@@ -98,8 +98,16 @@ export class GoodsComp extends Component {
}else if(this.goodsData.c_type==CType.FREE){
this.do_free()
}else if(this.goodsData.c_type==CType.DIAMOND){
if(smc.data.diamond<this.goodsData.cast){
oops.gui.toast("钻石不足")
return
}
this.do_diamond_cast()
}else if(this.goodsData.c_type==CType.GOLD){
if(smc.data.gold<this.goodsData.cast){
oops.gui.toast("金币不足")
return
}
this.do_gold_cast()
}
}

View File

@@ -23,15 +23,18 @@ export class HCardUICom extends Component {
update(deltaTime: number) {
}
to_update_hero(){
this.update_data(this.h_uuid,{type:this.type})
to_update_hero(event:any,args:any){
if(args.uuid==this.h_uuid){
console.log("[HCardUICom]:是我诶:",HeroInfo[args.uuid].name+args.uuid)
this.update_data(args.uuid,{type:this.type})
}
}
update_data(uuid:number,args:any){
this.type=args.type
if(args.slot) this.slot=args.slot
console.log("[HCardUICom]:update_data",uuid,this.type,this.slot,args)
this.h_uuid=uuid
this.node.getChildByName("in_fight").active=this.check_in_fight(uuid)
this.node.getChildByName("in_fight").active=this.check_in_fight()
let hero_data = HeroInfo[uuid]
let hero= this.node.getChildByName("hero")
let anm_path=hero_data.path
@@ -69,7 +72,7 @@ export class HCardUICom extends Component {
break
case HeroConSet.SELECT:
if(oops.gui.has(UIID.HeroSelect)) {
this.check_in_slot(this.h_uuid)
this.check_in_slot()
smc.setFightHero(this.slot,this.h_uuid,true)
oops.message.dispatchEvent(GameEvent.UpdateFightHero)
oops.gui.remove(UIID.HeroSelect)
@@ -77,18 +80,18 @@ export class HCardUICom extends Component {
break
}
}
check_in_slot(uuid:number){ //如果英雄在出战位,则移除久的出战位
check_in_slot(){ //如果英雄在出战位,则移除久的出战位
let heros=smc.fight_heros
for(let i=0;i<GameSet.HERO_NUM;i++){
if(heros[i]==uuid) {
if(heros[i]==this.h_uuid) {
smc.setFightHero(i,0,true)
}
}
}
check_in_fight(uuid:number){
check_in_fight(){
let heros=smc.fight_heros
for(let i=0;i<GameSet.HERO_NUM;i++){
if(heros[i]==uuid) return true
if(heros[i]==this.h_uuid) return true
}
return false
}

View File

@@ -1,10 +1,11 @@
import { _decorator, Animation, AnimationClip, Component, Label, Node, resources } from 'cc';
import { _decorator, Animation, AnimationClip, Component, Label, Node, resources, Sprite, SpriteFrame } from 'cc';
import { oops } from 'db://oops-framework/core/Oops';
import { UIID } from '../common/config/GameUIConfig';
import { getHeroList, getHeroStatsByLevel, getUpgradeResources, HeroInfo, HType } from '../common/config/heroSet';
import { getHeroList, getHeroStatsByLevel, getUpgradeResources, HeroInfo, HType, unlockHeroCost } from '../common/config/heroSet';
import { smc } from '../common/SingletonModuleComp';
import { GameEvent } from '../common/config/GameEvent';
import { NumberFormatter } from '../common/config/BoxSet';
import { Items } from '../common/config/Items';
const { ccclass, property } = _decorator;
@ccclass('HInfoComp')
@@ -22,22 +23,21 @@ export class HInfoComp extends Component {
}
update_data(uuid:number){
console.log("[HInfoComp]:update_data",uuid)
console.log("[HCardUICom]:update_data",uuid)
this.h_uuid=uuid
let hero_data = HeroInfo[uuid]
let hero= this.node.getChildByName("hero")
console.log("[HInfoComp]:update_data",uuid,hero_data,this.node)
let lv=smc.heros[uuid]?.lv??1
let anm_path=hero_data.path
resources.load("game/heros/hero/"+anm_path+"/idle", AnimationClip, (err, clip) => {
hero.getComponent(Animation).addClip(clip);
hero.getComponent(Animation).play("idle");
this.node.getChildByName("hero").getComponent(Animation).addClip(clip);
this.node.getChildByName("hero").getComponent(Animation).play("idle");
});
this.node.getChildByName("name").getComponent(Label).string=hero_data.name
this.node.getChildByName("lv").getChildByName("num").getComponent(Label).string=lv.toString()
this.node.getChildByName("skills").getChildByName("list2").getChildByName("luck").active= lv <5
this.node.getChildByName("skills").getChildByName("list3").getChildByName("luck").active= lv <10
this.node.getChildByName("skills").getChildByName("list4").getChildByName("luck").active= lv <15
this.node.getChildByName("skills").getChildByName("list2").getChildByName("lock").active= lv <5
this.node.getChildByName("skills").getChildByName("list3").getChildByName("lock").active= lv <10
this.node.getChildByName("skills").getChildByName("list4").getChildByName("lock").active= lv <15
let {hp,ap,def}=getHeroStatsByLevel(uuid,lv)
this.node.getChildByName("info").getChildByName("hp").getChildByName("num").getComponent(Label).string=hp.toString()
this.node.getChildByName("info").getChildByName("ap").getChildByName("num").getComponent(Label).string=ap.toString()
@@ -48,7 +48,7 @@ export class HInfoComp extends Component {
this.node.getChildByName("type").getChildByName("w").active=hero_data.type==HType.warrior
this.node.getChildByName("type").getChildByName("r").active=hero_data.type==HType.remote
this.node.getChildByName("type").getChildByName("m").active=hero_data.type==HType.mage
this.show_luck(smc.heros[uuid]?.lv??0)
this.show_lock(smc.heros[uuid]?.lv??0)
}
updata_need(experience:number,gold:number){
let need_node=this.node.getChildByName("upNeed").getChildByName("need")
@@ -57,29 +57,62 @@ export class HInfoComp extends Component {
need_node.getChildByName("exp").getChildByName("has").getComponent(Label).string=NumberFormatter.formatNumber(smc.data.exp)
need_node.getChildByName("gold").getChildByName("has").getComponent(Label).string=NumberFormatter.formatNumber(smc.data.gold)
}
show_luck(lv:number){
show_lock(lv:number){
this.node.getChildByName("upBtn").active=lv > 0
this.node.getChildByName("upNeed").active=lv > 0
this.node.getChildByName("luck").active=lv == 0
this.node.getChildByName("lock").active=lv == 0
this.node.getChildByName("unLock").active=lv == 0
let need_item=unlockHeroCost[HeroInfo[this.h_uuid].quality]
console.log("[HInfoComp]:show_lock item:item_uuid:hero_uuid:hero_data",Items[need_item.i_uuid],need_item.i_uuid,this.h_uuid,HeroInfo[this.h_uuid])
this.node.getChildByName("unLockNeed").getChildByName("need").getChildByName("has").getComponent(Label).string=smc.items[need_item.i_uuid]??0
this.node.getChildByName("unLockNeed").getChildByName("need").getChildByName("need").getComponent(Label).string=NumberFormatter.formatNumber(need_item.num)
let path="gui/items/"+Items[need_item.i_uuid].path
resources.load(path,SpriteFrame, (err, clip) => {
this.node.getChildByName("unLockNeed").getChildByName("need").getChildByName("icon").getComponent(Sprite).spriteFrame=clip
});
this.node.getChildByName("unLockNeed").active=lv == 0
}
uplockhero(){
let need_item=unlockHeroCost[HeroInfo[this.h_uuid].quality]
if(!smc.items[need_item.i_uuid]||smc.items[need_item.i_uuid]<need_item.num){
oops.gui.toast("["+Items[need_item.i_uuid].name+"]数量不足")
return
}
if(!smc.spendItem(need_item.i_uuid,need_item.num)){
smc.error()
return
}
if(!smc.addHero(this.h_uuid)){
smc.addItem(need_item.i_uuid,need_item.num,false)
oops.gui.toast("英雄< "+HeroInfo[this.h_uuid].name+" >解锁失败")
return
}
oops.gui.toast("英雄< "+HeroInfo[this.h_uuid].name+" >解锁成功")
this.update_data(this.h_uuid)
oops.message.dispatchEvent(GameEvent.UpdateHero, {uuid:this.h_uuid})
}
uplevel(){
let lv=smc.heros[this.h_uuid].lv
let {experience,gold}=getUpgradeResources(lv)
if(smc.data.exp<=experience||smc.data.gold<=gold){
if(smc.data.exp<experience||smc.data.gold<gold){
oops.gui.toast("经验或金币不足")
return
}
smc.spendGameProperty({exp:experience,gold:gold},false)
let result=smc.levelUpHero(this.h_uuid,experience,gold)
if(!result){
smc.addExp(experience,false)
smc.addGold(gold,false)
oops.gui.toast("网络出错了,升级失败,请重试")
if(!smc.spendGameProperty({exp:experience,gold:gold},false)){
smc.error()
return
}
if(!smc.levelUpHero(this.h_uuid)){
smc.addExp(experience,false)
smc.addGold(gold,false)
smc.error()
return
}
this.update_data(this.h_uuid)
oops.message.dispatchEvent(GameEvent.UpdateHero, {})
oops.gui.toast(`英雄< ${HeroInfo[this.h_uuid].name} >升级成功`)
oops.message.dispatchEvent(GameEvent.UpdateHero, {uuid:this.h_uuid})
}
next_hero(){
let heros=getHeroList()

View File

@@ -446,3 +446,4 @@ export class GameDataManager {

View File

@@ -224,8 +224,8 @@ export class WxCloudApi{
* @param amount 消耗的数量
* @return Promise<CloudCallFunctionResult<CloudReturnType<{field: string, old_value: number, new_value: number, change: number}>>>
*/
public static async spendGameDataField(field:string, amount: number): Promise<CloudCallFunctionResult<CloudReturnType<{
field: string,
public static async spendGameDataField(field:string|Record<string, number>, amount: number): Promise<CloudCallFunctionResult<CloudReturnType<{
field: string|Record<string, number>,
old_value: number,
new_value: number,
change: number
@@ -529,7 +529,7 @@ export class WxCloudApi{
* @param levels 升级级数默认1级
* @return Promise<CloudCallFunctionResult<CloudReturnType<{hero_id: number, property: string, old_value: number, new_value: number}>>>
*/
public static async levelUpHero(heroId: number, exp:number,gold:number,levels: number = 1): Promise<CloudCallFunctionResult<CloudReturnType<{
public static async levelUpHero(heroId: number,levels: number = 1): Promise<CloudCallFunctionResult<CloudReturnType<{
hero_id: number,
property: string,
old_value: number,
@@ -540,8 +540,6 @@ export class WxCloudApi{
data: {
cmd: "hero_levelup",
hero_id: heroId,
exp: exp,
gold:gold,
levels: levels
}
});

View File

@@ -916,3 +916,4 @@ wx.cloud.callFunction({

View File

@@ -270,3 +270,4 @@ module.exports = {