强化选项 完成

This commit is contained in:
2025-07-16 10:38:47 +08:00
parent 6f2af2f395
commit 82127a81ba
9 changed files with 204 additions and 176 deletions

View File

@@ -33,6 +33,7 @@ export class SingletonModuleComp extends ecs.Comp {
hero_back_x:number = 0; hero_back_x:number = 0;
mon_front_x:number = 0; mon_front_x:number = 0;
mon_back_x:number = 0; mon_back_x:number = 0;
enhancements:any=[]
vmdata: any = { vmdata: any = {
game_over:false, game_over:false,
game_pause:false, game_pause:false,

View File

@@ -11,7 +11,7 @@ export const EnhancementType = {
ATTACK: 1, // 攻击力强化 ATTACK: 1, // 攻击力强化
HEALTH: 2, // 生命值强化 HEALTH: 2, // 生命值强化
ATTACK_SPEED: 3, // 攻击速度强化 ATTACK_SPEED: 3, // 攻击速度强化
SPECIAL: 4, // 特殊效果强化 DEF: 4, // 特殊效果强化
} }
// 玩家强化等级追踪 // 玩家强化等级追踪
@@ -19,7 +19,7 @@ export interface PlayerEnhancementProgress {
[EnhancementType.ATTACK]: number; [EnhancementType.ATTACK]: number;
[EnhancementType.HEALTH]: number; [EnhancementType.HEALTH]: number;
[EnhancementType.ATTACK_SPEED]: number; [EnhancementType.ATTACK_SPEED]: number;
[EnhancementType.SPECIAL]: number; [EnhancementType.DEF]: number;
} }
// 默认强化进度所有强化都从0级开始 // 默认强化进度所有强化都从0级开始
@@ -27,152 +27,121 @@ export const defaultEnhancementProgress: PlayerEnhancementProgress = {
[EnhancementType.ATTACK]: 0, [EnhancementType.ATTACK]: 0,
[EnhancementType.HEALTH]: 0, [EnhancementType.HEALTH]: 0,
[EnhancementType.ATTACK_SPEED]: 0, [EnhancementType.ATTACK_SPEED]: 0,
[EnhancementType.SPECIAL]: 0, [EnhancementType.DEF]: 0,
}; };
export const defaultEnhancements=()=>{
// 强化选项配置表(按等级分类) return defaultEnhancementProgress
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 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 { export interface EnhancementOption {
name: string; uuid: number; // 强化选项唯一ID
description: string; type: number; // 强化类型 (EnhancementType)
buffType: number; lv: number; // 强化等级
value: number; name: string; // 强化名称
icon: string; description: string; // 强化描述
rarity: 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 currentLevel = playerProgress[type] || 0;
const nextLevel = Math.min(currentLevel + 1, 5); // 最大等级为5 const nextLevel = Math.min(currentLevel + 1, 5); // 最大等级为5
const option = EnhancementOptions[type]?.[nextLevel]; const option = EnhancementOptions[type - 1]?.[nextLevel - 1]; // 数组索引从0开始
if (option) { if (option) {
options.push(option); options.push(option);
} }
@@ -211,7 +180,7 @@ export function getEnhancement(playerProgress: PlayerEnhancementProgress, count:
// 获取指定类型和等级的强化选项 // 获取指定类型和等级的强化选项
export function getEnhancementOptionByTypeAndLevel(type: number, level: number): EnhancementOption | null { 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[] = []; const options: EnhancementOption[] = [];
for (const type of Object.values(EnhancementType)) { for (const type of Object.values(EnhancementType)) {
const option = EnhancementOptions[type]?.[level]; const option = EnhancementOptions[type - 1]?.[level - 1]; // 数组索引从0开始
if (option) { if (option) {
options.push(option); options.push(option);
} }
@@ -304,3 +273,34 @@ export function getEnhancementLevel(progress: PlayerEnhancementProgress, type: n
export function getTotalEnhancementLevel(progress: PlayerEnhancementProgress): number { export function getTotalEnhancementLevel(progress: PlayerEnhancementProgress): number {
return Object.values(progress).reduce((total, level) => total + level, 0); 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;
}

View File

@@ -2,7 +2,7 @@
"ver": "4.0.23", "ver": "4.0.23",
"importer": "typescript", "importer": "typescript",
"imported": true, "imported": true,
"uuid": "b7e16305-7610-4d81-a60b-040fbbce4b72", "uuid": "bbef9ac6-154b-4e27-9c56-e964e27ef2d5",
"files": [], "files": [],
"subMetas": {}, "subMetas": {},
"userData": {} "userData": {}

View File

@@ -1,9 +0,0 @@
{
"ver": "4.0.23",
"importer": "typescript",
"imported": true,
"uuid": "4493de4e-44b0-45a1-9d0b-3043d50cc417",
"files": [],
"subMetas": {},
"userData": {}
}

View File

@@ -1,11 +0,0 @@
{
"ver": "1.0.2",
"importer": "text",
"imported": true,
"uuid": "65b38842-3a45-44b0-b756-068a4d799715",
"files": [
".json"
],
"subMetas": {},
"userData": {}
}

View File

@@ -16,6 +16,7 @@ import { getApIncrease, getHpIncrease, getUpExp, HeroInfo, HeroPos } from "../co
import { FriendModelComp } from "./FriendModel"; import { FriendModelComp } from "./FriendModel";
import { MasterModelComp } from "./MasterModel"; import { MasterModelComp } from "./MasterModel";
import { RandomManager } from "db://oops-framework/core/common/random/RandomManager"; import { RandomManager } from "db://oops-framework/core/common/random/RandomManager";
import { EnhancementType } from "../common/config/LevelUp";
const { ccclass, property } = _decorator; const { ccclass, property } = _decorator;
@@ -159,6 +160,22 @@ export class HeroViewComp extends CCComp {
} }
use_enhancement(e:GameEvent,data:any){ use_enhancement(e:GameEvent,data:any){
console.log("[HeroViewComp]:use_enhancement",data) 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){ change_atk(e:GameEvent,data:any){
@@ -202,6 +219,16 @@ export class HeroViewComp extends CCComp {
* 增加英雄的攻击AP * 增加英雄的攻击AP
* @param 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){ add_ap(ap: number,is_num:boolean=true){
console.log("[HeroViewComp]:add_ap add:",ap,this.ap) console.log("[HeroViewComp]:add_ap add:",ap,this.ap)
if(is_num){ if(is_num){
@@ -620,6 +647,8 @@ export class HeroViewComp extends CCComp {
let diff=this.exp-this.next_exp let diff=this.exp-this.next_exp
if(diff >= 0){ if(diff >= 0){
this.exp=diff this.exp=diff
console.log("[HeroViewComp]:exp_up",this.exp,this.next_exp)
oops.message.dispatchEvent(GameEvent.EnhancementSelect)
this.to_update() this.to_update()
} }
this.BUFFCOMP.vmdata_update(true) //简易更新vmdata this.BUFFCOMP.vmdata_update(true) //简易更新vmdata

View File

@@ -96,6 +96,10 @@ export class CardComp extends CCComp {
this.node.getChildByName("show").active=false this.node.getChildByName("show").active=false
this.node.getChildByName("anim").getChildByName("up").getComponent(Animation).play('carsup') this.node.getChildByName("anim").getChildByName("up").getComponent(Animation).play('carsup')
this.show_enhancement(args) this.show_enhancement(args)
this.scheduleOnce(() => {
this.node.getChildByName("show").active=true
this.node.getChildByName("Button").active=true
}, 0.1);
} }
random_select(){ random_select(){
@@ -176,6 +180,12 @@ export class CardComp extends CCComp {
let show=this.node.getChildByName("show") let show=this.node.getChildByName("show")
show.getChildByName("name").getChildByName("name").getComponent(Label).string=data.name show.getChildByName("name").getChildByName("name").getComponent(Label).string=data.name
this.do_card_bg_show(data.rarity) 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){ do_card_bg_show(q:number=Quality.WHITE){
@@ -316,6 +326,11 @@ export class CardComp extends CCComp {
case cardType.ENHANCEMENT: case cardType.ENHANCEMENT:
console.log("[cardcomp]:use_card 强化卡") console.log("[cardcomp]:use_card 强化卡")
oops.message.dispatchEvent(GameEvent.UseEnhancement,this.enhancement_data) 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) oops.message.dispatchEvent(GameEvent.CardsClose)
break break
} }

View File

@@ -46,6 +46,7 @@ export class CardsCompComp extends CCComp {
this.on(GameEvent.HeroSkillSelectEnd, this.close_cards, this); this.on(GameEvent.HeroSkillSelectEnd, this.close_cards, this);
this.on(GameEvent.CardsClose, this.close_cards, this); this.on(GameEvent.CardsClose, this.close_cards, this);
this.on(GameEvent.EquipSelect, this.addToQueue, this); this.on(GameEvent.EquipSelect, this.addToQueue, this);
this.on(GameEvent.EnhancementSelect, this.addToQueue, this);
this.card1=this.node.getChildByName("cards").getChildByName("card1") this.card1=this.node.getChildByName("cards").getChildByName("card1")
this.card2=this.node.getChildByName("cards").getChildByName("card2") this.card2=this.node.getChildByName("cards").getChildByName("card2")
this.card3=this.node.getChildByName("cards").getChildByName("card3") this.card3=this.node.getChildByName("cards").getChildByName("card3")
@@ -89,19 +90,19 @@ export class CardsCompComp extends CCComp {
console.log("[CardsComp]:显示强化选择卡牌") console.log("[CardsComp]:显示强化选择卡牌")
this.node.getChildByName("btns").getChildByName("cancel").active=true this.node.getChildByName("btns").getChildByName("cancel").active=true
this.node.getChildByName("top").getChildByName("title").getChildByName("Label").getComponent(Label).string="选择强化" this.node.getChildByName("top").getChildByName("title").getChildByName("Label").getComponent(Label).string="选择强化"
this.enhancement_select(data) this.enhancement_select()
break break
} }
if(!is_refresh) this.show() if(!is_refresh) this.show()
} }
enhancement_select(data:any){ enhancement_select(){
let list=getEnhancement([0,0,0,0],3) let list=getEnhancement(smc.enhancements,3)
console.log("[CardsComp]:强化选择卡牌列表",list) console.log("[CardsComp]:强化选择卡牌列表",list)
this.card1c.enhancement_select(data[0]) this.card1c.enhancement_select(list[0])
this.card2c.enhancement_select(data[1]) this.card2c.enhancement_select(list[1])
this.card3c.enhancement_select(data[2]) this.card3c.enhancement_select(list[2])
} }
hero_select(data:any){ hero_select(data:any){
let list=[] let list=[]

View File

@@ -8,6 +8,7 @@ import { Timer } from "../../../../extensions/oops-plugin-framework/assets/core/
import { GameEvent } from "../common/config/GameEvent"; import { GameEvent } from "../common/config/GameEvent";
import { HeroViewComp } from "../hero/HeroViewComp"; import { HeroViewComp } from "../hero/HeroViewComp";
import { Hero } from "../hero/Hero"; import { Hero } from "../hero/Hero";
import { defaultEnhancements, EnhancementOptions } from "../common/config/LevelUp";
const { ccclass, property } = _decorator; const { ccclass, property } = _decorator;
@@ -24,6 +25,7 @@ export class MissionComp extends CCComp {
waveTimer:Timer = new Timer(10); waveTimer:Timer = new Timer(10);
normal_max_wave:number = 10; normal_max_wave:number = 10;
is_fight:boolean = false; is_fight:boolean = false;
enhancements:any=[0,0,0,0,0]
onLoad(){ onLoad(){
this.on(GameEvent.MissionStart,this.mission_start,this) this.on(GameEvent.MissionStart,this.mission_start,this)
this.on(GameEvent.FightEnd,this.fight_end,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.hero = JSON.parse(JSON.stringify(VmInfo));
smc.vmdata.boss = JSON.parse(JSON.stringify(VmInfo)); smc.vmdata.boss = JSON.parse(JSON.stringify(VmInfo));
this.GlodAddTimer=new Timer(smc.vmdata.mission_data.refrsh_time) this.GlodAddTimer=new Timer(smc.vmdata.mission_data.refrsh_time)
smc.enhancements=defaultEnhancements()
} }