예제 #1
0
 void Start()
 {
     //find gamemanager from scene
     gameManager       = FindObjectOfType <GameManager>();
     currentState      = new StandingPlayerState();
     currentLevelState = new PlayingState();
 }
예제 #2
0
    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;
    }
예제 #3
0
 public void ChangeState(string state)
 {
     _currentState.OnExit();
     _currentState = _map[state];
     _currentState.OnEnter();
 }