This commit is contained in:
walkpan
2025-02-01 00:14:25 +08:00
parent c5c01c6cf4
commit bffbb9077e
91 changed files with 2067 additions and 1327 deletions

View File

@@ -0,0 +1,37 @@
import { ecs } from "../../../../../extensions/oops-plugin-framework/assets/libs/ecs/ECS";
/** 战斗组件 */
@ecs.register('Combat')
export class Combat extends ecs.Comp {
/** 攻击力 */
attackPower: number = 10;
/** 攻击范围(像素) */
attackRange: number = 100;
/** 攻击间隔(秒) */
attackInterval: number = 1;
/** 当前攻击计时 */
attackTimer: number = 0;
/** 攻击目标 */
target: ecs.Entity | null = null;
init(attack: number, range: number) {
this.attackPower = attack;
this.attackRange = range;
}
/** 攻击结束回调 */
onAttackEnd() {
// 重置攻击目标
this.target = null;
// 触发攻击结束事件
oops.message.dispatch('AttackEnd', this.ent);
}
reset() {
this.attackPower = 10;
this.attackRange = 100;
this.attackInterval = 1;
this.attackTimer = 0;
this.target = null;
}
}