Exemple #1
0
        // Drop-out
        public void SubtractPlayer() // here *** so refactor this then refactor the above, [AddPlayer()]
        {
            int numPlayers = GameVariables.NumPlayers;

            if (numPlayers < 2)
            {
                return;
            }

            PlayerIndex playerIndex;

            if (numPlayers > 3)
            {
                playerIndex = PlayerIndex.Four;
            }
            else if (numPlayers > 2)
            {
                playerIndex = PlayerIndex.Three;
            }
            else if (numPlayers > 1)
            {
                playerIndex = PlayerIndex.Two;
            }
            else
            {
                return;
            }

            Player player = entityManager.GetPlayerWithIndex(playerIndex);

            entityManager.Remove(player);
            PlayerRepresentation playerRepresentation = representationManager.GetPlayerRepresentationWithIndex(playerIndex);

            representationManager.Remove(playerRepresentation);
            PlayerController playerController = controllerManager.GetPlayerControllerWithIndex(playerIndex);

            controllerManager.Remove(playerController);

            player.Dispose();

            numPlayers--;
            GameVariables.NumPlayers = numPlayers;

            SetUpSplitScreen();
            ResetPlayerCameras();
        }