From 82127a81ba4217b8404fd585e3b9e709c1fb01a7 Mon Sep 17 00:00:00 2001 From: panw Date: Wed, 16 Jul 2025 10:38:47 +0800 Subject: [PATCH] =?UTF-8?q?=E5=BC=BA=E5=8C=96=E9=80=89=E9=A1=B9=20?= =?UTF-8?q?=E5=AE=8C=E6=88=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../script/game/common/SingletonModuleComp.ts | 1 + assets/script/game/common/config/LevelUp.ts | 292 +++++++++--------- ...lUpEnhancement.ts.meta => LevelUp.ts.meta} | 2 +- .../config/LevelUpEnhancementExample.ts.meta | 9 - .../config/README_LevelUpEnhancement.md.meta | 11 - assets/script/game/hero/HeroViewComp.ts | 33 +- assets/script/game/map/CardComp.ts | 15 + assets/script/game/map/CardsComp.ts | 13 +- assets/script/game/map/MissionComp.ts | 4 +- 9 files changed, 204 insertions(+), 176 deletions(-) rename assets/script/game/common/config/{LevelUpEnhancement.ts.meta => LevelUp.ts.meta} (70%) delete mode 100644 assets/script/game/common/config/LevelUpEnhancementExample.ts.meta delete mode 100644 assets/script/game/common/config/README_LevelUpEnhancement.md.meta diff --git a/assets/script/game/common/SingletonModuleComp.ts b/assets/script/game/common/SingletonModuleComp.ts index a1e57865..170d4620 100644 --- a/assets/script/game/common/SingletonModuleComp.ts +++ b/assets/script/game/common/SingletonModuleComp.ts @@ -33,6 +33,7 @@ export class SingletonModuleComp extends ecs.Comp { hero_back_x:number = 0; mon_front_x:number = 0; mon_back_x:number = 0; + enhancements:any=[] vmdata: any = { game_over:false, game_pause:false, diff --git a/assets/script/game/common/config/LevelUp.ts b/assets/script/game/common/config/LevelUp.ts index 9cf14a12..e1c321db 100644 --- a/assets/script/game/common/config/LevelUp.ts +++ b/assets/script/game/common/config/LevelUp.ts @@ -11,7 +11,7 @@ export const EnhancementType = { ATTACK: 1, // 攻击力强化 HEALTH: 2, // 生命值强化 ATTACK_SPEED: 3, // 攻击速度强化 - SPECIAL: 4, // 特殊效果强化 + DEF: 4, // 特殊效果强化 } // 玩家强化等级追踪 @@ -19,7 +19,7 @@ export interface PlayerEnhancementProgress { [EnhancementType.ATTACK]: number; [EnhancementType.HEALTH]: number; [EnhancementType.ATTACK_SPEED]: number; - [EnhancementType.SPECIAL]: number; + [EnhancementType.DEF]: number; } // 默认强化进度(所有强化都从0级开始) @@ -27,152 +27,121 @@ export const defaultEnhancementProgress: PlayerEnhancementProgress = { [EnhancementType.ATTACK]: 0, [EnhancementType.HEALTH]: 0, [EnhancementType.ATTACK_SPEED]: 0, - [EnhancementType.SPECIAL]: 0, + [EnhancementType.DEF]: 0, }; - -// 强化选项配置表(按等级分类) -export const EnhancementOptions = { - // 攻击力强化选项 - [EnhancementType.ATTACK]: { - 1: { - name: "力量训练 I", - description: "攻击力 +5", - buffType: BuffAttr.ATK, - value: 5, - icon: "attack_1", - rarity: "common" - }, - 2: { - name: "力量训练 II", - description: "攻击力 +12", - buffType: BuffAttr.ATK, - value: 12, - icon: "attack_2", - rarity: "uncommon" - }, - 3: { - name: "力量训练 III", - description: "攻击力 +20", - buffType: BuffAttr.ATK, - value: 20, - icon: "attack_3", - rarity: "rare" - }, - 4: { - name: "力量训练 IV", - description: "攻击力 +35", - buffType: BuffAttr.ATK, - value: 35, - icon: "attack_4", - rarity: "epic" - }, - 5: { - name: "力量训练 V", - description: "攻击力 +50", - buffType: BuffAttr.ATK, - value: 50, - icon: "attack_5", - rarity: "legendary" - } - }, - - // 生命值强化选项 - [EnhancementType.HEALTH]: { - 1: { - name: "体质增强 I", - description: "生命值 +10", - buffType: BuffAttr.HP, - value: 10, - icon: "health_1", - rarity: "common" - }, - 2: { - name: "体质增强 II", - description: "生命值 +25", - buffType: BuffAttr.HP, - value: 25, - icon: "health_2", - rarity: "uncommon" - }, - 3: { - name: "体质增强 III", - description: "生命值 +40", - buffType: BuffAttr.HP, - value: 40, - icon: "health_3", - rarity: "rare" - }, - 4: { - name: "体质增强 IV", - description: "生命值 +65", - buffType: BuffAttr.HP, - value: 65, - icon: "health_4", - rarity: "epic" - }, - 5: { - name: "体质增强 V", - description: "生命值 +100", - buffType: BuffAttr.HP, - value: 100, - icon: "health_5", - rarity: "legendary" - } - }, - - // 攻击速度强化选项 - [EnhancementType.ATTACK_SPEED]: { - 1: { - name: "快速出手 I", - description: "攻击速度 +8%", - buffType: BuffAttr.ATK_CD, - value: -8, // 负值表示减少CD,即提升攻击速度 - icon: "speed_1", - rarity: "common" - }, - 2: { - name: "快速出手 II", - description: "攻击速度 +15%", - buffType: BuffAttr.ATK_CD, - value: -15, - icon: "speed_2", - rarity: "uncommon" - }, - 3: { - name: "快速出手 III", - description: "攻击速度 +25%", - buffType: BuffAttr.ATK_CD, - value: -25, - icon: "speed_3", - rarity: "rare" - }, - 4: { - name: "快速出手 IV", - description: "攻击速度 +40%", - buffType: BuffAttr.ATK_CD, - value: -40, - icon: "speed_4", - rarity: "epic" - }, - 5: { - name: "快速出手 V", - description: "攻击速度 +60%", - buffType: BuffAttr.ATK_CD, - value: -60, - icon: "speed_5", - rarity: "legendary" - } - }, +export const defaultEnhancements=()=>{ + return defaultEnhancementProgress } +// 强化选项配置表(二维数组格式) +export const EnhancementOptions: EnhancementOption[][] = [ + // 攻击力强化选项 (EnhancementType.ATTACK = 1) + [ + { + uuid: 1001, type: EnhancementType.ATTACK,lv: 1,name: "力量训练 I",description: "攻击力 +5", + buffType: BuffAttr.ATK,value: 5,icon: "3058",rarity: Quality.GREEN + }, + { + uuid: 1002, type: EnhancementType.ATTACK,lv: 2,name: "力量训练 II", description: "攻击力 +12", + buffType: BuffAttr.ATK,value: 12,icon: "3058",rarity: Quality.GREEN + }, + { + uuid: 1003, type: EnhancementType.ATTACK,lv: 3,name: "力量训练 III",description: "攻击力 +20", + buffType: BuffAttr.ATK,value: 20,icon: "3058",rarity: Quality.BLUE + }, + { + uuid: 1004, type: EnhancementType.ATTACK,lv: 4,name: "力量训练 IV",description: "攻击力 +35", + buffType: BuffAttr.ATK,value: 35,icon: "3058",rarity: Quality.BLUE + }, + { + uuid: 1005, type: EnhancementType.ATTACK,lv: 5,name: "力量训练 V",description: "攻击力 +50", + buffType: BuffAttr.ATK,value: 50,icon: "3058",rarity: Quality.PURPLE + } + ], + + // 生命值强化选项 (EnhancementType.HEALTH = 2) + [ + { + uuid: 2001, type: EnhancementType.HEALTH,lv: 1,name: "体质增强 I",description: "生命值 +10", + buffType: BuffAttr.HP,value: 10,icon: "3058",rarity: Quality.GREEN + }, + { + uuid: 2002, type: EnhancementType.HEALTH,lv: 2,name: "体质增强 II",description: "生命值 +25", + buffType: BuffAttr.HP,value: 25,icon: "3058",rarity: Quality.GREEN + }, + { + uuid: 2003, type: EnhancementType.HEALTH,lv: 3,name: "体质增强 III",description: "生命值 +40", + buffType: BuffAttr.HP,value: 40,icon: "3058",rarity: Quality.BLUE + }, + { + uuid: 2004, type: EnhancementType.HEALTH,lv: 4,name: "体质增强 IV",description: "生命值 +65", + buffType: BuffAttr.HP,value: 65,icon: "3058",rarity: Quality.BLUE + }, + { + uuid: 2005, type: EnhancementType.HEALTH,lv: 5,name: "体质增强 V",description: "生命值 +100", + buffType: BuffAttr.HP,value: 100,icon: "3058",rarity: Quality.PURPLE + } + ], + + // 攻击速度强化选项 (EnhancementType.ATTACK_SPEED = 3) + [ + { + uuid: 3001, type: EnhancementType.ATTACK_SPEED,lv: 1,name: "快速出手 I",description: "攻击速度 +1%", + buffType: BuffAttr.ATK_CD,value: 1,icon: "3058",rarity: Quality.GREEN + }, + { + uuid: 3002, type: EnhancementType.ATTACK_SPEED,lv: 2,name: "快速出手 II",description: "攻击速度 +2%", + buffType: BuffAttr.ATK_CD,value: 2,icon: "3058",rarity: Quality.GREEN + }, + { + uuid: 3003, type: EnhancementType.ATTACK_SPEED,lv: 3,name: "快速出手 III",description: "攻击速度 +3%", + buffType: BuffAttr.ATK_CD,value: 3,icon: "3058",rarity: Quality.BLUE + }, + { + uuid: 3004, type: EnhancementType.ATTACK_SPEED,lv: 4,name: "快速出手 IV",description: "攻击速度 +4%", + buffType: BuffAttr.ATK_CD,value: 4,icon: "3058",rarity: Quality.BLUE + }, + { + uuid: 3005, type: EnhancementType.ATTACK_SPEED,lv: 5,name: "快速出手 V",description: "攻击速度 +5%", + buffType: BuffAttr.ATK_CD,value: 5,icon: "3058",rarity: Quality.PURPLE + } + ], + + // 特殊效果强化选项 (EnhancementType.SPECIAL = 4) + [ + { + uuid: 4001, type: EnhancementType.DEF,lv: 1,name: "幸运强化 I",description: "暴击率 +1%", + buffType: BuffAttr.DEF,value: 1,icon: "3058",rarity: Quality.GREEN + }, + { + uuid: 4002, type: EnhancementType.DEF,lv: 2,name: "幸运强化 II",description: "暴击率 +2%", + buffType: BuffAttr.DEF,value: 2,icon: "3058",rarity: Quality.GREEN + }, + { + uuid: 4003, type: EnhancementType.DEF,lv: 3,name: "幸运强化 III",description: "暴击率 +3%", + buffType: BuffAttr.DEF,value: 3,icon: "3058",rarity: Quality.BLUE + }, + { + uuid: 4004, type: EnhancementType.DEF,lv: 4,name: "幸运强化 IV",description: "暴击率 +4%", + buffType: BuffAttr.DEF,value: 4,icon: "3058",rarity: Quality.BLUE + }, + { + uuid: 4005, type: EnhancementType.DEF,lv: 5,name: "幸运强化 V",description: "暴击率 +5%", + buffType: BuffAttr.DEF,value: 5,icon: "3058",rarity: Quality.PURPLE + } + ] +]; // 强化选项接口定义 export interface EnhancementOption { - name: string; - description: string; - buffType: number; - value: number; - icon: string; - rarity: string; + uuid: number; // 强化选项唯一ID + type: number; // 强化类型 (EnhancementType) + lv: number; // 强化等级 + name: string; // 强化名称 + description: string; // 强化描述 + buffType: number; // 属性类型 (BuffAttr) + value: number; // 属性值 + icon: string; // 图标ID + rarity: number; // 稀有度 (Quality) } // 获取随机强化选项(基于玩家当前强化进度) @@ -200,7 +169,7 @@ export function getEnhancement(playerProgress: PlayerEnhancementProgress, count: const currentLevel = playerProgress[type] || 0; const nextLevel = Math.min(currentLevel + 1, 5); // 最大等级为5 - const option = EnhancementOptions[type]?.[nextLevel]; + const option = EnhancementOptions[type - 1]?.[nextLevel - 1]; // 数组索引从0开始 if (option) { options.push(option); } @@ -211,7 +180,7 @@ export function getEnhancement(playerProgress: PlayerEnhancementProgress, count: // 获取指定类型和等级的强化选项 export function getEnhancementOptionByTypeAndLevel(type: number, level: number): EnhancementOption | null { - return EnhancementOptions[type]?.[level] || null; + return EnhancementOptions[type - 1]?.[level - 1] || null; // 数组索引从0开始 } // 获取所有可用的强化类型 @@ -224,7 +193,7 @@ export function getEnhancementOptionsByLevel(level: number): EnhancementOption[] const options: EnhancementOption[] = []; for (const type of Object.values(EnhancementType)) { - const option = EnhancementOptions[type]?.[level]; + const option = EnhancementOptions[type - 1]?.[level - 1]; // 数组索引从0开始 if (option) { options.push(option); } @@ -303,4 +272,35 @@ export function getEnhancementLevel(progress: PlayerEnhancementProgress, type: n // 获取玩家所有强化的总等级 export function getTotalEnhancementLevel(progress: PlayerEnhancementProgress): number { return Object.values(progress).reduce((total, level) => total + level, 0); +} + +// 通过UUID获取强化选项 +export function getEnhancementOptionByUuid(uuid: number): EnhancementOption | null { + for (const typeArray of EnhancementOptions) { + for (const option of typeArray) { + if (option.uuid === uuid) { + return option; + } + } + } + return null; +} + +// 获取指定类型的所有强化选项 +export function getEnhancementOptionsByType(type: number): EnhancementOption[] { + const typeIndex = type - 1; // 转换为数组索引 + return EnhancementOptions[typeIndex] || []; +} + +// 获取指定UUID范围的强化选项 +export function getEnhancementOptionsByUuidRange(startUuid: number, endUuid: number): EnhancementOption[] { + const options: EnhancementOption[] = []; + for (const typeArray of EnhancementOptions) { + for (const option of typeArray) { + if (option.uuid >= startUuid && option.uuid <= endUuid) { + options.push(option); + } + } + } + return options; } \ No newline at end of file diff --git a/assets/script/game/common/config/LevelUpEnhancement.ts.meta b/assets/script/game/common/config/LevelUp.ts.meta similarity index 70% rename from assets/script/game/common/config/LevelUpEnhancement.ts.meta rename to assets/script/game/common/config/LevelUp.ts.meta index ccc818f9..53f3ed59 100644 --- a/assets/script/game/common/config/LevelUpEnhancement.ts.meta +++ b/assets/script/game/common/config/LevelUp.ts.meta @@ -2,7 +2,7 @@ "ver": "4.0.23", "importer": "typescript", "imported": true, - "uuid": "b7e16305-7610-4d81-a60b-040fbbce4b72", + "uuid": "bbef9ac6-154b-4e27-9c56-e964e27ef2d5", "files": [], "subMetas": {}, "userData": {} diff --git a/assets/script/game/common/config/LevelUpEnhancementExample.ts.meta b/assets/script/game/common/config/LevelUpEnhancementExample.ts.meta deleted file mode 100644 index 13266001..00000000 --- a/assets/script/game/common/config/LevelUpEnhancementExample.ts.meta +++ /dev/null @@ -1,9 +0,0 @@ -{ - "ver": "4.0.23", - "importer": "typescript", - "imported": true, - "uuid": "4493de4e-44b0-45a1-9d0b-3043d50cc417", - "files": [], - "subMetas": {}, - "userData": {} -} diff --git a/assets/script/game/common/config/README_LevelUpEnhancement.md.meta b/assets/script/game/common/config/README_LevelUpEnhancement.md.meta deleted file mode 100644 index 592ed70f..00000000 --- a/assets/script/game/common/config/README_LevelUpEnhancement.md.meta +++ /dev/null @@ -1,11 +0,0 @@ -{ - "ver": "1.0.2", - "importer": "text", - "imported": true, - "uuid": "65b38842-3a45-44b0-b756-068a4d799715", - "files": [ - ".json" - ], - "subMetas": {}, - "userData": {} -} diff --git a/assets/script/game/hero/HeroViewComp.ts b/assets/script/game/hero/HeroViewComp.ts index 20a00d45..47662f17 100644 --- a/assets/script/game/hero/HeroViewComp.ts +++ b/assets/script/game/hero/HeroViewComp.ts @@ -16,6 +16,7 @@ import { getApIncrease, getHpIncrease, getUpExp, HeroInfo, HeroPos } from "../co import { FriendModelComp } from "./FriendModel"; import { MasterModelComp } from "./MasterModel"; import { RandomManager } from "db://oops-framework/core/common/random/RandomManager"; +import { EnhancementType } from "../common/config/LevelUp"; const { ccclass, property } = _decorator; @@ -159,6 +160,22 @@ export class HeroViewComp extends CCComp { } use_enhancement(e:GameEvent,data:any){ console.log("[HeroViewComp]:use_enhancement",data) + if(this.is_master){ + switch(data.type){ + case EnhancementType.ATTACK: + this.add_ap(data.value) + break + case EnhancementType.ATTACK_SPEED: + this.add_speed(data.value) + break + case EnhancementType.HEALTH: + this.add_hp_max(data.value) + break + case EnhancementType.DEF: + this.add_def(data.value) + break + } + } } change_atk(e:GameEvent,data:any){ @@ -202,6 +219,16 @@ export class HeroViewComp extends CCComp { * 增加英雄的攻击(AP)。 * @param ap 要增加的攻击。 */ + add_def(def: number){ + this.def+=def + this.BUFFCOMP.vmdata_update() + // this.BUFFCOMP.tooltip(TooltipTypes.defup,def.toFixed(0)); + } + add_speed(cd: number){ + this.cd -=this.cd*cd/100 + this.BUFFCOMP.vmdata_update() + // this.BUFFCOMP.tooltip(TooltipTypes.speedup,speed.toFixed(0)); + } add_ap(ap: number,is_num:boolean=true){ console.log("[HeroViewComp]:add_ap add:",ap,this.ap) if(is_num){ @@ -619,8 +646,10 @@ export class HeroViewComp extends CCComp { this.next_exp=getUpExp(this.lv) let diff=this.exp-this.next_exp if(diff >= 0){ - this.exp=diff - this.to_update() + this.exp=diff + console.log("[HeroViewComp]:exp_up",this.exp,this.next_exp) + oops.message.dispatchEvent(GameEvent.EnhancementSelect) + this.to_update() } this.BUFFCOMP.vmdata_update(true) //简易更新vmdata } diff --git a/assets/script/game/map/CardComp.ts b/assets/script/game/map/CardComp.ts index bb41ba1d..6704a63c 100644 --- a/assets/script/game/map/CardComp.ts +++ b/assets/script/game/map/CardComp.ts @@ -96,6 +96,10 @@ export class CardComp extends CCComp { this.node.getChildByName("show").active=false this.node.getChildByName("anim").getChildByName("up").getComponent(Animation).play('carsup') this.show_enhancement(args) + this.scheduleOnce(() => { + this.node.getChildByName("show").active=true + this.node.getChildByName("Button").active=true + }, 0.1); } random_select(){ @@ -176,6 +180,12 @@ export class CardComp extends CCComp { let show=this.node.getChildByName("show") show.getChildByName("name").getChildByName("name").getComponent(Label).string=data.name this.do_card_bg_show(data.rarity) + var icon_path = "game/heros/cards" + resources.load(icon_path, SpriteAtlas, (err: any, atlas) => { + const sprite = show.getChildByName("mask").getChildByName("func").getComponent(Sprite); + sprite.spriteFrame = atlas.getSpriteFrame(data.icon); + }); + show.getChildByName("info").getComponent(Label).string=data.description } do_card_bg_show(q:number=Quality.WHITE){ @@ -316,6 +326,11 @@ export class CardComp extends CCComp { case cardType.ENHANCEMENT: console.log("[cardcomp]:use_card 强化卡") oops.message.dispatchEvent(GameEvent.UseEnhancement,this.enhancement_data) + if(this.enhancement_data.lv >=5){ + smc.enhancements[this.enhancement_data.type]=this.enhancement_data.lv + }else{ + smc.enhancements[this.enhancement_data.type]=this.enhancement_data.lv+1 + } oops.message.dispatchEvent(GameEvent.CardsClose) break } diff --git a/assets/script/game/map/CardsComp.ts b/assets/script/game/map/CardsComp.ts index 9e9dbde3..933280cc 100644 --- a/assets/script/game/map/CardsComp.ts +++ b/assets/script/game/map/CardsComp.ts @@ -46,6 +46,7 @@ export class CardsCompComp extends CCComp { this.on(GameEvent.HeroSkillSelectEnd, this.close_cards, this); this.on(GameEvent.CardsClose, this.close_cards, this); this.on(GameEvent.EquipSelect, this.addToQueue, this); + this.on(GameEvent.EnhancementSelect, this.addToQueue, this); this.card1=this.node.getChildByName("cards").getChildByName("card1") this.card2=this.node.getChildByName("cards").getChildByName("card2") this.card3=this.node.getChildByName("cards").getChildByName("card3") @@ -89,19 +90,19 @@ export class CardsCompComp extends CCComp { console.log("[CardsComp]:显示强化选择卡牌") this.node.getChildByName("btns").getChildByName("cancel").active=true this.node.getChildByName("top").getChildByName("title").getChildByName("Label").getComponent(Label).string="选择强化" - this.enhancement_select(data) + this.enhancement_select() break } if(!is_refresh) this.show() } - enhancement_select(data:any){ - let list=getEnhancement([0,0,0,0],3) + enhancement_select(){ + let list=getEnhancement(smc.enhancements,3) console.log("[CardsComp]:强化选择卡牌列表",list) - this.card1c.enhancement_select(data[0]) - this.card2c.enhancement_select(data[1]) - this.card3c.enhancement_select(data[2]) + this.card1c.enhancement_select(list[0]) + this.card2c.enhancement_select(list[1]) + this.card3c.enhancement_select(list[2]) } hero_select(data:any){ let list=[] diff --git a/assets/script/game/map/MissionComp.ts b/assets/script/game/map/MissionComp.ts index cc460353..ed0dc267 100644 --- a/assets/script/game/map/MissionComp.ts +++ b/assets/script/game/map/MissionComp.ts @@ -8,6 +8,7 @@ import { Timer } from "../../../../extensions/oops-plugin-framework/assets/core/ import { GameEvent } from "../common/config/GameEvent"; import { HeroViewComp } from "../hero/HeroViewComp"; import { Hero } from "../hero/Hero"; +import { defaultEnhancements, EnhancementOptions } from "../common/config/LevelUp"; const { ccclass, property } = _decorator; @@ -24,6 +25,7 @@ export class MissionComp extends CCComp { waveTimer:Timer = new Timer(10); normal_max_wave:number = 10; is_fight:boolean = false; + enhancements:any=[0,0,0,0,0] onLoad(){ this.on(GameEvent.MissionStart,this.mission_start,this) this.on(GameEvent.FightEnd,this.fight_end,this) @@ -105,7 +107,7 @@ export class MissionComp extends CCComp { smc.vmdata.hero = JSON.parse(JSON.stringify(VmInfo)); smc.vmdata.boss = JSON.parse(JSON.stringify(VmInfo)); this.GlodAddTimer=new Timer(smc.vmdata.mission_data.refrsh_time) - + smc.enhancements=defaultEnhancements() }