This commit is contained in:
2025-06-11 16:54:50 +08:00
parent 4096922e61
commit d06d8fe910
10 changed files with 295 additions and 141 deletions

View File

@@ -9,6 +9,7 @@ import { SkillSet, TargetGroup, TargetType } from "../common/config/SkillSet";
import { BuffComp } from "./BuffComp";
import { oops } from "db://oops-framework/core/Oops";
import { GameEvent } from "../common/config/GameEvent";
import { FightConComp } from "../map/FightConComp";
const { ccclass, property } = _decorator;
@@ -16,6 +17,7 @@ const { ccclass, property } = _decorator;
@ccclass('HeroViewComp') // 定义为 Cocos Creator 组件
@ecs.register('HeroView', false) // 定义为 ECS 组件
export class HeroViewComp extends CCComp {
FIGHTCON:FightConComp=null!
BUFFCOMP:BuffComp=null!
as: HeroSpine = null!
status:String = "idle"
@@ -84,6 +86,8 @@ export class HeroViewComp extends CCComp {
onLoad() {
this.as = this.getComponent(HeroSpine);
this.FIGHTCON=this.node.parent.getComponent(FightConComp);
console.log("hero view comp ",this.FIGHTCON)
// let anm = this.node.getChildByName("anm")
// anm.setScale(anm.scale.x*0.8,anm.scale.y*0.8);
// 注册单个碰撞体的回调函数

View File

@@ -8,12 +8,13 @@ import { GameEvent } from '../common/config/GameEvent';
import { BoxSet } from '../common/config/BoxSet';
import { smc } from '../common/SingletonModuleComp';
import { CCComp } from 'db://oops-framework/module/common/CCComp';
import { FightConComp } from '../map/FightConComp';
const { ccclass, property } = _decorator;
@ccclass('SkillCon')
@ecs.register('SkillCon')
export class SkillConComp extends CCComp {
FIGHTCON:FightConComp=null!
HeroView:any=null;
HeroEntity:any=null;
private _timers: { [key: string]: number } = {};
@@ -23,6 +24,7 @@ export class SkillConComp extends CCComp {
}
onLoad(){
this.HeroView=this.node.getComponent(HeroViewComp)
this.FIGHTCON=this.node.parent.getComponent(FightConComp)
// console.log(this.HeroView.uuid+"=>"+this.HeroView.hero_name+"=> SkillConComp onLoad")
this.on(GameEvent.CastHeroSkill,this.cast_master_skill,this)
}
@@ -36,7 +38,13 @@ 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(config);
let count=1
if(this.HeroView.is_master){
count+=this.FIGHTCON.hero.ATK_COUNT+this.FIGHTCON.ally.ATK_COUNT
}else{
count+=this.FIGHTCON.friend.ATK_COUNT+this.FIGHTCON.ally.ATK_COUNT
}
this.castSkill(config,count);
this.HeroView.at = 0;
}
}
@@ -46,29 +54,29 @@ export class SkillConComp extends CCComp {
if(!this.HeroView.is_master) return
console.log("hart cast_skill",uuid ,e)
const config = SkillSet[uuid];
this.castSkill(config)
this.castSkill(config,(1+this.FIGHTCON.hero.ATK_COUNT+this.FIGHTCON.ally.ATK_COUNT))
}
/** 施放技能 */
castSkill(config: typeof SkillSet[keyof typeof SkillSet]) {
castSkill(config: typeof SkillSet[keyof typeof SkillSet],count:number=1) {
// console.log(view.uuid+"=>"+view.hero_name+"施放技能:"+config.uuid);
if (config.TargetGroup === TargetGroup.Enemy) {
this.HeroView.playSkillEffect(config.uuid);
this.doSkill(config);
this.doSkill(config,count);
}
if (config.TargetGroup === TargetGroup.Ally) {
const targets = this.selectAllyTargets( config);
if (targets.length === 0) return;
this.doSkill(config,count);
}
if (config.TargetGroup === TargetGroup.Self) {
this.doSkill(config,count);
}
}
private doSkill(config: typeof SkillSet[keyof typeof SkillSet]) {
private doSkill(config: typeof SkillSet[keyof typeof SkillSet],count:number=1) {
const skillEntity = ecs.getEntity<Skill>(Skill);
const targets = this.selectEnemyTargets(config);
if (targets.length === 0) return;