dd
This commit is contained in:
37
assets/script/game/component/hero/Combat.ts
Normal file
37
assets/script/game/component/hero/Combat.ts
Normal 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;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user