feat(hero): 初始化角色和怪物技能数据,修改技能数据引用
- 在Hero实体中初始化技能数组,添加技能UUID和冷却时间信息 - 在Monster实体中遍历怪物技能,准备技能相关数据 - 在HeroViewComp中新增skills属性以存储技能信息 - 在SkillEnt中修正技能属性赋值,使用深拷贝避免引用问题 - 删除SkillConComp中无用的空行,优化update方法代码格式
This commit is contained in:
@@ -8,7 +8,8 @@ import { BoxSet, FacSet } from "../common/config/BoxSet";
|
||||
import { HeroInfo, HeroPos, HType } from "../common/config/heroSet";
|
||||
import { BattleMoveComp } from "../common/ecs/position/BattleMoveComp";
|
||||
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`)
|
||||
|
||||
@@ -71,6 +72,10 @@ export class Hero extends ecs.Entity {
|
||||
hv.box_group = BoxSet.HERO;
|
||||
hv.hero_uuid= uuid;
|
||||
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,cd:0 }
|
||||
hv.skills.push(skill)
|
||||
}
|
||||
hv.base_ap=hero.ap
|
||||
hv.base_map=hero.mp
|
||||
hv.base_def=hero.def
|
||||
|
||||
@@ -56,7 +56,7 @@ export class HeroViewComp extends CCComp {
|
||||
is_master:boolean =false;
|
||||
is_friend:boolean =false;
|
||||
is_kalami:boolean =false;
|
||||
|
||||
skills:any=[]
|
||||
mp: number = 100;
|
||||
hp: number = 100; /** 血*/
|
||||
shield:number=0; //当前护甲
|
||||
@@ -163,7 +163,7 @@ export class HeroViewComp extends CCComp {
|
||||
attrIndex !== Attrs.MAP &&
|
||||
attrIndex !== Attrs.SPEED &&
|
||||
attrIndex !== Attrs.DIS
|
||||
|
||||
|
||||
) {
|
||||
this.Attrs[attrIndex] = 0;
|
||||
}
|
||||
|
||||
@@ -94,7 +94,10 @@ export class Monster extends ecs.Entity {
|
||||
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}`);
|
||||
}
|
||||
|
||||
for(let i=0;i<hero.skills.length;i++){
|
||||
let skill={ uuid:SkillSet[hero.skills[i]].uuid, cd_max:SkillSet[hero.skills[i]].cd,cd:0 }
|
||||
hv.skills.push(skill)
|
||||
}
|
||||
hv.base_ap=finalAp
|
||||
hv.base_map=hero.mp
|
||||
hv.base_def=hero.def
|
||||
|
||||
@@ -32,7 +32,6 @@ export class SkillConComp extends CCComp {
|
||||
|
||||
update(dt: number) {
|
||||
if(!smc.mission.play||smc.mission.pause) return
|
||||
|
||||
if(!this.HeroView.isStun() && !this.HeroView.isFrost()) {
|
||||
let skills=this.HeroView.skills
|
||||
for(let i=0;i<skills.length;i++){
|
||||
|
||||
@@ -57,8 +57,8 @@ load(startPos: Vec3, parent: Node, uuid: number, targetPos: any[], caster:Hero
|
||||
SComp.targetPos= targetPos
|
||||
SComp.group= caster.box_group
|
||||
SComp.fac= caster.fac,
|
||||
// 技能数值
|
||||
SComp.Attrs= caster.Attrs
|
||||
// 技能数值(深拷贝避免引用问题)
|
||||
SComp.Attrs = { ...caster.Attrs } // 或使用 Object.assign({}, caster.Attrs)
|
||||
SComp.caster= caster,
|
||||
this.add(SComp);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user