public static void ChangeGameState(bool successful) { if (OnGameStateChange != null) { OnGameStateChange.Invoke(successful); } }
private void Start() { Cursor.visible = false; cursor.SetActive(false); // Broadcast "playing" to everyone that's subscribed on start of game OnGameStateChange?.Invoke(playing); }
/// <summary> /// Sets the new game state and triggers the event. /// </summary> /// <param name="state"></param> private void SetGameState(GameState state) { OnGameStateChange?.Invoke(this, new GameStateEvent { CurrentState = state, PreviousState = State }); State = state; }
private void SetGameState(GameState gameState) { this.gameState = gameState; OnGameStateChange?.Invoke(gameState); Time.timeScale = (gameState == Running) ? 1f : 0f; loadingCanvas.SetActive(gameState == Loading); }
private void Awake() { activeGameState = GameState.PREGAME; lastGameState = GameState.PREGAME; inSelectionMenu = true; OnGameStateChange?.Invoke(activeGameState); }
public static void TriggerGameStateChange() { if (OnGameStateChange != null) { OnGameStateChange.Invoke(GameManager.instance.gameState); } }
public static void ChangeGameState(GameState newState, GameState previousState) { OnGameStateChange?.Invoke(newState, previousState); if (Debug.isDebugBuild) { Debug.Log("State switched from " + previousState + " to " + newState); } }
private void GameStateChange(EGameState newState) { EGameState previous = _currentGameState; _currentGameState = newState; OnGameStateChange?.Invoke(new GameStateChangeArgs(previous, _currentGameState)); }
void ChangeState(GameState state) { if (this.state == state) { return; } this.state = state; OnGameStateChange?.Invoke(state); }
private void Tile_OnPlayerAction(GameState lastGameState) { if (lastGameState == GameState.PLAYERX) { activeGameState = GameState.PLAYERO; OnGameStateChange?.Invoke(activeGameState); } else if (lastGameState == GameState.PLAYERO) { activeGameState = GameState.PLAYERX; OnGameStateChange?.Invoke(activeGameState); } //Check For WIN STATES if (CheckForWin(lastGameState) == Player.O) { activeGameState = GameState.WINO; OnGameStateChange?.Invoke(activeGameState); OnRoundEnd.Invoke(Player.O); StartCoroutine(SetUpNextRound(Player.O)); } else if (CheckForWin(lastGameState) == Player.X) { activeGameState = GameState.WINX; OnGameStateChange?.Invoke(activeGameState); OnRoundEnd.Invoke(Player.X); StartCoroutine(SetUpNextRound(Player.X)); } //Check for TIE else if (CheckForWin(lastGameState) == Player.None) { bool isTie = true; foreach (Tile tile in tiles) { if (tile.affiliation == Player.None) { isTie = false; } } if (isTie) { OnRoundEnd.Invoke(Player.None); activeGameState = GameState.TIE; OnGameStateChange?.Invoke(activeGameState); StartCoroutine(SetUpNextRound(Player.None)); } } if (lastGameState == GameState.PLAYERO || lastGameState == GameState.PLAYERX) { lastPlayerAction = (lastGameState == GameState.PLAYERO) ? GameState.PLAYERX : GameState.PLAYERO; } }
IEnumerator SetUpGameAndTiles() { aiGameState = (player == GameState.PLAYERO) ? GameState.PLAYERX : GameState.PLAYERO; if (player == GameState.PLAYERX) { playerWin = GameState.WINX; } else if (player == GameState.PLAYERO) { playerWin = GameState.WINO; } for (int j = 1; j >= -1; j--) { for (int i = -1; i < Mathf.Sqrt(tiles.Length) - 1; i++) { tiles[i + 1, j + 1] = Instantiate(Tile, canvas).GetComponent <Tile>(); tiles[i + 1, j + 1].gameObject.transform.localPosition = new Vector3((float)(dist * i), (float)(dist * j), 0f); tiles[i + 1, j + 1].gameObject.SetActive(false); if (showDebugTileIndex) { tiles[i + 1, j + 1].SetUpTile($"{i + 1} | {j + 1}"); } else { tiles[i + 1, j + 1].SetUpTile(); } } } yield return(new WaitForEndOfFrame()); OnTilesLoaded?.Invoke(); //Invokes a function when all Tiles are loaded to prevent other scripts, depending on the tiles from gettin null refferences for (int j = 1; j >= -1; j--) { for (int i = -1; i < Mathf.Sqrt(tiles.Length) - 1; i++) { tiles[i + 1, j + 1].gameObject.SetActive(true); yield return(new WaitForSeconds(setUpTimer)); } } foreach (Tile tile in tiles) { tile.OnPlayerAction += Tile_OnPlayerAction; } inSelectionMenu = false; activeGameState = GameState.PLAYERX; OnGameStateChange?.Invoke(activeGameState); }
private void OnLifeChange(int life) { // If the player is dead, set the game state to false if (life <= 0) { Instantiate(particle, player.transform.position, Quaternion.identity); source.clip = playerDeath; source.Play(); Destroy(player.gameObject); timeStamp = Time.time; playing = false; // Broadcast "playing" to everyone that's subscribed after the player died OnGameStateChange?.Invoke(playing); } }
public void SetState(GameState newState) { if (newState != GameState) { GameState lastState = GameState; GameState = newState; if (GameState == GameState.Paused) { Time.timeScale = 0; } else if (GameState == GameState.Running) { Time.timeScale = 1; } OnGameStateChange?.Invoke(lastState, GameState); } }
public void UpdateState(GameState state) { GameState previousState = _currentState; _currentState = state; switch (currentState) { case GameState.PAUSED: Time.timeScale = 0; break; default: Time.timeScale = 1; break; } OnGameStateChange.Invoke(previousState, _currentState); }
public void ChangeState(EGameStates NewGameState) { gameState = NewGameState; OnGameStateChange?.Invoke(gameState); switch (gameState) { case EGameStates.Waiting: break; case EGameStates.Gameplay: break; case EGameStates.RoundOver: StartCoroutine(ChangeNextLevel()); break; case EGameStates.GameOver: break; default: break; } }
public void BeginNewGameState(GameStates newGameState) { switch (newGameState) { case GameStates.MainPowerOn: currentGameState = newGameState; OnGameStateChange?.Invoke(newGameState); break; case GameStates.MainPowerOff: currentGameState = newGameState; if (LightManager.instance && TransitionManager.instance.GetCurrentLevel() != SceneIndex.IceRink) { LightManager.instance.SetChargeState(ChargeStates.Discharging); } OnGameStateChange?.Invoke(newGameState); break; case GameStates.LevelClear: currentGameState = newGameState; InitStateManager.instance.BeginNewState(InitStates.LevelClear); OnGameStateChange?.Invoke(newGameState); break; case GameStates.TasksCompleted: currentGameState = newGameState; OnGameStateChange?.Invoke(newGameState); break; } }
// ============================================================================================================= #endregion #region MISC // ============================================================================================================= /// <summary> /// Set game state, it will affect all units and buildings. /// </summary> /// <param name="gState"></param> private void SetGameState(GameState gState) { Debug.Log("Game state changed: " + gState); gameState = gState; OnGameStateChange?.Invoke(gameState); }
private void PlayerWon() { Debug.Log("game over - player won"); OnGameStateChange?.Invoke(GameState.Won); }
public void ChangeGameState(EGameStates NewGameState) { gameStates = NewGameState; OnGameStateChange?.Invoke(gameStates); }
private IEnumerator SetUpNextRound(Player lastWinner) { yield return(new WaitForSeconds(1f)); activeGameState = GameState.PRETURN; OnGameStateChange?.Invoke(activeGameState); //Deactivate and reset TILES for (int j = 1; j >= -1; j--) { for (int i = -1; i < Mathf.Sqrt(tiles.Length) - 1; i++) { tiles[i + 1, j + 1].gameObject.SetActive(false); if (showDebugTileIndex) { tiles[i + 1, j + 1].SetUpTile($"{i + 1} | {j + 1}"); } else { tiles[i + 1, j + 1].SetUpTile(); } } } //for (int j = 1; j >= -1; j--) //{ // for (int i = -1; i < Mathf.Sqrt(tiles.Length) - 1; i++) // { // tiles[i + 1, j + 1].gameObject.SetActive(true); // yield return new WaitForSeconds(setUpTimer); // } //} //Reactivate TILES in a certain order tiles[1, 1].gameObject.SetActive(true); yield return(new WaitForSeconds(setUpTimer * 2)); tiles[1, 2].gameObject.SetActive(true); tiles[0, 1].gameObject.SetActive(true); tiles[1, 0].gameObject.SetActive(true); tiles[2, 1].gameObject.SetActive(true); yield return(new WaitForSeconds(setUpTimer * 2)); tiles[0, 2].gameObject.SetActive(true); tiles[0, 0].gameObject.SetActive(true); tiles[2, 2].gameObject.SetActive(true); tiles[2, 0].gameObject.SetActive(true); yield return(new WaitForSeconds(setUpTimer * 2)); //Set new Gamestate if (lastWinner == Player.X) { activeGameState = GameState.PLAYERO; } else if (lastWinner == Player.O) { activeGameState = GameState.PLAYERX; } else { activeGameState = lastPlayerAction; } OnGameStateChange(activeGameState); }
public void ChangeGameState(GameState gameState) { CurrentState = gameState; OnGameStateChange?.Invoke(gameState); }
private void OnEnable() { gameStateChanged += GameMatControlsDelegate; }
private void OnDisable() { gameStateChanged -= GameMatControlsDelegate; }
public static void ReportGameStateChange(GameState _gameState) { OnGameStateChange?.Invoke(_gameState); }
private void EnemyController_OnEnemyDie(Enemy obj) { sectionService.Points += pointsEnemyDead; OnGameStateChange?.Invoke(this, GetGameStateData()); }
void HandleGameStateChange(OnGameStateChange e) => IsCanMove = (e.NewState == GameState.WAIT || e.NewState == GameState.ACTION);