hero 升级

This commit is contained in:
2025-08-15 16:33:02 +08:00
parent 94231cb3b1
commit 739600de89
9 changed files with 3225 additions and 2159 deletions

View File

@@ -22,32 +22,32 @@
"__id__": 2
},
{
"__id__": 26
"__id__": 40
},
{
"__id__": 32
},
{
"__id__": 38
}
],
"_active": true,
"_components": [
{
"__id__": 46
},
{
"__id__": 48
},
{
"__id__": 50
},
{
"__id__": 52
}
],
"_active": true,
"_components": [
{
"__id__": 60
},
{
"__id__": 62
},
{
"__id__": 64
},
{
"__id__": 66
}
],
"_prefab": {
"__id__": 54
"__id__": 68
},
"_lpos": {
"__type__": "cc.Vec3",
@@ -92,22 +92,28 @@
},
{
"__id__": 11
},
{
"__id__": 19
},
{
"__id__": 25
}
],
"_active": true,
"_components": [
{
"__id__": 19
"__id__": 33
},
{
"__id__": 21
"__id__": 35
},
{
"__id__": 23
"__id__": 37
}
],
"_prefab": {
"__id__": 25
"__id__": 39
},
"_lpos": {
"__type__": "cc.Vec3",
@@ -147,7 +153,7 @@
"__id__": 2
},
"_children": [],
"_active": true,
"_active": false,
"_components": [
{
"__id__": 4
@@ -242,7 +248,7 @@
"a": 255
},
"_spriteFrame": {
"__uuid__": "49c583b3-d566-4c79-9e4c-bd0ca4a4b717@9c802",
"__uuid__": "49c583b3-d566-4c79-9e4c-bd0ca4a4b717@30983",
"__expectedType__": "cc.SpriteFrame"
},
"_type": 1,
@@ -322,7 +328,7 @@
"__id__": 2
},
"_children": [],
"_active": true,
"_active": false,
"_components": [
{
"__id__": 12
@@ -488,6 +494,317 @@
"targetOverrides": null,
"nestedPrefabInstanceRoots": null
},
{
"__type__": "cc.Node",
"_name": "BaseFrame_Basic_Gradient_02",
"_objFlags": 0,
"__editorExtras__": {},
"_parent": {
"__id__": 2
},
"_children": [],
"_active": true,
"_components": [
{
"__id__": 20
},
{
"__id__": 22
}
],
"_prefab": {
"__id__": 24
},
"_lpos": {
"__type__": "cc.Vec3",
"x": 0,
"y": 0,
"z": 0
},
"_lrot": {
"__type__": "cc.Quat",
"x": 0,
"y": 0,
"z": 0,
"w": 1
},
"_lscale": {
"__type__": "cc.Vec3",
"x": 1,
"y": 1,
"z": 1
},
"_mobility": 0,
"_layer": 33554432,
"_euler": {
"__type__": "cc.Vec3",
"x": 0,
"y": 0,
"z": 0
},
"_id": ""
},
{
"__type__": "cc.UITransform",
"_name": "",
"_objFlags": 0,
"__editorExtras__": {},
"node": {
"__id__": 19
},
"_enabled": true,
"__prefab": {
"__id__": 21
},
"_contentSize": {
"__type__": "cc.Size",
"width": 789,
"height": 80
},
"_anchorPoint": {
"__type__": "cc.Vec2",
"x": 0.5,
"y": 0.5
},
"_id": ""
},
{
"__type__": "cc.CompPrefabInfo",
"fileId": "d6IIR00atHFb/F5NJOiN15"
},
{
"__type__": "cc.Sprite",
"_name": "",
"_objFlags": 0,
"__editorExtras__": {},
"node": {
"__id__": 19
},
"_enabled": true,
"__prefab": {
"__id__": 23
},
"_customMaterial": null,
"_srcBlendFactor": 2,
"_dstBlendFactor": 4,
"_color": {
"__type__": "cc.Color",
"r": 247,
"g": 217,
"b": 0,
"a": 92
},
"_spriteFrame": {
"__uuid__": "6cd18ad7-7b15-43fc-b1bc-33a3973a6564@42c3a",
"__expectedType__": "cc.SpriteFrame"
},
"_type": 0,
"_fillType": 0,
"_sizeMode": 0,
"_fillCenter": {
"__type__": "cc.Vec2",
"x": 0,
"y": 0
},
"_fillStart": 0,
"_fillRange": 0,
"_isTrimmedMode": true,
"_useGrayscale": false,
"_atlas": null,
"_id": ""
},
{
"__type__": "cc.CompPrefabInfo",
"fileId": "41Sz/VwRVPP7oGYNFZ5OHh"
},
{
"__type__": "cc.PrefabInfo",
"root": {
"__id__": 1
},
"asset": {
"__id__": 0
},
"fileId": "bb6oN8XR5GkYRN7E6109Y0",
"instance": null,
"targetOverrides": null,
"nestedPrefabInstanceRoots": null
},
{
"__type__": "cc.Node",
"_name": "ToastMessage_01_Line",
"_objFlags": 0,
"__editorExtras__": {},
"_parent": {
"__id__": 2
},
"_children": [],
"_active": true,
"_components": [
{
"__id__": 26
},
{
"__id__": 28
},
{
"__id__": 30
}
],
"_prefab": {
"__id__": 32
},
"_lpos": {
"__type__": "cc.Vec3",
"x": 0,
"y": 3.426000000000002,
"z": 0
},
"_lrot": {
"__type__": "cc.Quat",
"x": 0,
"y": 0,
"z": 0,
"w": 1
},
"_lscale": {
"__type__": "cc.Vec3",
"x": 1,
"y": 1,
"z": 1
},
"_mobility": 0,
"_layer": 33554432,
"_euler": {
"__type__": "cc.Vec3",
"x": 0,
"y": 0,
"z": 0
},
"_id": ""
},
{
"__type__": "cc.UITransform",
"_name": "",
"_objFlags": 0,
"__editorExtras__": {},
"node": {
"__id__": 25
},
"_enabled": true,
"__prefab": {
"__id__": 27
},
"_contentSize": {
"__type__": "cc.Size",
"width": 920,
"height": 80
},
"_anchorPoint": {
"__type__": "cc.Vec2",
"x": 0.5,
"y": 0.5
},
"_id": ""
},
{
"__type__": "cc.CompPrefabInfo",
"fileId": "f8aLap7pFEgZacNbQGlmhT"
},
{
"__type__": "cc.Sprite",
"_name": "",
"_objFlags": 0,
"__editorExtras__": {},
"node": {
"__id__": 25
},
"_enabled": true,
"__prefab": {
"__id__": 29
},
"_customMaterial": null,
"_srcBlendFactor": 2,
"_dstBlendFactor": 4,
"_color": {
"__type__": "cc.Color",
"r": 247,
"g": 217,
"b": 0,
"a": 255
},
"_spriteFrame": {
"__uuid__": "49c583b3-d566-4c79-9e4c-bd0ca4a4b717@fe0e2",
"__expectedType__": "cc.SpriteFrame"
},
"_type": 1,
"_fillType": 0,
"_sizeMode": 0,
"_fillCenter": {
"__type__": "cc.Vec2",
"x": 0,
"y": 0
},
"_fillStart": 0,
"_fillRange": 0,
"_isTrimmedMode": true,
"_useGrayscale": false,
"_atlas": null,
"_id": ""
},
{
"__type__": "cc.CompPrefabInfo",
"fileId": "08nplBo29Ol78Gtxzcu4cd"
},
{
"__type__": "cc.Widget",
"_name": "",
"_objFlags": 0,
"__editorExtras__": {},
"node": {
"__id__": 25
},
"_enabled": true,
"__prefab": {
"__id__": 31
},
"_alignFlags": 45,
"_target": null,
"_left": -110,
"_right": -110,
"_top": 31.573999999999998,
"_bottom": 38.426,
"_horizontalCenter": 0,
"_verticalCenter": 0,
"_isAbsLeft": true,
"_isAbsRight": true,
"_isAbsTop": true,
"_isAbsBottom": true,
"_isAbsHorizontalCenter": true,
"_isAbsVerticalCenter": true,
"_originalWidth": 920,
"_originalHeight": 36,
"_alignMode": 2,
"_lockFlags": 0,
"_id": ""
},
{
"__type__": "cc.CompPrefabInfo",
"fileId": "03FEWX2c1P540WfZNMt86Y"
},
{
"__type__": "cc.PrefabInfo",
"root": {
"__id__": 1
},
"asset": {
"__id__": 0
},
"fileId": "94L0RfIhtJm7Ep+O3LIQCS",
"instance": null,
"targetOverrides": null,
"nestedPrefabInstanceRoots": null
},
{
"__type__": "cc.UITransform",
"_name": "",
@@ -498,7 +815,7 @@
},
"_enabled": true,
"__prefab": {
"__id__": 20
"__id__": 34
},
"_contentSize": {
"__type__": "cc.Size",
@@ -526,7 +843,7 @@
},
"_enabled": true,
"__prefab": {
"__id__": 22
"__id__": 36
},
"_alignFlags": 17,
"_target": null,
@@ -562,7 +879,7 @@
},
"_enabled": true,
"__prefab": {
"__id__": 24
"__id__": 38
},
"_customMaterial": null,
"_srcBlendFactor": 2,
@@ -619,19 +936,19 @@
"_active": true,
"_components": [
{
"__id__": 27
"__id__": 41
},
{
"__id__": 29
"__id__": 43
}
],
"_prefab": {
"__id__": 31
"__id__": 45
},
"_lpos": {
"__type__": "cc.Vec3",
"x": -272.864,
"y": 2.307,
"y": 0,
"z": 0
},
"_lrot": {
@@ -663,16 +980,16 @@
"_objFlags": 0,
"__editorExtras__": {},
"node": {
"__id__": 26
"__id__": 40
},
"_enabled": true,
"__prefab": {
"__id__": 28
"__id__": 42
},
"_contentSize": {
"__type__": "cc.Size",
"width": 90,
"height": 90
"width": 26,
"height": 54
},
"_anchorPoint": {
"__type__": "cc.Vec2",
@@ -691,11 +1008,11 @@
"_objFlags": 0,
"__editorExtras__": {},
"node": {
"__id__": 26
"__id__": 40
},
"_enabled": true,
"__prefab": {
"__id__": 30
"__id__": 44
},
"_customMaterial": null,
"_srcBlendFactor": 2,
@@ -708,7 +1025,7 @@
"a": 255
},
"_spriteFrame": {
"__uuid__": "49c583b3-d566-4c79-9e4c-bd0ca4a4b717@37889",
"__uuid__": "49c583b3-d566-4c79-9e4c-bd0ca4a4b717@f4e17",
"__expectedType__": "cc.SpriteFrame"
},
"_type": 0,
@@ -755,14 +1072,14 @@
"_active": false,
"_components": [
{
"__id__": 33
"__id__": 47
},
{
"__id__": 35
"__id__": 49
}
],
"_prefab": {
"__id__": 37
"__id__": 51
},
"_lpos": {
"__type__": "cc.Vec3",
@@ -799,11 +1116,11 @@
"_objFlags": 0,
"__editorExtras__": {},
"node": {
"__id__": 32
"__id__": 46
},
"_enabled": true,
"__prefab": {
"__id__": 34
"__id__": 48
},
"_contentSize": {
"__type__": "cc.Size",
@@ -827,11 +1144,11 @@
"_objFlags": 0,
"__editorExtras__": {},
"node": {
"__id__": 32
"__id__": 46
},
"_enabled": false,
"__prefab": {
"__id__": 36
"__id__": 50
},
"_customMaterial": null,
"_srcBlendFactor": 2,
@@ -891,17 +1208,17 @@
"_active": true,
"_components": [
{
"__id__": 39
"__id__": 53
},
{
"__id__": 41
"__id__": 55
},
{
"__id__": 43
"__id__": 57
}
],
"_prefab": {
"__id__": 45
"__id__": 59
},
"_lpos": {
"__type__": "cc.Vec3",
@@ -938,11 +1255,11 @@
"_objFlags": 0,
"__editorExtras__": {},
"node": {
"__id__": 38
"__id__": 52
},
"_enabled": true,
"__prefab": {
"__id__": 40
"__id__": 54
},
"_contentSize": {
"__type__": "cc.Size",
@@ -966,11 +1283,11 @@
"_objFlags": 0,
"__editorExtras__": {},
"node": {
"__id__": 38
"__id__": 52
},
"_enabled": true,
"__prefab": {
"__id__": 42
"__id__": 56
},
"_customMaterial": null,
"_srcBlendFactor": 2,
@@ -1034,11 +1351,11 @@
"_objFlags": 0,
"__editorExtras__": {},
"node": {
"__id__": 38
"__id__": 52
},
"_enabled": true,
"__prefab": {
"__id__": 44
"__id__": 58
},
"_params": [],
"_dataID": "",
@@ -1071,7 +1388,7 @@
},
"_enabled": true,
"__prefab": {
"__id__": 47
"__id__": 61
},
"_contentSize": {
"__type__": "cc.Size",
@@ -1099,7 +1416,7 @@
},
"_enabled": true,
"__prefab": {
"__id__": 49
"__id__": 63
},
"_customMaterial": null,
"_srcBlendFactor": 2,
@@ -1141,7 +1458,7 @@
},
"_enabled": true,
"__prefab": {
"__id__": 51
"__id__": 65
},
"playOnLoad": true,
"_clips": [
@@ -1170,13 +1487,13 @@
},
"_enabled": true,
"__prefab": {
"__id__": 53
"__id__": 67
},
"lab_content": {
"__id__": 41
"__id__": 55
},
"animation": {
"__id__": 50
"__id__": 64
},
"_id": ""
},

File diff suppressed because it is too large Load Diff

View File

@@ -14254,7 +14254,7 @@
"_lpos": {
"__type__": "cc.Vec3",
"x": 0,
"y": -83.991,
"y": -90.588,
"z": 0
},
"_lrot": {
@@ -14304,7 +14304,7 @@
"_lpos": {
"__type__": "cc.Vec3",
"x": 0,
"y": 0,
"y": 5.223,
"z": 0
},
"_lrot": {
@@ -14453,8 +14453,8 @@
},
"_contentSize": {
"__type__": "cc.Size",
"width": 54,
"height": 55
"width": 78,
"height": 50
},
"_anchorPoint": {
"__type__": "cc.Vec2",
@@ -14490,12 +14490,12 @@
"a": 255
},
"_spriteFrame": {
"__uuid__": "49c583b3-d566-4c79-9e4c-bd0ca4a4b717@afbdf",
"__uuid__": "49c583b3-d566-4c79-9e4c-bd0ca4a4b717@600b8",
"__expectedType__": "cc.SpriteFrame"
},
"_type": 0,
"_fillType": 0,
"_sizeMode": 1,
"_sizeMode": 0,
"_fillCenter": {
"__type__": "cc.Vec2",
"x": 0,
@@ -16033,7 +16033,7 @@
"_lpos": {
"__type__": "cc.Vec3",
"x": 0,
"y": -83.991,
"y": -90.588,
"z": 0
},
"_lrot": {
@@ -16083,7 +16083,7 @@
"_lpos": {
"__type__": "cc.Vec3",
"x": 0,
"y": 0,
"y": 5.223,
"z": 0
},
"_lrot": {
@@ -16232,8 +16232,8 @@
},
"_contentSize": {
"__type__": "cc.Size",
"width": 54,
"height": 55
"width": 78,
"height": 50
},
"_anchorPoint": {
"__type__": "cc.Vec2",
@@ -16269,12 +16269,12 @@
"a": 255
},
"_spriteFrame": {
"__uuid__": "49c583b3-d566-4c79-9e4c-bd0ca4a4b717@afbdf",
"__uuid__": "49c583b3-d566-4c79-9e4c-bd0ca4a4b717@600b8",
"__expectedType__": "cc.SpriteFrame"
},
"_type": 0,
"_fillType": 0,
"_sizeMode": 1,
"_sizeMode": 0,
"_fillCenter": {
"__type__": "cc.Vec2",
"x": 0,
@@ -17812,7 +17812,7 @@
"_lpos": {
"__type__": "cc.Vec3",
"x": 0,
"y": -83.991,
"y": -90.588,
"z": 0
},
"_lrot": {
@@ -17862,7 +17862,7 @@
"_lpos": {
"__type__": "cc.Vec3",
"x": 0,
"y": 0,
"y": 5.223,
"z": 0
},
"_lrot": {
@@ -18011,8 +18011,8 @@
},
"_contentSize": {
"__type__": "cc.Size",
"width": 54,
"height": 55
"width": 78,
"height": 50
},
"_anchorPoint": {
"__type__": "cc.Vec2",
@@ -18048,12 +18048,12 @@
"a": 255
},
"_spriteFrame": {
"__uuid__": "49c583b3-d566-4c79-9e4c-bd0ca4a4b717@afbdf",
"__uuid__": "49c583b3-d566-4c79-9e4c-bd0ca4a4b717@600b8",
"__expectedType__": "cc.SpriteFrame"
},
"_type": 0,
"_fillType": 0,
"_sizeMode": 1,
"_sizeMode": 0,
"_fillCenter": {
"__type__": "cc.Vec2",
"x": 0,
@@ -20891,7 +20891,7 @@
"__id__": 1589
}
],
"_active": true,
"_active": false,
"_components": [
{
"__id__": 1605
@@ -34675,7 +34675,7 @@
"__id__": 1635
}
],
"_active": true,
"_active": false,
"_components": [
{
"__id__": 1679

View File

@@ -301,10 +301,10 @@
"height": 102,
"rawWidth": 102,
"rawHeight": 102,
"borderTop": 0,
"borderBottom": 0,
"borderLeft": 0,
"borderRight": 0,
"borderTop": 51,
"borderBottom": 51,
"borderLeft": 51,
"borderRight": 51,
"packable": true,
"pixelsToUnit": 100,
"pivotX": 0.5,
@@ -715,10 +715,10 @@
"height": 36,
"rawWidth": 920,
"rawHeight": 36,
"borderTop": 0,
"borderBottom": 0,
"borderLeft": 0,
"borderRight": 0,
"borderTop": 26,
"borderBottom": 10,
"borderLeft": 460,
"borderRight": 460,
"packable": true,
"pixelsToUnit": 100,
"pivotX": 0.5,
@@ -17413,10 +17413,10 @@
"height": 35,
"rawWidth": 920,
"rawHeight": 35,
"borderTop": 0,
"borderBottom": 0,
"borderLeft": 0,
"borderRight": 0,
"borderTop": 25,
"borderBottom": 10,
"borderLeft": 460,
"borderRight": 460,
"packable": true,
"pixelsToUnit": 100,
"pivotX": 0.5,

View File

@@ -28,6 +28,7 @@ export class SingletonModuleComp extends ecs.Comp {
gold:100,
diamond:100,
meat:0,
exp:0,
}
fight_heros:any={
0:5001,
@@ -52,6 +53,7 @@ export class SingletonModuleComp extends ecs.Comp {
game_pause:false,
mission_data:{
gold:1000,//金币
exp:0,//经验
score:0,//分数
diamond:0,//钻石
mission:1,//关卡
@@ -379,12 +381,26 @@ export class SingletonModuleComp extends ecs.Comp {
this.data[property] = value;
this.vmdata.mission_data[property] = value;
console.log(`[SMC]: 设置游戏数据 ${property} = ${value}`);
if (autoSave) {
this.saveGameData();
}
}
addGameProperty(property: string, value: any, autoSave: boolean = true) {
this.data[property] = this.data[property] + value;
this.vmdata.mission_data[property] = this.data[property]
console.log(`[SMC]:增加游戏数据 ${property} = ${value}`);
if (autoSave) {
this.saveGameData();
}
}
spendGameProperty(property: string, value: any, autoSave: boolean = true) {
this.data[property] = this.data[property] - value;
this.vmdata.mission_data[property] = this.data[property]
console.log(`[SMC]: 消耗游戏数据 ${property} = ${value}`);
if (autoSave) {
this.saveGameData();
}
}
/**
* 获取游戏数据属性
* @param property 属性名
@@ -394,25 +410,14 @@ export class SingletonModuleComp extends ecs.Comp {
return this.data[property] !== undefined ? this.data[property] : defaultValue;
}
/**
* 增加金币
* @param amount 金币数量
* @param autoSave 是否自动保存 (默认true)
*/
addGold(amount: number, autoSave: boolean = true) {
const currentGold = this.getGameProperty("gold", 0);
const newGold = Math.max(0, currentGold + amount);
this.setGameProperty("gold", newGold, autoSave);
console.log(`[SMC]: 金币变更: ${currentGold} -> ${newGold} (${amount > 0 ? '+' : ''}${amount})`);
return newGold;
}
syncData(){
this.vmdata.mission_data.gold=this.getGameProperty("gold", 0)
this.vmdata.mission_data.meat=this.getGameProperty("meat", 0)
this.vmdata.mission_data.diamond=this.getGameProperty("diamond", 0)
this.vmdata.mission_data.mission=this.getGameProperty("mission", 1)
this.vmdata.mission_data.score=this.getGameProperty("score", 0)
this.vmdata.mission_data.exp=this.getGameProperty("exp", 0)
// 计算章节和关卡等级
const currentMission = this.getGameProperty("mission", 1)
this.vmdata.mission_data.chapter = Math.floor((currentMission - 1) / 10) + 1
@@ -430,6 +435,19 @@ export class SingletonModuleComp extends ecs.Comp {
this.vmdata.reward.ycard=0
}
/**
* 增加金币
* @param amount 金币数量
* @param autoSave 是否自动保存 (默认true)
*/
addGold(amount: number, autoSave: boolean = true) {
const currentGold = this.getGameProperty("gold", 0);
const newGold = Math.max(0, currentGold + amount);
this.setGameProperty("gold", newGold, autoSave);
console.log(`[SMC]: 金币变更: ${currentGold} -> ${newGold} (${amount > 0 ? '+' : ''}${amount})`);
return newGold;
}
/**
* 消耗金币
* @param amount 消耗数量
* @param autoSave 是否自动保存 (默认true)
@@ -446,12 +464,6 @@ export class SingletonModuleComp extends ecs.Comp {
return true;
}
/**
* 获取金币数量
*/
getGold(): number {
return this.getGameProperty("gold", 0);
}
/**
* 增加钻石
@@ -483,25 +495,6 @@ export class SingletonModuleComp extends ecs.Comp {
return true;
}
/**
* 获取钻石数量
*/
getDiamond(): number {
return this.getGameProperty("diamond", 0);
}
/**
* 设置关卡进度
* @param mission 关卡号
* @param autoSave 是否自动保存 (默认true)
*/
setMission(mission: number, autoSave: boolean = true) {
const currentMission = this.getGameProperty("mission", 1);
if (mission > currentMission) {
this.setGameProperty("mission", mission, autoSave);
console.log(`[SMC]: 关卡进度更新: ${currentMission} -> ${mission}`);
}
}
/**
* 增加关卡进度
@@ -519,12 +512,6 @@ export class SingletonModuleComp extends ecs.Comp {
return newMission;
}
/**
* 获取当前关卡进度
*/
getMission(): number {
return this.getGameProperty("mission", 1);
}
/**
* 增加分数
@@ -539,13 +526,6 @@ export class SingletonModuleComp extends ecs.Comp {
return newScore;
}
/**
* 获取当前分数
*/
getScore(): number {
return this.getGameProperty("score", 0);
}
/**
* 重置游戏数据为默认值
* @param autoSave 是否自动保存 (默认true)

View File

@@ -11,21 +11,21 @@ export enum UIID {
/** 资源加载界面 */
Loading = 1,
/** 弹窗界面 */
Window,
// Window,
/** 加载与延时提示界面 */
Netinstable,
/** 角色控制 */
Role_Controller,
// /** 提示窗 */
// Toast,
HeroInfo,
Shop_page,
Hero_page,
}
/** 打开界面方式的配置数据 */
export var UIConfigData: { [key: number]: UIConfig } = {
[UIID.Loading]: { layer: LayerType.UI, prefab: "loading/prefab/loading", bundle: "resources" },
[UIID.Netinstable]: { layer: LayerType.PopUp, prefab: "common/prefab/netinstable" },
[UIID.Window]: { layer: LayerType.Dialog, prefab: "common/prefab/window" },
// [UIID.Window]: { layer: LayerType.Dialog, prefab: "common/prefab/window" },
[UIID.Role_Controller]: { layer: LayerType.UI, prefab: "gui/role_controller" },
[UIID.HeroInfo]: { layer: LayerType.UI, prefab: "gui/Hinfo" },
// [UIID.Toast]: { layer: LayerType.PopUp, prefab: "common/prefab/toast" },

View File

@@ -359,3 +359,76 @@ export const getMultipleHeroStatsByLevel = (
// 升级资源配置
export const UpgradeResourceConfig = {
// 经验值配置
experience: {
base: 100, // 初始值1级升2级所需经验
growth: 1.5, // 增长值:每级增长倍数
bonus: 0.2 // 增长值提升比例5级倍数提升20%
},
// 金币配置
gold: {
base: 50, // 初始值1级升2级所需金币
growth: 1.3, // 增长值:每级增长倍数
bonus: 0.15 // 增长值提升比例5级倍数提升15%
}
};
/**
* 获取指定等级升级所需的经验值
* @param level 当前等级
* @returns 升级所需经验值
*/
export const getUpgradeExperience = (level: number): number => {
if (level <= 0) return 0;
const config = UpgradeResourceConfig.experience;
let result = config.base * Math.pow(config.growth, level - 1);
// 5级倍数提升
if (level % 5 === 0) {
result = result * (1 + config.bonus);
}
return Math.floor(result);
};
/**
* 获取指定等级升级所需的金币
* @param level 当前等级
* @returns 升级所需金币
*/
export const getUpgradeGold = (level: number): number => {
if (level <= 0) return 0;
const config = UpgradeResourceConfig.gold;
let result = config.base * Math.pow(config.growth, level - 1);
// 5级倍数提升
if (level % 5 === 0) {
result = result * (1 + config.bonus);
}
return Math.floor(result);
};
/**
* 获取指定等级升级所需的所有资源
* @param level 当前等级
* @returns 升级资源信息 {experience, gold}
*/
export const getUpgradeResources = (level: number) => {
return {
experience: getUpgradeExperience(level),
gold: getUpgradeGold(level)
};
};

View File

@@ -1,8 +1,9 @@
import { _decorator, Animation, AnimationClip, Component, Label, Node, resources } from 'cc';
import { oops } from 'db://oops-framework/core/Oops';
import { UIID } from '../common/config/GameUIConfig';
import { getHeroStatsByLevel, HeroInfo } from '../common/config/heroSet';
import { getHeroStatsByLevel, getUpgradeResources, HeroInfo, HType } from '../common/config/heroSet';
import { smc } from '../common/SingletonModuleComp';
import { GameEvent } from '../common/config/GameEvent';
const { ccclass, property } = _decorator;
@ccclass('HInfoComp')
@@ -25,17 +26,58 @@ export class HInfoComp extends Component {
this.h_uuid=uuid
let hero_data = HeroInfo[uuid]
let hero= this.node.getChildByName("hero")
let lv=smc.heros[uuid].lv
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("name").getComponent(Label).string=hero_data.name
this.node.getChildByName("lv").getChildByName("num").getComponent(Label).string=smc.heros[uuid].lv.toString()
let {hp,ap,def}=getHeroStatsByLevel(uuid,smc.heros[uuid].lv)
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
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()
this.node.getChildByName("info").getChildByName("def").getChildByName("num").getComponent(Label).string=def.toString()
let {experience,gold}=getUpgradeResources(lv)
let need_node=this.node.getChildByName("upNeed").getChildByName("need")
need_node.getChildByName("exp").getChildByName("need").getComponent(Label).string=experience.toString()
need_node.getChildByName("gold").getChildByName("need").getComponent(Label).string=gold.toString()
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
}
uplevel(){
let hero_data = HeroInfo[this.h_uuid]
let lv=smc.heros[this.h_uuid].lv
let {experience,gold}=getUpgradeResources(lv)
if(smc.vmdata.mission_data.exp<=experience||smc.vmdata.mission_data.gold<=gold){
oops.gui.toast("经验或金币不足")
return
}
smc.spendGameProperty("exp",experience)
smc.spendGameProperty("gold",gold)
smc.levelUpHero(this.h_uuid)
this.update_data(this.h_uuid)
oops.message.dispatchEvent(GameEvent.UpdateHero, {})
}
next_hero(){
let heros=smc.getHasHeroUUID()
let index = heros.indexOf(this.h_uuid);
index++
if(index==heros.length) index=0
let nextHero = heros[index];
this.update_data(nextHero)
}
prev_hero(){
let heros=smc.getHasHeroUUID()
let index = heros.indexOf(this.h_uuid);
index--
if(index==-1) index=heros.length-1
let prevHero = heros[index];
this.update_data(prevHero)
}
close(){
oops.gui.removeByNode(this.node)

View File

@@ -40,44 +40,46 @@ export class MissionHomeComp extends CCComp {
}
btn_func(e:string,data:any){
// console.log("[MissionHomeComp]:btn_func",e,data)
let page_heros=this.node.getChildByName("heros_page")
let page_shop=this.node.getChildByName("shop_page")
// let page_fight=this.node.getChildByName("fight_page")
// let page_skill=this.node.getChildByName("skill_page")
// let page_set=this.node.getChildByName("set_page")
let btns=this.node.getChildByName("btns")
let shop =btns.getChildByName("shop")
let heros =btns.getChildByName("heros")
let heros_page=this.node.getChildByName("heros").getComponent(HeroPageComp)!
let fight =btns.getChildByName("fight")
let skill =btns.getChildByName("skill")
let set =btns.getChildByName("set")
shop.getChildByName("act").active=false
heros.getChildByName("act").active=false
fight.getChildByName("act").active=false
skill.getChildByName("act").active=false
set.getChildByName("act").active=false
this.node.getChildByName("shop").active=false
this.node.getChildByName("heros").active=false
// this.node.getChildByName("fight").active=false
// this.node.getChildByName("skill").active=false
// this.node.getChildByName("set").active=false
let btn_shop =btns.getChildByName("shop")
let btn_heros =btns.getChildByName("heros")
let btn_fight =btns.getChildByName("fight")
let btn_skill =btns.getChildByName("skill")
let btn_set =btns.getChildByName("set")
btn_shop.getChildByName("act").active=false
btn_heros.getChildByName("act").active=false
btn_fight.getChildByName("act").active=false
btn_skill.getChildByName("act").active=false
btn_set.getChildByName("act").active=false
page_heros.active=false
page_shop.active=false
switch(data){
case "shop":
this.node.getChildByName("shop").active=true
shop.getChildByName("act").active=true
page_shop.active=true
btn_shop.getChildByName("act").active=true
break
case "heros":
this.node.getChildByName("heros").active=true
heros_page.update_heros()
heros.getChildByName("act").active=true
page_heros.active=true
let page_heros_com=page_heros.getComponent(HeroPageComp)!
page_heros_com.update_heros()
btn_heros.getChildByName("act").active=true
break
case "fight":
fight.getChildByName("act").active=true
btn_fight.getChildByName("act").active=true
break
case "skill":
skill.getChildByName("act").active=true
btn_skill.getChildByName("act").active=true
break
case "set":
set.getChildByName("act").active=true
btn_set.getChildByName("act").active=true
break
default:
fight.getChildByName("act").active=true
btn_fight.getChildByName("act").active=true
break
}
}