private ITowerState m_currentState; // Holds the current state #endregion #region Unity Functions private void Start() { m_attackRadius = m_towerAsset.AttackRadius; m_cooldown = m_towerAsset.Cooldown; m_health = m_towerAsset.Heath; m_currentState = new TowerStateAttack(this); m_projectile = m_towerAsset.projectile; }
private void Update() { var newState = _state.Update(); if (newState != null) { _state = newState; } }
public void SwitchState(ITowerState state) // Switch the state of the tower, give new class of the state { m_currentState.End(); // Call the end of the current state m_currentState = state; // Switch the state m_currentState.Start(); // Call the start of the new state }