public void Start() { #region Validation if (this._status != GameStatus.ReadyToStart) { throw new InvalidOperationException("Only game with status 'ReadyToStart' can be started"); } #endregion /* * Review GY: рекомендую проставити фігурні дужки для оператора if */ if (GameStartedEvent == null) { throw new NullReferenceException(); } this._status = GameStatus.InProgress; /* * Review GY: метод Invoke викликається автоматично. * Викликати його явно не потрібно. */ GameStartedEvent.Invoke(); }
public void StartGame() { GameStartedEvent?.Invoke(); m_GamePanel.gameObject.SetActive(true); m_MenuPanel.gameObject.SetActive(false); p_HealthLeft = 10; m_HealthText.text = "Health Left: " + p_HealthLeft.ToString(); p_CurrentScore = 0; m_ScoreText.text = "Score: " + p_CurrentScore.ToString(); }
private void TryStartGame(bool force) { if (force || (PlayerManager.Players.Count >= RoomSettings.MinPlayers && PlayerManager.Players.GetCombinedStates() == ClientState.Ready)) { if (RoomSettings.CloseOnStarted) { RoomSettings.IsOpen = false; RoomSettings.IsVisible = false; } GameStartedEvent?.Invoke(); } }
public void setGameState(GameState newGameState) { if (newGameState.Equals(GameState.Playing)) { GameStartedEvent?.Invoke(); onStartActivated?.Invoke(); } if (newGameState.Equals(GameState.GameOver)) { GameEndedEvent?.Invoke(); onGameOverActivated?.Invoke(); } eGameState = newGameState; }
/// <summary> /// Starts a new game. /// </summary> /// <param name="gameParams">Parameters of the game.</param> public void StartGame(GameParameters gameParams) { // Init the game CurrentGameState.Params = gameParams; CurrentGameState.CurrentPlayerIndex = -1; CurrentGameState.CurrentPhase = GamePhase.BEFORE_START; _TileSetType = gameParams.TileSet; // Set correct tile supplier switch (_TileSetType) { case TileSetType.STANDARD: CurrentGameState.TileSupplier = new StandardTileSetSupplier(); break; case TileSetType.PASSIVE: CurrentGameState.TileSupplier = new PassiveTileSupplier(); break; case TileSetType.STANDARD_PASSIVE: CurrentGameState.TileSupplier = new StandardPassiveTileSetSupplier(); break; } // Add score records foreach (PlayerColor color in gameParams.PlayerOrder) { CurrentGameState.Scores.Add(color, 0); } // Notify that game has been started GameStartedEvent.Invoke(gameParams); if (_TileSetType != TileSetType.PASSIVE && _TileSetType != TileSetType.STANDARD_PASSIVE) { // Place the initial tile PlaceTile(PlayerColor.NONE, CurrentGameState.TileSupplier.GetFirst(), new Coords(0, 0), TileOrientation.N); } // Start next move StartNextMove(); }
private void InvokeStateEvents(GameStates state) { switch (state) { case GameStates.Menu: MainMenuEvent?.Invoke(); ClearEntities(); break; case GameStates.GenerateMap: GenerateMenuEvent?.Invoke(); ClearEntities(); break; case GameStates.PlayMap: PlayMapMenuEvent?.Invoke(); GameStartedEvent?.Invoke(); break; default: break; } }
protected virtual void OnGameStartedEvent() { GameStartedEvent?.Invoke(); }
public void GameStarted(int gameId) { GameStartedEvent?.Invoke(this, new GameStartedEventArgs(gameId)); }
/// <summary> /// Starts a two player game /// </summary> public void StartTwoPlayerGame() { AudioManager.Play(AudioClipName.MenuButtonClick); gameStartedEvent.Invoke((int)Difficulty.Medium, GameType.TwoPlayer); SceneManager.LoadScene("gameplay"); }
public void InvokeGameStarted() { GameStartedEvent?.Invoke(); InvokePauseLevel(false); //Unpausing }
/// <summary> /// invoke the event that signals the game has started /// </summary> public static void InvokeGameStartedEvent() { GameStartedEvent.Invoke(); }
public static void OnGameStartedEvent() { GameStartedEvent?.Invoke(); }