public TeamSelectPlayerState(Player _player)
        {
            selectedTeam = Team.Auto;

            currentState = state.team_select;

            nextState = null;

            player = _player;
            player.TeamNotSet = true;

            cameraPosition = new Vector3(0, 75000, 0);
            cameraView = new Vector3(0, 0, 0);
            cameraUp = new Vector3(0, 0, 1);

            player.PlayerCamera.setViewMatrix(cameraPosition, cameraView, cameraUp);

            player.PlayerHUD.InitializeGraphics();

            player.PlayerShip = null;

            switch ( Space394Game.GameInstance.NumberOfPlayers)
            {
                case 1:
                    box = new AutoTexture2D(ContentLoadManager.loadTexture("Textures/Screens/team_select"), new Vector2(142, 418));
                    break;
                case 2:
                    box = new AutoTexture2D(ContentLoadManager.loadTexture("Textures/Screens/team_select"), new Vector2(142, 418));
                    break;
                case 3:
                    box = new AutoTexture2D(ContentLoadManager.loadTexture("Textures/Screens/team_select"), new Vector2(142, 418));
                    break;
                case 4:
                    box = new AutoTexture2D(ContentLoadManager.loadTexture("Textures/Screens/team_select"), new Vector2(142, 418));
                    break;

            }

            esxolus = new AutoTexture2D(ContentLoadManager.loadTexture("Textures/Screens/team_select_esx"), new Vector2(142, 281));
            halk = new AutoTexture2D(ContentLoadManager.loadTexture("Textures/Screens/team_select_halk"), new Vector2(538, 280));
            auto = new AutoTexture2D(ContentLoadManager.loadTexture("Textures/Screens/team_select_auto"), new Vector2(352, 272));
            spectate = new AutoTexture2D(ContentLoadManager.loadTexture("Textures/Screens/team_select_spectate"), new Vector2(343, 348));

            esxolusLit = new AutoTexture2D(ContentLoadManager.loadTexture("Textures/Screens/team_select_esx_lit"), new Vector2(142, 281));
            halkLit = new AutoTexture2D(ContentLoadManager.loadTexture("Textures/Screens/team_select_halk_lit"), new Vector2(538, 280));
            autoLit = new AutoTexture2D(ContentLoadManager.loadTexture("Textures/Screens/team_select_auto_lit"), new Vector2(352, 272));
            spectateLit = new AutoTexture2D(ContentLoadManager.loadTexture("Textures/Screens/team_select_spectate_lit"), new Vector2(343, 348));

            LogCat.updateValue("PlayerState", "TeamSelect");
        }
 public Player(ControllerIndex _number)
 {
     justUnpaused = false;
     isPaused = false;
     teamNotSet = true;
     number = _number;
     if (_number != ControllerIndex.Keyboard)
     {
         keyboardControlled = false;
     }
     else
     {
         keyboardControlled = true;
     }
     playerCamera = null;
     currentState = new MenuPlayerState(this);
     playerHUD = new PlayerHUD(this);
     playerHUDActive = false;
     objectivesDrawActive = true;
     pausedState = new PausedPlayerState(this);
 }
        public void Update(float deltaTime)
        {
            if (!isPaused)
            {
                currentState.ProcessInput();
                justUnpaused = false;
            }
            else
            {
                pausedState.ProcessInput();
            }

            currentState.Update(deltaTime);
            if (isPaused)
            {
                pausedState.Update(deltaTime);
            }
            else { }

            LogCat.updateValue("Player Paused", ""+isPaused);

            if (playerCamera != null)
            {
                PlayerCamera.Update(deltaTime);
                SoundManager.setListenerLocation(PlayerCamera.Position);
            }
            else { }

            if (playerHUDActive)
            {
                playerHUD.Update(deltaTime);
            }
            else { }

            if (currentState.StateComplete)
            {
                currentState = currentState.getNextState(this);
            }
            else { }
        }
 public PlayerState nextState()
 {
     currentState = currentState.getNextState(this); return currentState;
 }
        public override void Update(float deltaTime)
        {
            if (playerShip != null)
            {
                if (playerShip.JustReflected)
                {
                    lockCamera();
                }
                else { }

                // Init happens before positions are set in the game scene
                if (camPosSet == false)
                {
                    player.PlayerCamera.playerInit(new Vector3(0.0f, 0.0f, 0.15f), player);
                    setViewNoMove();
                    camPosSet = true;
                }

                if (!player.IsPaused)
                {
                    ProcessInput(deltaTime);
                }
                else { }

                if (playerShip.Health <= 0)
                {
                    StateComplete = true;
                    if (((GameScene)Space394Game.GameInstance.CurrentScene).CurrentState ==
                        GameScene.state.victory)
                    {
                        nextState = new ScoreboardPlayerState(player);
                    }
                    else
                    {
                        nextState = new DyingPlayerState(player);
                    }
                }
                else { }

                if (playerShip.Health > 0 && !((CollisionSphere)playerShip.CollisionBase).isCollidingSq(leavingSphere))
                {
                    StateComplete = true;
                    nextState = new TurningAroundPlayerState(player);
                }
                else { }

                cameraLock -= deltaTime;
                if (cameraLock <= 0)
                {
                    if (cameraPositionOffset != defaultOffset)
                    {
                        cameraPositionOffset = defaultOffset;
                    }
                    else { }
                }
                else
                {
                    cameraPositionOffset.Z += bounceZ * deltaTime;
                }

                setView(deltaTime);
            }
            else { } // No ship
        }
        public override void ProcessInput()
        {
            if (Space394Game.GameInstance.CurrentScene is GameScene)
            {
                if (InputManager.isCombinedUpCombinedStickPressed(player.PlayerNumber))
                {
                    selectedTeam = Team.Auto;
                }
                else if (InputManager.isCombinedDownCombinedStickPressed(player.PlayerNumber))
                {
                    selectedTeam = Team.Spectate;
                }
                else { }
                switch (selectedTeam)
                {
                    case Team.Auto:
                        if (InputManager.isCombinedLeftCombinedStickPressed(player.PlayerNumber))
                        {
                            selectedTeam = Team.Esxolus;
                            //selectorPosition = esxolusPosition;
                        }
                        else if (InputManager.isCombinedRightCombinedStickPressed(player.PlayerNumber))
                        {
                            selectedTeam = Team.Halk;
                            //selectorPosition = halkPosition;
                        }
                        else { }
                        break;

                    case Team.Esxolus:
                        if (InputManager.isCombinedLeftCombinedStickPressed(player.PlayerNumber))
                        {
                            selectedTeam = Team.Halk;
                            //selectorPosition = halkPosition;
                        }
                        else if (InputManager.isCombinedRightCombinedStickPressed(player.PlayerNumber))
                        {
                            selectedTeam = Team.Auto;
                            //selectorPosition = autoPosition;
                        }
                        else { }
                        break;

                    case Team.Halk:
                        if (InputManager.isCombinedLeftCombinedStickPressed(player.PlayerNumber))
                        {
                            selectedTeam = Team.Auto;
                            //selectorPosition = autoPosition;
                        }
                        else if (InputManager.isCombinedRightCombinedStickPressed(player.PlayerNumber))
                        {
                            selectedTeam = Team.Esxolus;
                            //selectorPosition = esxolusPosition;
                        }
                        else { }
                        break;

                    case Team.Spectate:
                        if (InputManager.isCombinedLeftCombinedStickPressed(player.PlayerNumber))
                        {
                            selectedTeam = Team.Esxolus;
                            //selectorPosition = esxolusPosition;
                        }
                        else if (InputManager.isCombinedRightCombinedStickPressed(player.PlayerNumber))
                        {
                            selectedTeam = Team.Halk;
                            //selectorPosition = halkPosition;
                        }
                        else if (InputManager.isCombinedUpCombinedStickPressed(player.PlayerNumber))
                        { }
                        break;
                }
                //selector.setPosition(selectorPosition);

                if (InputManager.isCombinedConfirmPressed(player.PlayerNumber)
                    || InputManager.isCombinedPrimaryFirePressed(player.PlayerNumber))
                {
                    switch (selectedTeam)
                    {
                        case Team.Auto:
                            if (((GameScene)Space394Game.GameInstance.CurrentScene).EsxolusPlayers <
                                ((GameScene)Space394Game.GameInstance.CurrentScene).HalkPlayers)
                            {
                                player.CurrentTeam = Ship.Team.Esxolus;
                            }
                            else if (((GameScene)Space394Game.GameInstance.CurrentScene).EsxolusPlayers >
                                ((GameScene)Space394Game.GameInstance.CurrentScene).HalkPlayers)
                            {
                                player.CurrentTeam = Ship.Team.Halk;
                            }
                            else
                            {
                                Random random = new Random(System.DateTime.Now.Millisecond);
                                switch (random.Next() % 2)
                                {
                                    case 0:
                                        player.CurrentTeam = Ship.Team.Esxolus;
                                        break;
                                    case 1:
                                        player.CurrentTeam = Ship.Team.Halk;
                                        break;
                                }
                            }
                            player.TeamNotSet = false;
                            break;
                        case Team.Esxolus:
                            player.CurrentTeam = Ship.Team.Esxolus;
                            player.TeamNotSet = false;
                            break;
                        case Team.Halk:
                            player.CurrentTeam = Ship.Team.Halk;
                            player.TeamNotSet = false;
                            break;
                        case Team.Spectate:
                            nextState = new SpectatorPlayerState(player);
                            break;
                    }
                    StateComplete = true;
                }
                else { }

                if (InputManager.isCombinedPausePressed(player.PlayerNumber))
                {
                    player.pause();
                }
                else { }
            }
            else { } // Still loading
        }
 public override PlayerState getNextState(Player _player)
 {
     OnExit();
     if (nextState == null)
     {
         if ((GameScene)Space394Game.GameInstance.CurrentScene is GameScene)
         {
             if (((GameScene)Space394Game.GameInstance.CurrentScene).getSpawnPointsRemaining(_player.CurrentTeam) <= 0)
             {
                 // player.getPlayerHUD().InitializeHUDTeam();
                 nextState = new ScoreboardPlayerState(_player);
             }
             else
             {
                 // player.getPlayerHUD().InitializeHUDTeam();
                 nextState = new SpawnSelectPlayerState(_player);
             }
         }
         else
         {
             nextState = this;
         }
     }
     else { }
     return nextState;
 }
        public override void Update(float deltaTime)
        {
            if (!ready)
            {
                Vector3 position = Vector3.Transform(getSpawnShips()[index].CameraPositions[(int)currentShip], getSpawnShips()[index].Rotation) + getSpawnShips()[index].Position;
                Vector3 target = Vector3.Transform(getSpawnShips()[index].CameraViews[(int)currentShip], getSpawnShips()[index].Rotation) + getSpawnShips()[index].Position;
                Vector3 up = Vector3.Transform(getSpawnShips()[index].CameraUps[(int)currentShip], getSpawnShips()[index].Rotation);

                player.PlayerCamera.setViewMatrix(position, target, up);
            }
            else { }

            modelRotation += ROTATION_SPEED * deltaTime;

            if (getSpawnShips()[index].Health <= 0 || rememberedSpawnShipNumber != getSpawnShips().Count)
            {
                ready = false;
                selectingShip = true;
                index = 0;
                while (index < getSpawnShips().Count
                && getSpawnShips()[index].ShipTeam != player.CurrentTeam) // They must have a ship, but just in case
                {
                    index++;
                }
                if (index == getSpawnShips().Count)
                {
                    // Nothing found
                    nextState = new ScoreboardPlayerState(player);
                    StateComplete = true;
                }
                else { }
            }
            else { }

            if (ready && ((GameScene)Space394Game.GameInstance.CurrentScene).WaveReleased)
            {
                nextState = new SpawningPlayerState(player);
                StateComplete = true;
            }
            else { }
        }