2 Commits

Author SHA1 Message Date
2eae29f1a1 fix(hero): 修正英雄与怪物技能消耗和状态判断逻辑
- 修改Hero和Monster类中技能对象,新增cost属性用于技能消耗
- 修复HeroViewComp中isStun和isFrost方法,确保返回布尔值
- SkillConComp日志输出技能列表和消耗信息,增强调试能力
- 更新英雄配置中的map属性值由0改为100,统一角色数据映射
2025-10-18 09:07:22 +08:00
a3e4e70d9d feat(hero): 初始化角色和怪物技能数据,修改技能数据引用
- 在Hero实体中初始化技能数组,添加技能UUID和冷却时间信息
- 在Monster实体中遍历怪物技能,准备技能相关数据
- 在HeroViewComp中新增skills属性以存储技能信息
- 在SkillEnt中修正技能属性赋值,使用深拷贝避免引用问题
- 删除SkillConComp中无用的空行,优化update方法代码格式
2025-10-17 22:29:10 +08:00
6 changed files with 42 additions and 32 deletions

View File

@@ -107,101 +107,101 @@ export interface heroInfo{
export const HeroInfo: Record<number, heroInfo> = { export const HeroInfo: Record<number, heroInfo> = {
//主将 //主将
5001:{uuid:5001,name:"火焰骑士",path:"hk1", fac:FacSet.HERO, kind:1, 5001:{uuid:5001,name:"火焰骑士",path:"hk1", fac:FacSet.HERO, kind:1,
type:HType.warrior,lv:1,hp:100,mp:100,map:0,def:5,ap:15,dis:100,cd:1,speed:150,skills:[6001,6001], type:HType.warrior,lv:1,hp:100,mp:100,map:100,def:5,ap:15,dis:100,cd:1,speed:150,skills:[6001,6001],
buff:[],debuff:[],info:""}, buff:[],debuff:[],info:""},
5002:{uuid:5002,name:"刺客",path:"hc1", fac:FacSet.HERO, kind:1, 5002:{uuid:5002,name:"刺客",path:"hc1", fac:FacSet.HERO, kind:1,
type:HType.warrior,lv:1,hp:100,mp:100,map:0,def:5,ap:15,dis:100,cd:1,speed:150,skills:[6001,6001], type:HType.warrior,lv:1,hp:100,mp:100,map:100,def:5,ap:15,dis:100,cd:1,speed:150,skills:[6001,6001],
buff:[],debuff:[],info:""}, buff:[],debuff:[],info:""},
5005:{uuid:5005,name:"绿箭",path:"ha1", fac:FacSet.HERO, kind:2, 5005:{uuid:5005,name:"绿箭",path:"ha1", fac:FacSet.HERO, kind:2,
type:HType.remote,lv:1,hp:100,mp:100,map:0,def:5,ap:15,dis:400,cd:1,speed:100,skills:[6001,6001], type:HType.remote,lv:1,hp:100,mp:100,map:100,def:5,ap:15,dis:400,cd:1,speed:100,skills:[6001,6001],
buff:[],debuff:[],info:""}, buff:[],debuff:[],info:""},
5007:{uuid:5007,name:"牧师",path:"hmh1", fac:FacSet.HERO, kind:2, 5007:{uuid:5007,name:"牧师",path:"hmh1", fac:FacSet.HERO, kind:2,
type:HType.mage,lv:1,hp:100,mp:100,map:0,def:5,ap:15,dis:400,cd:1,speed:100,skills:[6001,6001], type:HType.mage,lv:1,hp:100,mp:100,map:100,def:5,ap:15,dis:400,cd:1,speed:100,skills:[6001,6001],
buff:[],debuff:[],info:""}, buff:[],debuff:[],info:""},
5008:{uuid:5008,name:"火女",path:"hmf1", fac:FacSet.HERO, kind:2, 5008:{uuid:5008,name:"火女",path:"hmf1", fac:FacSet.HERO, kind:2,
type:HType.mage,lv:1,hp:100,mp:100,map:0,def:5,ap:15,dis:400,cd:1.5,speed:100,skills:[6001,6001], type:HType.mage,lv:1,hp:100,mp:100,map:100,def:5,ap:15,dis:400,cd:1.5,speed:100,skills:[6001,6001],
buff:[],debuff:[],info:""}, buff:[],debuff:[],info:""},
// 5009:{uuid:5009,name:"风暴精灵",path:"hk1", fac:FacSet.HERO, kind:2, // 5009:{uuid:5009,name:"风暴精灵",path:"hk1", fac:FacSet.HERO, kind:2,
// type:HType.mage,lv:1,hp:100,mp:100,map:0,def:5,ap:15,dis:400,cd:1.5,speed:100,skills:[6006,6006,6301,6302,6303], // type:HType.mage,lv:1,hp:100,mp:100,map:100,def:5,ap:15,dis:400,cd:1.5,speed:100,skills:[6006,6006,6301,6302,6303],
// buff:[],debuff:[],info:""}, // buff:[],debuff:[],info:""},
// 5010:{uuid:5010,name:"战争祭祀",path:"hk1", fac:FacSet.HERO, kind:2, // 5010:{uuid:5010,name:"战争祭祀",path:"hk1", fac:FacSet.HERO, kind:2,
// type:HType.mage,lv:1,hp:100,mp:100,map:0,def:5,ap:15,dis:400,cd:1.5,speed:100,skills:[6007,6007,6301,6302,6303], // type:HType.mage,lv:1,hp:100,mp:100,map:100,def:5,ap:15,dis:400,cd:1.5,speed:100,skills:[6007,6007,6301,6302,6303],
// buff:[],debuff:[],info:""}, // buff:[],debuff:[],info:""},
// 5011:{uuid:5011,name:"ha2",path:"ha2", fac:FacSet.HERO, kind:2, // 5011:{uuid:5011,name:"ha2",path:"ha2", fac:FacSet.HERO, kind:2,
// type:HType.remote,lv:1,hp:100,mp:100,map:0,def:5,ap:15,dis:400,cd:1,speed:100,skills:[6003,6003,6301,6302,6303], // type:HType.remote,lv:1,hp:100,mp:100,map:100,def:5,ap:15,dis:400,cd:1,speed:100,skills:[6003,6003,6301,6302,6303],
// buff:[],debuff:[],info:""}, // buff:[],debuff:[],info:""},
//怪物 //怪物
5201:{uuid:5201,name:"兽人战士",path:"mo1", fac:FacSet.MON, kind:1, 5201:{uuid:5201,name:"兽人战士",path:"mo1", fac:FacSet.MON, kind:1,
type:HType.warrior,lv:1,hp:25,mp:100,map:0,def:5,ap:5,dis:90,cd:2,speed:100,skills:[6001,6001], type:HType.warrior,lv:1,hp:25,mp:100,map:100,def:5,ap:5,dis:90,cd:2,speed:100,skills:[6001,6001],
buff:[],debuff:[],info:"普通怪物-战士型"}, buff:[],debuff:[],info:"普通怪物-战士型"},
5202:{uuid:5202,name:"兽人刺客",path:"mo1", fac:FacSet.MON, kind:1, 5202:{uuid:5202,name:"兽人刺客",path:"mo1", fac:FacSet.MON, kind:1,
type:HType.remote,lv:1,hp:20,mp:100,map:0,def:5,ap:5,dis:350,cd:1,speed:100,skills:[6001,6001], type:HType.remote,lv:1,hp:20,mp:100,map:100,def:5,ap:5,dis:350,cd:1,speed:100,skills:[6001,6001],
buff:[],debuff:[],info:"普通怪物-战士型"}, buff:[],debuff:[],info:"普通怪物-战士型"},
5203:{uuid:5203,name:"兽人护卫",path:"mo1", fac:FacSet.MON, kind:1, 5203:{uuid:5203,name:"兽人护卫",path:"mo1", fac:FacSet.MON, kind:1,
type:HType.warrior,lv:1,hp:25,mp:100,map:0,def:5,ap:5,dis:90,cd:2,speed:100,skills:[6001,6001], type:HType.warrior,lv:1,hp:25,mp:100,map:100,def:5,ap:5,dis:90,cd:2,speed:100,skills:[6001,6001],
buff:[],debuff:[],info:"普通怪物-战士型"}, buff:[],debuff:[],info:"普通怪物-战士型"},
5204:{uuid:5204,name:"石卫", path:"mo1", fac:FacSet.MON, kind:1, 5204:{uuid:5204,name:"石卫", path:"mo1", fac:FacSet.MON, kind:1,
type:HType.mage,lv:1,hp:18,mp:100,map:0,def:5,ap:5,dis:90,cd:2.5,speed:100,skills:[6001,6001], type:HType.mage,lv:1,hp:18,mp:100,map:100,def:5,ap:5,dis:90,cd:2.5,speed:100,skills:[6001,6001],
buff:[],debuff:[],info:"法师怪物-高伤害脆弱"}, buff:[],debuff:[],info:"法师怪物-高伤害脆弱"},
5205:{uuid:5205,name:"土卫", path:"mo1", fac:FacSet.MON, kind:1, 5205:{uuid:5205,name:"土卫", path:"mo1", fac:FacSet.MON, kind:1,
type:HType.mage,lv:1,hp:18,mp:100,map:0,def:5,ap:5,dis:90,cd:2.5,speed:100,skills:[6001,6001], type:HType.mage,lv:1,hp:18,mp:100,map:100,def:5,ap:5,dis:90,cd:2.5,speed:100,skills:[6001,6001],
buff:[],debuff:[],info:"法师怪物-高伤害脆弱"}, buff:[],debuff:[],info:"法师怪物-高伤害脆弱"},
5206:{uuid:5206,name:"树卫", path:"mo1", fac:FacSet.MON, kind:1, 5206:{uuid:5206,name:"树卫", path:"mo1", fac:FacSet.MON, kind:1,
type:HType.mage,lv:1,hp:18,mp:100,map:0,def:5,ap:5,dis:90,cd:2.5,speed:100,skills:[6001,6001], type:HType.mage,lv:1,hp:18,mp:100,map:100,def:5,ap:5,dis:90,cd:2.5,speed:100,skills:[6001,6001],
buff:[],debuff:[],info:"法师怪物-高伤害脆弱"}, buff:[],debuff:[],info:"法师怪物-高伤害脆弱"},
5219:{uuid:5219,name:"牛头战士",path:"mo1", fac:FacSet.MON,kind:1, 5219:{uuid:5219,name:"牛头战士",path:"mo1", fac:FacSet.MON,kind:1,
type:HType.warrior,lv:1,hp:25,mp:100,map:0,def:5,ap:5,dis:90,cd:2,speed:100,skills:[6001,6001], type:HType.warrior,lv:1,hp:25,mp:100,map:100,def:5,ap:5,dis:90,cd:2,speed:100,skills:[6001,6001],
buff:[],debuff:[],info:"普通怪物-战士型"}, buff:[],debuff:[],info:"普通怪物-战士型"},
5220:{uuid:5220,name:"牛头战士",path:"mo1", fac:FacSet.MON, kind:1, 5220:{uuid:5220,name:"牛头战士",path:"mo1", fac:FacSet.MON, kind:1,
type:HType.warrior,lv:1,hp:25,mp:100,map:0,def:5,ap:5,dis:90,cd:2,speed:100,skills:[6001,6001], type:HType.warrior,lv:1,hp:25,mp:100,map:100,def:5,ap:5,dis:90,cd:2,speed:100,skills:[6001,6001],
buff:[],debuff:[],info:"普通怪物-战士型"}, buff:[],debuff:[],info:"普通怪物-战士型"},
5221:{uuid:5221,name:"牛头战士",path:"mo1", fac:FacSet.MON, kind:1, 5221:{uuid:5221,name:"牛头战士",path:"mo1", fac:FacSet.MON, kind:1,
type:HType.remote,lv:1,hp:20,mp:100,map:0,def:5,ap:5,dis:350,cd:1.5,speed:100,skills:[6001,6001], type:HType.remote,lv:1,hp:20,mp:100,map:100,def:5,ap:5,dis:350,cd:1.5,speed:100,skills:[6001,6001],
buff:[],debuff:[],info:"普通怪物-战士型"}, buff:[],debuff:[],info:"普通怪物-战士型"},
5222:{uuid:5222,name:"独眼巨人",path:"mo1", fac:FacSet.MON, kind:1, 5222:{uuid:5222,name:"独眼巨人",path:"mo1", fac:FacSet.MON, kind:1,
type:HType.warrior,lv:1,hp:25,mp:100,map:0,def:5,ap:5,dis:90,cd:2,speed:100,skills:[6001,6001], type:HType.warrior,lv:1,hp:25,mp:100,map:100,def:5,ap:5,dis:90,cd:2,speed:100,skills:[6001,6001],
buff:[],debuff:[],info:"普通怪物-战士型"}, buff:[],debuff:[],info:"普通怪物-战士型"},
5223:{uuid:5223,name:"独眼巨人",path:"mo1", fac:FacSet.MON, kind:1, 5223:{uuid:5223,name:"独眼巨人",path:"mo1", fac:FacSet.MON, kind:1,
type:HType.warrior,lv:1,hp:25,mp:100,map:0,def:5,ap:5,dis:90,cd:2,speed:100,skills:[6001,6001], type:HType.warrior,lv:1,hp:25,mp:100,map:100,def:5,ap:5,dis:90,cd:2,speed:100,skills:[6001,6001],
buff:[],debuff:[],info:"普通怪物-战士型"}, buff:[],debuff:[],info:"普通怪物-战士型"},
5224:{uuid:5224,name:"独眼巨人",path:"mo1", fac:FacSet.MON, kind:1, 5224:{uuid:5224,name:"独眼巨人",path:"mo1", fac:FacSet.MON, kind:1,
type:HType.remote,lv:1,hp:20,mp:100,map:0,def:5,ap:5,dis:350,cd:1.5,speed:100,skills:[6001,6001], type:HType.remote,lv:1,hp:20,mp:100,map:100,def:5,ap:5,dis:350,cd:1.5,speed:100,skills:[6001,6001],
buff:[],debuff:[],info:"普通怪物-战士型"}, buff:[],debuff:[],info:"普通怪物-战士型"},
5225:{uuid:5225,name:"精英独眼",path:"mo1", fac:FacSet.MON, kind:1, 5225:{uuid:5225,name:"精英独眼",path:"mo1", fac:FacSet.MON, kind:1,
type:HType.warrior,lv:1,hp:45,mp:100,map:0,def:5,ap:12,dis:300,cd:2,speed:100,skills:[6001], type:HType.warrior,lv:1,hp:45,mp:100,map:100,def:5,ap:12,dis:300,cd:2,speed:100,skills:[6001],
buff:[],debuff:[],info:"精英怪物-战士型"}, buff:[],debuff:[],info:"精英怪物-战士型"},
5226:{uuid:5226,name:"精英牛头",path:"mo1", fac:FacSet.MON, kind:1, 5226:{uuid:5226,name:"精英牛头",path:"mo1", fac:FacSet.MON, kind:1,
type:HType.warrior,lv:1,hp:45,mp:100,map:0,def:5,ap:12,dis:300,cd:2,speed:100,skills:[6001,6001], type:HType.warrior,lv:1,hp:45,mp:100,map:100,def:5,ap:12,dis:300,cd:2,speed:100,skills:[6001,6001],
buff:[],debuff:[],info:"精英怪物-战士型"}, buff:[],debuff:[],info:"精英怪物-战士型"},
5227:{uuid:5227,name:"精英兽人",path:"mo1", fac:FacSet.MON, kind:1, 5227:{uuid:5227,name:"精英兽人",path:"mo1", fac:FacSet.MON, kind:1,
type:HType.warrior,lv:1,hp:45,mp:100,map:0,def:5,ap:12,dis:300,cd:2,speed:100,skills:[6001,6001], type:HType.warrior,lv:1,hp:45,mp:100,map:100,def:5,ap:12,dis:300,cd:2,speed:100,skills:[6001,6001],
buff:[],debuff:[],info:"精英怪物-战士型"}, buff:[],debuff:[],info:"精英怪物-战士型"},
}; };

View File

@@ -8,7 +8,8 @@ import { BoxSet, FacSet } from "../common/config/BoxSet";
import { HeroInfo, HeroPos, HType } from "../common/config/heroSet"; import { HeroInfo, HeroPos, HType } from "../common/config/heroSet";
import { BattleMoveComp } from "../common/ecs/position/BattleMoveComp"; import { BattleMoveComp } from "../common/ecs/position/BattleMoveComp";
import { GameEvent } from "../common/config/GameEvent"; import { GameEvent } from "../common/config/GameEvent";
import { Attrs, getAttrs } from "../common/config/SkillSet"; import { Attrs, getAttrs, SkillSet } from "../common/config/SkillSet";
import { time } from "console";
/** 角色实体 */ /** 角色实体 */
@ecs.register(`Hero`) @ecs.register(`Hero`)
@@ -71,6 +72,10 @@ export class Hero extends ecs.Entity {
hv.box_group = BoxSet.HERO; hv.box_group = BoxSet.HERO;
hv.hero_uuid= uuid; hv.hero_uuid= uuid;
hv.hero_name= hero.name; hv.hero_name= hero.name;
for(let i=0;i<hero.skills.length;i++){
let skill={ uuid:SkillSet[hero.skills[i]].uuid, cd_max:SkillSet[hero.skills[i]].cd,cost:SkillSet[hero.skills[i]].cost,cd:0 }
hv.skills.push(skill)
}
hv.base_ap=hero.ap hv.base_ap=hero.ap
hv.base_map=hero.mp hv.base_map=hero.mp
hv.base_def=hero.def hv.base_def=hero.def

View File

@@ -56,7 +56,7 @@ export class HeroViewComp extends CCComp {
is_master:boolean =false; is_master:boolean =false;
is_friend:boolean =false; is_friend:boolean =false;
is_kalami:boolean =false; is_kalami:boolean =false;
skills:any=[]
mp: number = 100; mp: number = 100;
hp: number = 100; /** 血*/ hp: number = 100; /** 血*/
shield:number=0; //当前护甲 shield:number=0; //当前护甲
@@ -474,10 +474,10 @@ export class HeroViewComp extends CCComp {
} }
public isStun() { public isStun() {
this.DBUFFS_V[DBuff.STUN] !== undefined return this.DBUFFS_V[DBuff.STUN] !== undefined?true:false
} }
public isFrost() { public isFrost() {
this.DBUFFS_V[DBuff.FROST] !== undefined return this.DBUFFS_V[DBuff.FROST] !== undefined?true:false
} }
update(dt: number){ update(dt: number){

View File

@@ -94,7 +94,10 @@ export class Monster extends ecs.Entity {
finalAp = Math.floor(baseAp * stageMultipliers.attack); finalAp = Math.floor(baseAp * stageMultipliers.attack);
// console.log(`[Monster]: 怪物${hero.name} 关卡倍数 - HP: ${baseHp} x ${stageMultipliers.hp.toFixed(2)} = ${finalHp}, AP: ${baseAp} x ${stageMultipliers.attack.toFixed(2)} = ${finalAp}`); // console.log(`[Monster]: 怪物${hero.name} 关卡倍数 - HP: ${baseHp} x ${stageMultipliers.hp.toFixed(2)} = ${finalHp}, AP: ${baseAp} x ${stageMultipliers.attack.toFixed(2)} = ${finalAp}`);
} }
for(let i=0;i<hero.skills.length;i++){
let skill={ uuid:SkillSet[hero.skills[i]].uuid, cd_max:SkillSet[hero.skills[i]].cd,cost:SkillSet[hero.skills[i]].cost,cd:0 }
hv.skills.push(skill)
}
hv.base_ap=finalAp hv.base_ap=finalAp
hv.base_map=hero.mp hv.base_map=hero.mp
hv.base_def=hero.def hv.base_def=hero.def

View File

@@ -32,12 +32,14 @@ export class SkillConComp extends CCComp {
update(dt: number) { update(dt: number) {
if(!smc.mission.play||smc.mission.pause) return if(!smc.mission.play||smc.mission.pause) return
if(!this.HeroView.isStun() && !this.HeroView.isFrost()) { if(!this.HeroView.isStun() && !this.HeroView.isFrost()) {
let skills=this.HeroView.skills let skills=this.HeroView.skills
console.log(this.HeroView.uuid+"=>"+this.HeroView.hero_name+"技能列表:",skills)
for(let i=0;i<skills.length;i++){ for(let i=0;i<skills.length;i++){
skills[i].cd += dt; skills[i].cd += dt;
console.log(this.HeroView.uuid+"=>"+skills[i].cost,this.HeroView.mp)
if(skills[i].cd > skills[i].cd_max&&this.HeroView.mp >= skills[i].cost){ if(skills[i].cd > skills[i].cd_max&&this.HeroView.mp >= skills[i].cost){
if(SkillSet[skills[i].uuid].SType==SType.damage&&this.HeroView.is_atking){ if(SkillSet[skills[i].uuid].SType==SType.damage&&this.HeroView.is_atking){
this.castSkill(SkillSet[skills[i].uuid]) this.castSkill(SkillSet[skills[i].uuid])
this.HeroView.skills[i].cd = 0 this.HeroView.skills[i].cd = 0

View File

@@ -57,8 +57,8 @@ load(startPos: Vec3, parent: Node, uuid: number, targetPos: any[], caster:Hero
SComp.targetPos= targetPos SComp.targetPos= targetPos
SComp.group= caster.box_group SComp.group= caster.box_group
SComp.fac= caster.fac, SComp.fac= caster.fac,
// 技能数值 // 技能数值(深拷贝避免引用问题)
SComp.Attrs= caster.Attrs SComp.Attrs = { ...caster.Attrs } // 或使用 Object.assign({}, caster.Attrs)
SComp.caster= caster, SComp.caster= caster,
this.add(SComp); this.add(SComp);
} }