void Start() { //find gamemanager from scene gameManager = FindObjectOfType <GameManager>(); currentState = new StandingPlayerState(); currentLevelState = new PlayingState(); }
private void Start() { NavMeshAgent agent = (TryGetComponent <NavMeshAgent>(out NavMeshAgent agentResult)) ? agentResult : gameObject.AddComponent <NavMeshAgent>(); iStates newIdleState = new IdleState(this, idleTime.Value); iStates newPatrolState = new PatrolState(this, enemyRigidbody, agent, patrolTime.Value, patrolSwitchProbability.Value, enemySightRadius.Value); iStates newAttackState = new AttackState(this, enemyRigidbody, agent, chaseVelocity.Value, enemySightRadius.Value, enemySpeed.Value); _map.Add(Global.IdleState, newIdleState); _map.Add(Global.PatrolState, newPatrolState); _map.Add(Global.AttackState, newAttackState); _currentState = newIdleState; }
public void ChangeState(string state) { _currentState.OnExit(); _currentState = _map[state]; _currentState.OnEnter(); }