dd
This commit is contained in:
@@ -21,9 +21,13 @@ export class SkillConComp extends CCComp {
|
||||
init(): void {
|
||||
oops.message.on(GameEvent.FightEnd, this.clear_timer, this);
|
||||
}
|
||||
start() {
|
||||
// console.log("SkillConComp start")
|
||||
onLoad(){
|
||||
this.HeroView=this.node.getComponent(HeroViewComp)
|
||||
console.log(this.HeroView.uuid+"=>"+this.HeroView.hero_name+"=> SkillConComp onLoad")
|
||||
}
|
||||
start() {
|
||||
this.HeroView=this.node.getComponent(HeroViewComp)
|
||||
console.log(this.HeroView.uuid+"=>"+this.HeroView.hero_name+"=> SkillConComp start")
|
||||
this.HeroEntity=this.HeroView.ent
|
||||
}
|
||||
|
||||
@@ -32,21 +36,21 @@ export class SkillConComp extends CCComp {
|
||||
if (this.HeroView.is_atking &&this.HeroView.at > this.HeroView.cd) {
|
||||
const config = SkillSet[this.HeroView.atk_skill];
|
||||
if (!config) return;
|
||||
this.castSkill(this.HeroView, this.HeroView.atk_skill, config);
|
||||
this.castSkill(config);
|
||||
this.HeroView.at = 0;
|
||||
}
|
||||
}
|
||||
|
||||
/** 施放技能 */
|
||||
private castSkill(view: HeroViewComp, skillId: number, config: typeof SkillSet[keyof typeof SkillSet]) {
|
||||
castSkill(config: typeof SkillSet[keyof typeof SkillSet]) {
|
||||
// console.log(view.uuid+"=>"+view.hero_name+"施放技能:"+config.uuid);
|
||||
if (config.TargetGroup === TargetGroup.Enemy) {
|
||||
view.playSkillEffect(config.uuid);
|
||||
this.doSkill(view,config);
|
||||
this.HeroView.playSkillEffect(config.uuid);
|
||||
this.doSkill(config);
|
||||
}
|
||||
|
||||
if (config.TargetGroup === TargetGroup.Ally) {
|
||||
const targets = this.selectAllyTargets(view, config);
|
||||
const targets = this.selectAllyTargets( config);
|
||||
if (targets.length === 0) return;
|
||||
|
||||
}
|
||||
@@ -55,24 +59,24 @@ export class SkillConComp extends CCComp {
|
||||
}
|
||||
|
||||
}
|
||||
private doSkill(view: HeroViewComp, config: typeof SkillSet[keyof typeof SkillSet]) {
|
||||
private doSkill(config: typeof SkillSet[keyof typeof SkillSet]) {
|
||||
|
||||
const skillEntity = ecs.getEntity<Skill>(Skill);
|
||||
const targets = this.selectEnemyTargets(view, config);
|
||||
const targets = this.selectEnemyTargets(config);
|
||||
if (targets.length === 0) return;
|
||||
skillEntity.load(
|
||||
new Vec3(view.node.position.x, view.node.position.y+BoxSet.ATK_Y, 0), // 起始位置
|
||||
view.box_group, // 阵营
|
||||
view.node.parent, // 父节点
|
||||
new Vec3(this.HeroView.node.position.x, this.HeroView.node.position.y+BoxSet.ATK_Y, 0), // 起始位置
|
||||
this.HeroView.box_group, // 阵营
|
||||
this.node.parent, // 父节点
|
||||
config.uuid, // 技能ID
|
||||
new Vec3(targets[0]?.get(HeroViewComp).node.position.x, targets[0]?.get(HeroViewComp).node.position.y, 0), // 目标位置
|
||||
view
|
||||
this.HeroView
|
||||
);
|
||||
// console.log("技能:"+config.uuid+"=>"+targets[0]?.get(HeroViewComp).hero_name);
|
||||
}
|
||||
|
||||
private selectEnemyTargets(View: HeroViewComp, config: typeof SkillSet[keyof typeof SkillSet]): ecs.Entity[] {
|
||||
const team = View.fac;
|
||||
private selectEnemyTargets(config: typeof SkillSet[keyof typeof SkillSet]): ecs.Entity[] {
|
||||
const team = this.HeroView.fac;
|
||||
const isEnemyTeam = team === 0 ? 1 : 0;
|
||||
const candidates= ecs.query(ecs.allOf(HeroViewComp)).filter(e => e.get(HeroViewComp).fac !== team);
|
||||
return this.filterFrontRow(candidates, isEnemyTeam);
|
||||
@@ -89,8 +93,8 @@ export class SkillConComp extends CCComp {
|
||||
Math.abs(e.get(HeroViewComp).node.position.x - keyPos) < 10
|
||||
);
|
||||
}
|
||||
private selectAllyTargets(View: HeroViewComp, config: typeof SkillSet[keyof typeof SkillSet]): ecs.Entity[] {
|
||||
const team = View.fac;
|
||||
private selectAllyTargets( config: typeof SkillSet[keyof typeof SkillSet]): ecs.Entity[] {
|
||||
const team = this.HeroView.fac;
|
||||
const candidates= ecs.query(ecs.allOf(HeroViewComp)).filter(e => e.get(HeroViewComp).fac === team);
|
||||
// 第二阶段:位置/血量等精细筛选
|
||||
switch(config.TargetType) {
|
||||
|
||||
Reference in New Issue
Block a user