This commit is contained in:
2025-06-29 23:36:22 +08:00
parent 2ec530d881
commit 326e9bb97c
29 changed files with 2082 additions and 86 deletions

View File

@@ -14,7 +14,7 @@ const { ccclass, property } = _decorator;
@ccclass('FightConComp')
export class FightConComp extends Component {
//装备 及 光环效果 物品存在生效
//装备 及 光环效果 物品存在生效 enemy_buff 是针对 怪物的debuff 偶尔也有buff 需要注意
hero_buff=getBuffNum()
friend_buff=getBuffNum()
enemy_buff=getBuffNum()
@@ -36,8 +36,9 @@ export class FightConComp extends Component {
aoe_queues:any[]=[] // 范围伤害技能执行队列
private aoe_timer: number = 0; // 技能执行计时器
private aoe_timers: Map<number, number> = new Map(); // 每个技能的独立计时器
private readonly AOE_INTERVAL: number = 0.4; // 执行间隔,单位秒
private skill_id_counter: number = 0; // 技能ID计数器
aoe_pos:Vec3=new Vec3(-280,20,0)
aoe_target_pos:Vec3=new Vec3(180,0,0)
@@ -119,10 +120,14 @@ export class FightConComp extends Component {
}
break
case SuperCardsType.AOE:
this.skill_id_counter++;
this.aoe_queues.push({
id: this.skill_id_counter,
s_uuid:SuperCards[data.uuid].value1,
count:SuperCards[data.uuid].value2,
damage:SuperCards[data.uuid].value3})
// 初始化该技能的计时器
this.aoe_timers.set(this.skill_id_counter, 0);
break
case SuperCardsType.BUFF:
@@ -169,6 +174,7 @@ export class FightConComp extends Component {
);
}
/** 随机选择目标 */
private pickRandomTarget(count: number=1): ecs.Entity[] {
let entities = ecs.query(ecs.allOf(MonModelComp))
@@ -191,20 +197,37 @@ export class FightConComp extends Component {
this.card_atk_add=0
this.card_hp_add=0
this.aoe_queues = [] // 清空技能队列
this.aoe_timer = 0 // 重置计时器
this.aoe_timers = new Map(); // 重置计时器
this.skill_id_counter = 0; // 重置技能ID计数器
}
update(deltaTime: number) {
// 更新技能执行计时器
// 并行执行多个技能
if (this.aoe_queues.length > 0) {
this.aoe_timer += deltaTime;
if (this.aoe_timer >= this.AOE_INTERVAL) {
this.aoe_timer = 0;
let skill = this.aoe_queues[0];
this.aoe_skill_execute(skill);
skill.count--;
if (skill.count <= 0) {
this.aoe_queues.shift(); // 移除已完成的技能
console.log("[FightConComp]:aoe_queues:",this.aoe_queues)
// 遍历所有技能,更新它们的计时器
for (let i = this.aoe_queues.length - 1; i >= 0; i--) {
let skill = this.aoe_queues[i];
let timer = this.aoe_timers.get(skill.id) || 0;
timer += deltaTime;
this.aoe_timers.set(skill.id, timer);
// 检查是否到达执行间隔
if (timer >= this.AOE_INTERVAL) {
// 重置计时器
this.aoe_timers.set(skill.id, 0);
// 执行技能
this.aoe_skill_execute(skill);
skill.count--;
// 如果技能执行完毕,从队列中移除
if (skill.count <= 0) {
this.aoe_queues.splice(i, 1);
this.aoe_timers.delete(skill.id);
}
}
}
}