This commit is contained in:
2025-06-05 23:06:53 +08:00
parent 25202ccb35
commit 6883916de1
12 changed files with 271 additions and 205 deletions

View File

@@ -2,19 +2,38 @@ import { oops } from "db://oops-framework/core/Oops";
import { ecs } from "../../../../extensions/oops-plugin-framework/assets/libs/ecs/ECS";
import { HeroViewComp } from "./HeroViewComp";
import { GameEvent } from "../common/config/GameEvent";
import { CCComp } from "db://oops-framework/module/common/CCComp";
import { MissionEvent } from "../common/config/MissionEvent";
import { SkillConComp } from "./SkillConComp";
import { SkillSet } from "../common/config/SkillSet";
import { _decorator } from "cc";
const { ccclass, property } = _decorator;
/**
* 角色属性数据
*/
@ecs.register('HartModel')
export class HartModelComp extends ecs.Comp {
@ccclass('HartMode')
@ecs.register('HartModelComp')
export class HartModelComp extends CCComp {
SkillCon:SkillConComp
onLoad(){
console.log("HartModel加载",this)
this.on(GameEvent.FightReady,this.start,this)
this.on(GameEvent.CastHeroSkill,this.cast_skill,this)
}
start(){
oops.message.dispatchEvent(GameEvent.FightReady,this)
this.SkillCon=this.node.getComponent(SkillConComp)
console.log("hart start",this.SkillCon)
}
cast_skill(e:string,uuid:any){
console.log("hart cast_skill",uuid ,e)
const config = SkillSet[uuid];
this.SkillCon.castSkill(config)
}
reset() {
}
}

View File

@@ -5,7 +5,6 @@ import { smc } from "../common/SingletonModuleComp";
import { HeroModelComp } from "./HeroModelComp";
import { HeroViewComp } from "./HeroViewComp";
import { HeroInfo, HeroPos, HeroSet } from "../common/config/heroSet";
import { MissionComp } from "../map/MissionComp";
const { ccclass, property } = _decorator;

View File

@@ -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) {