feat(map): 新增任务技能面板并优化技能触发逻辑
- 新增 mskills.prefab 作为任务技能容器 - 将 MissSkillsComp 挂载到场景实体层,移除 MissionCardComp 中的引用 - 优化 SkillBoxComp 触发坐标计算,改为基于父节点位置 - 调整技能盒尺寸并添加等级标签显示 - 修复战斗开始时技能触发计时器重置逻辑
This commit is contained in:
@@ -47,6 +47,7 @@ export class SkillBoxComp extends CCComp {
|
||||
}
|
||||
|
||||
init(uuid: number, card_lv: number) {
|
||||
// this.node.parent=smc.map.MapView.scene.entityLayer!.node!
|
||||
this.s_uuid = uuid;
|
||||
this.card_lv = card_lv;
|
||||
|
||||
@@ -104,7 +105,9 @@ export class SkillBoxComp extends CCComp {
|
||||
this.in_combat = true;
|
||||
|
||||
if (!this.is_instant) {
|
||||
this.timer = this.trigger_interval; // 确保第一次能立即或按间隔触发
|
||||
// 战斗开始时,计时归0,重新计时
|
||||
this.timer = 0;
|
||||
// 如果这个技能每回合都可以触发 t_times 次,则在每回合开始时重置当前回合触发次数
|
||||
this.current_trigger_times = 0;
|
||||
}
|
||||
}
|
||||
@@ -141,7 +144,7 @@ export class SkillBoxComp extends CCComp {
|
||||
if (this.current_trigger_times < this.trigger_times) {
|
||||
this.timer += dt;
|
||||
if (this.timer >= this.trigger_interval) {
|
||||
this.timer = 0;
|
||||
this.timer = 0; // 触发后重新计时
|
||||
this.triggerSkill();
|
||||
this.current_trigger_times++;
|
||||
}
|
||||
@@ -149,8 +152,13 @@ export class SkillBoxComp extends CCComp {
|
||||
}
|
||||
|
||||
private triggerSkill() {
|
||||
// 使用固定的全局坐标
|
||||
const targetPos = new Vec3(-340, 30, 0);
|
||||
// 获取自身在父节点下的局部坐标
|
||||
// UI 的局部坐标在 2D 相机中和实际的游戏逻辑坐标存在偏移关系,
|
||||
// 可以结合自身局部坐标做一次偏移,此处直接读取自身的 localPosition 加上父节点的偏移
|
||||
let targetPos = new Vec3();
|
||||
const localPos = this.node.position;
|
||||
const parentPos = this.node.parent ? this.node.parent.position : new Vec3(0, 0, 0);
|
||||
targetPos.set(parentPos.x + localPos.x, parentPos.y + localPos.y, 0);
|
||||
|
||||
oops.message.dispatchEvent(GameEvent.TriggerSkill, {
|
||||
s_uuid: this.s_uuid,
|
||||
|
||||
Reference in New Issue
Block a user