Example #1
0
        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();
        }
Example #2
0
    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();
    }
Example #3
0
        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();
            }
        }
Example #4
0
    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;
            }
        }
Example #7
0
 protected virtual void OnGameStartedEvent()
 {
     GameStartedEvent?.Invoke();
 }
 public void GameStarted(int gameId)
 {
     GameStartedEvent?.Invoke(this, new GameStartedEventArgs(gameId));
 }
Example #9
0
 /// <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
 }
Example #11
0
 /// <summary>
 /// invoke the event that signals the game has started
 /// </summary>
 public static void InvokeGameStartedEvent()
 {
     GameStartedEvent.Invoke();
 }
Example #12
0
 public static void OnGameStartedEvent()
 {
     GameStartedEvent?.Invoke();
 }