推进计时器逻辑的集中管理
- 将敌人的攻击计时任务放到基类中进行创建 - 将 EnemySpawnScheduler 敌人生成调度器的刷怪计时任务迁移到 TimerComponent
This commit is contained in:
@@ -1,7 +1,6 @@
|
||||
using SepCore.Components;
|
||||
using SepCore.CustomUtility;
|
||||
using SepCore.Definition;
|
||||
using SepCore.Timer;
|
||||
using UnityEngine;
|
||||
using UnityGameFramework.Runtime;
|
||||
|
||||
@@ -24,8 +23,6 @@ namespace SepCore.Entity
|
||||
private int _attackDamage = 1;
|
||||
|
||||
private float _sqrAttackRange;
|
||||
private TimerHandle _attackTimerHandle;
|
||||
private bool _canAttack;
|
||||
|
||||
private AttackStateType _attackState = AttackStateType.Idle;
|
||||
|
||||
@@ -71,8 +68,7 @@ namespace SepCore.Entity
|
||||
_attackDamage = Mathf.Max(1, _meleeEnemyData.AttackDamage);
|
||||
_sqrAttackRange = _attackRange * _attackRange;
|
||||
|
||||
_canAttack = false;
|
||||
_attackTimerHandle = GameEntry.Timer.ScheduleOnce(_attackCooldown, () => _canAttack = true, this);
|
||||
StartAttackCooldown(_attackCooldown);
|
||||
_attackState = AttackStateType.Idle;
|
||||
_targetableTarget = null;
|
||||
|
||||
@@ -96,8 +92,7 @@ namespace SepCore.Entity
|
||||
_movementComponent.OnReset();
|
||||
_healthComponent.OnReset();
|
||||
_targetableTarget = null;
|
||||
GameEntry.Timer.Cancel(_attackTimerHandle);
|
||||
_attackTimerHandle = TimerHandle.Invalid;
|
||||
CancelAttackCooldown();
|
||||
_attackState = AttackStateType.Idle;
|
||||
|
||||
base.OnHide(isShutdown, userData);
|
||||
@@ -155,8 +150,7 @@ namespace SepCore.Entity
|
||||
|
||||
if (_canAttack)
|
||||
{
|
||||
_canAttack = false;
|
||||
_attackTimerHandle = GameEntry.Timer.ScheduleOnce(_attackCooldown, () => _canAttack = true, this);
|
||||
ResetAttackCooldown(_attackCooldown);
|
||||
TransitionTo(AttackStateType.Attack);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user