public bool PerformTransition(GameModeStateType targetState) { if (!CurrentGameModeState.CheckTransition(targetState)) { Debug.LogWarning(targetState + " is currently not a valid state."); return(false); } bool result = false; GameModeStateBase state = GetStateByType(targetState); if (state != null) { SetState(CurrentGameModeState, state); result = true; } else { Debug.LogError(targetState + " mode object is missing."); } return(result); }
private void StartGameMode(GameModeStateType gameMode) { GameManager.Instance.StateManager. PerformTransition(gameMode); Debug.Log("Starting game mode: " + gameMode.ToString()); }
/// <summary> /// This method instructs the ToyElevatorController to start a specific game mode. /// </summary> /// <param name="gameModeStateType">The type of GameModeStateType that is to be started.</param> public void StartGameMode(GameModeStateType gameModeStateType) { if (gameModeStateType == GameModeStateType.Sampo) { _currentGameModeState = GameModeStateType.Sampo; _sampo.SetActive(true); RaiseElevator(); } }
/// <summary> /// Adds a new target state to the target state /// list if it isn't on the list already. /// </summary> /// <param name="targetState">A target state to /// be added to the target state list</param> /// <returns>Was the state added to the list</returns> public bool AddTransition(GameModeStateType targetState) { // Attempts to add a target state. // Will return false if the state was already added. if (TargetStates.Contains(targetState)) { return(false); } else { TargetStates.Add(targetState); return(true); } }
private GameModeStateBase GetStateByType(GameModeStateType stateType) { // Returns the first object from the state list whose State // property's value equals to stateType. If no object was found, // null is returned. foreach (GameModeStateBase state in _gameModeStates) { if (state.State == stateType) { return(state); } } return(null); // Does the same as all of the previous lines //return _screenStates.FirstOrDefault // (state => state.State == stateType); }
private void SetState(StateBase currentState, StateBase newState) { ScreenStateBase screenState = newState as ScreenStateBase; GameModeStateBase gameModeState = newState as GameModeStateBase; if (currentState != null) { currentState.Deactivate(); } if (screenState != null) { //CurrentScreenState.Deactivate(); CurrentScreenState = screenState; CurrentScreenState.Activate(); if (ScreenStateChanged != null) { ScreenStateChanged(screenState.State); } // Debugging _screen = CurrentScreenState.State; } else if (gameModeState != null) { //CurrentGameModeState.Deactivate(); CurrentGameModeState = gameModeState; CurrentGameModeState.Activate(); // Debugging _gameMode = CurrentGameModeState.State; } //Debug.Log("Changed from " + currentState + " to " + newState); }
/// <summary> /// Checks if the target state is on the target state list. /// </summary> /// <param name="targetState">A target state</param> /// <returns>Is the target state on the target state list</returns> public virtual bool CheckTransition(GameModeStateType targetState) { return(TargetStates.Contains(targetState)); }
/// <summary> /// Removes a target state from the target /// state list if it is on the list. /// </summary> /// <param name="targetState">A target state to /// be removed from the target state list</param> /// <returns>Was the state removed from the list</returns> public bool RemoveTransition(GameModeStateType targetState) { return(TargetStates.Remove(targetState)); }
public GameModeStateBase(StateManager owner, GameModeStateType state) : base(owner) { TargetStates = new List <GameModeStateType>(); State = state; }
//public bool _debugSampoModeStart = false; private void Start() { _currentGameModeState = GameModeStateType.Normal; _currentToyElevatorState = ToyElevatorState.Start; }