Esempio n. 1
0
    //bool buyMode = false;

    // Start is called before the first frame update
    private void Awake()
    {
        if (instance != null)
        {
            Destroy(gameObject);
        }
        instance = this;
        curState = stateSet;
    }
Esempio n. 2
0
    public void Init()
    {
        GameActionResolver = GameObject.FindGameObjectWithTag("actionResolver").GetComponent<ActionResolver>();

        //Initialize the state dictionary in memory
        StateDictionary = new Dictionary<Enums.GameStates, State_Base>();

        StateDictionary.Add(Enums.GameStates.gamestate_waitingForCommand, new State_WaitingForCommand());
        StateDictionary.Add(Enums.GameStates.gamestate_SelectActionMenu, new State_ActionSelectMenu());

        CurrentState = StateDictionary[Enums.GameStates.gamestate_waitingForCommand];
    }
Esempio n. 3
0
 void Start()
 {
     currBoard   = BoardMaker.MakeBoard(Data.instance.currBoard);
     turretBoard = new BoardNode[currBoard.GetLength(0), currBoard.GetLength(1)];
     BoardMaker.MakeTurretBoard(new Vector2Int(currBoard.GetLength(0), currBoard.GetLength(1)));
     blockerHolder = new GameObject("Blockers").GetComponent <Transform>();
     baseHolder    = new GameObject("AllYourBASE").GetComponent <Transform>();
     SpawnerHolder = new GameObject("Spawners").GetComponent <Transform>();
     PathHolder    = new GameObject("Pathways").GetComponent <Transform>();
     SetupForTesting();
     UpdateText();
     curState = stateGame;
 }
Esempio n. 4
0
    //Whenever the game is paused, this function will be called
    protected void OnPause()
    {
        //pause the current Animation
        m_animator.speed = Clock.TimeScale;

        //save the previous state, so the character will return to the state when the game the is resumed
        m_previousState = m_stateMachine.CurrentState;

        //set the current state to the pause state
        m_stateMachine.SetCurrentState(m_pauseState);

        //set the paused boolean to be true
        m_isPaused = true;
    }
    public void SetCurrentState(State_Base newState)
    {
        if (m_currentState != null)
        {
            m_currentState.ExitState();
        }

        m_currentState = newState;

        if (m_currentState != null)
        {
            m_currentState.EnterState();
        }
    }
Esempio n. 6
0
 public void MoveToNextState(Enums.GameStates _nextState, GameObject _object)
 {
     CurrentState.ExitState(_object);
     switch(_nextState)
     {
         case Enums.GameStates.gamestate_waitingForCommand:
             CurrentState = StateDictionary[Enums.GameStates.gamestate_waitingForCommand];
             break;
         case Enums.GameStates.gamestate_SelectActionMenu:
             CurrentState = StateDictionary[Enums.GameStates.gamestate_SelectActionMenu];
             break;
     }
     CurrentState.EnterState(_object);
 }
Esempio n. 7
0
    protected void OnUnPause()
    {
        //set the current state to the state that the character was in before the game was paused
        m_stateMachine.SetCurrentState(m_previousState);

        //set the previous state to null
        m_previousState = null;

        //set the paused boolean to be false
        m_isPaused = false;

        //unpause the current Animation
        m_animator.speed = Clock.TimeScale;

        m_motor.UnlockMotion();
    }
Esempio n. 8
0
 public void ChangeState(State_Base newState)
 {
     currentState?.Exit();
     currentState = newState;
     currentState.Enter();
 }