public void Update(ref ApplicationState appState, InputState input, PlayerIndex[] controllingPlayer)
        {
            base.Update(input, controllingPlayer);
            if (gameOptions.IsTrial == true && addBuyOption == false)
            {
                options.Add("Unlock Full Game");
                addBuyOption = true;
            }
            if (gameOptions.IsTrial == false && addBuyOption == true)
            {
                options.Remove("Unlock Full Game");
            }

            switch (selectedIndex)
            {
                case 0: SetTransitionOut(ApplicationState.InitaliseGame);
                    break;
                case 1: SetTransitionOut(ApplicationState.Options);
                    break;
                case 2: SetTransitionOut(ApplicationState.Quit);
                    break;
                case 3: if (controllingPlayer[0].CanBuyGame()) { Guide.ShowMarketplace(controllingPlayer[0]); }
                    break;
            }
            appState = ReturnState(ApplicationState.Home);
        }
        public void Update(ref ApplicationState appState, InputState input, PlayerIndex[] controllingPlayer)
        {
            base.Update(input, controllingPlayer);

            if (gameOptions.IsTrial == false)
                {
                    appState = ApplicationState.LevelComplete;
                }

            if ((input.IsNewButtonPress(ButtonMappings.Pad_XBtn, controllingPlayer[0], out controllingPlayer[1]) ||
                    input.IsNewKeyPress(ButtonMappings.Keyboard_XBtn, controllingPlayer[0], out controllingPlayer[1])))
            {
                if (gameOptions.IsTrial == true)
                {
                    if (controllingPlayer[0].CanBuyGame())
                    {
                        Guide.ShowMarketplace(controllingPlayer[0]);
                    }
                }
            }

            if ((input.IsNewButtonPress(ButtonMappings.Pad_BBtn, controllingPlayer[0], out controllingPlayer[1]) ||
                    input.IsNewKeyPress(ButtonMappings.Keyboard_BBtn, controllingPlayer[0], out controllingPlayer[1])))
            {
                appState = ApplicationState.Quit;
            }
        }
 public void Update(int _finalLevel, int _finalScore, ref ApplicationState appState, InputState input, PlayerIndex[] controllingPlayer)
 {
     if (firstCall == true)
     {
         MediaPlayer.IsRepeating = true;
         MediaPlayer.Volume = gameOptions.MusicVolumeAtPlay;
         MediaPlayer.Play(mySong);
         firstCall = false;
     }
     finalLevel = _finalLevel;
     finalScore = _finalScore;
     if (drawState <= 0 && (input.IsNewButtonPress(ButtonMappings.Pad_ABtn, controllingPlayer[0], out controllingPlayer[1]) ||
             input.IsNewKeyPress(ButtonMappings.Keyboard_ABtn, controllingPlayer[0], out controllingPlayer[1])))
     {
         appState = ApplicationState.InitaliseApp;
     }
     drawState--;
     if (drawState > 0 && (input.IsNewButtonPress(ButtonMappings.Pad_ABtn, controllingPlayer[0], out controllingPlayer[1]) ||
             input.IsNewKeyPress(ButtonMappings.Keyboard_ABtn, controllingPlayer[0], out controllingPlayer[1])))
     {
         drawState = 0;
     }
     base.Update(input, controllingPlayer);
     if (appState == ApplicationState.InitaliseApp)
     {
         MediaPlayer.Stop();
         Reset();
     }
 }
        public void Update(ref ApplicationState appState, InputState input, PlayerIndex[] controllingPlayer)
        {
            base.Update(input, controllingPlayer);

            if (confirm == true)
            {
                switch(quitScreen.Update(input, controllingPlayer))
                {
                    case 1: appState = ApplicationState.InitaliseApp;
                            break;

                    case 0: confirm = false;
                            menuIndex = 1;
                            return;
                }
            }

            if (selectedIndex == 0 || (input.IsNewButtonPress(ButtonMappings.Pad_BBtn, controllingPlayer[0], out controllingPlayer[1]) ||
                    input.IsNewKeyPress(ButtonMappings.Keyboard_BBtn, controllingPlayer[0], out controllingPlayer[1])))
            {
                menuIndex = 0;
                appState = ApplicationState.Playing;
            }
            else if(selectedIndex == 1)
            {
                confirm = true;
                quitScreen.Reset();
            }
        }
        public void Update(ref ApplicationState appState, InputState input, PlayerIndex[] controllingPlayer)
        {
            base.Update(input, controllingPlayer);

            if ((input.IsNewButtonPress(ButtonMappings.Pad_ABtn, controllingPlayer[0], out controllingPlayer[1]) ||
                    input.IsNewKeyPress(ButtonMappings.Keyboard_ABtn, controllingPlayer[0], out controllingPlayer[1])) ||
                (input.IsNewButtonPress(ButtonMappings.Pad_BBtn, controllingPlayer[0], out controllingPlayer[1]) ||
                    input.IsNewKeyPress(ButtonMappings.Keyboard_BBtn, controllingPlayer[0], out controllingPlayer[1])))
            {
                SetTransitionOut(ApplicationState.Home);
            }
            appState = ReturnState(ApplicationState.Options);
        }
        public new int Update(InputState input, PlayerIndex[] controllingPlayer)
        {
            base.Update(input, controllingPlayer);

            if (selectedIndex == 0 || (input.IsNewButtonPress(ButtonMappings.Pad_BBtn, controllingPlayer[0], out controllingPlayer[1]) ||
                    input.IsNewKeyPress(ButtonMappings.Keyboard_BBtn, controllingPlayer[0], out controllingPlayer[1])))
            {
                return 0;
            }
            else if (selectedIndex == 1)
            {
                return 1;
            }
            return -1;
        }
 public bool Update(int _fuelLeft, int _livesLeft, int _score, InputState input, PlayerIndex[] controllingPlayer)
 {
     fuelLeft = _fuelLeft;
     livesLeft = _livesLeft;
     score = _score;
     if (drawState <= 0 && (input.IsNewButtonPress(ButtonMappings.Pad_ABtn, controllingPlayer[0], out controllingPlayer[1]) ||
             input.IsNewKeyPress(ButtonMappings.Keyboard_ABtn, controllingPlayer[0], out controllingPlayer[1])))
     {
         Reset();
         return true;
     }
     drawState--;
     if (drawState > 0 && (input.IsNewButtonPress(ButtonMappings.Pad_ABtn, controllingPlayer[0], out controllingPlayer[1]) ||
             input.IsNewKeyPress(ButtonMappings.Keyboard_ABtn, controllingPlayer[0], out controllingPlayer[1])))
     {
         drawState = 0;
     }
     base.Update(input, controllingPlayer);
     return false;
 }
        public void Update(ref ApplicationState appState, InputState input, ref PlayerIndex[] controllingPlayer)
        {
            base.Update(input, controllingPlayer);
            for (PlayerIndex index = PlayerIndex.One; index <= PlayerIndex.Four; index++)
            {
                if (GamePad.GetState(index).Buttons.Start == ButtonState.Pressed || GamePad.GetState(index).Buttons.A == ButtonState.Pressed)
                {
                    controllingPlayer[0] = index;
                    SetTransitionOut(ApplicationState.InitaliseApp);
                }

                if (Keyboard.GetState().IsKeyDown(ButtonMappings.Keyboard_Start) || Keyboard.GetState().IsKeyDown(ButtonMappings.Keyboard_ABtn))
                {
                    controllingPlayer[0] = PlayerIndex.One;
                    SetTransitionOut(ApplicationState.InitaliseApp);
                }
            }

            appState = ReturnState(ApplicationState.Splash);
        }
示例#9
0
        public void Update(GameTime gameTime, ref ApplicationState appState, InputState input, PlayerIndex[] controllingPlayer)
        {
            switch (appState)
            {
                case ApplicationState.LevelComplete:
                    {
                        soundPlayer.StopAllSounds();
                        if (gameOptions.IsTrial == true && levelCount >= gameOptions.TrialLevel)
                        {
                            appState = ApplicationState.Trial;
                            break;
                        }
                        if (updateScore == false)
                        {
                            playerOne.Score += (playerOne.Fuel * gameOptions.FuelMultiplier) * playerOne.Lives;
                            startPeeps += gameOptions.IncPeeps;
                            if (startPeeps > gameOptions.MaxPeeps)
                            {
                                startPeeps = gameOptions.StartPeeps;
                                playerOne.StartFuel -= gameOptions.DecreaseFuel;
                            }
                            updateScore = true;
                        }

                        if (levelCompleteScreen.Update(playerOne.Fuel, playerOne.Lives, playerOne.Score, input, controllingPlayer))
                        {
                            updateScore = false;
                            CreateLevel();
                            appState = ApplicationState.Playing;
                        }
                        break;
                    }
                case ApplicationState.Playing:
                    {
                        if (isPaused == true)
                        {
                            MediaPlayer.Volume = gameOptions.MusicVolumeAtPlay;
                            isPaused = false;
                        }
                        level.Update(gameTime, input, controllingPlayer, ref appState, ref playerOne);
                        break;
                    }
                case ApplicationState.Paused:
                    {
                        pauseScreen.Update(ref appState, input, controllingPlayer);
                        break;
                    }
            }

            //check for pause button or game pad being disconnected
            if ((appState != ApplicationState.LevelComplete && appState != ApplicationState.Trial) &&
                ((input.IsNewButtonPress(ButtonMappings.Pad_Start, controllingPlayer[0], out controllingPlayer[1]) ||
                input.IsNewKeyPress(ButtonMappings.Keyboard_Start, controllingPlayer[0], out controllingPlayer[1])) ||
                input.GamePadConnected(controllingPlayer[0], out controllingPlayer[1]) == GamePadStateValues.Disconnected)
                )
            {
                if (appState == ApplicationState.Playing)
                {
                    soundPlayer.StopAllSounds();
                    pauseScreen.Reset();
                    MediaPlayer.Volume = gameOptions.MusicVolumeAtPause;
                    appState = ApplicationState.Paused;
                    isPaused = true;
                }
                else
                {
                    appState = ApplicationState.Playing;
                }
            }

            if (appState == ApplicationState.GameComplete || appState == ApplicationState.GameOver)
            {
                MediaPlayer.Stop();
            }
        }
示例#10
0
        public void Move(InputState input, PlayerIndex[] controllingPlayer)
        {
            if (input.IsNewButtonHeld(ButtonMappings.Pad_RightStickLeft, controllingPlayer[0], out controllingPlayer[1]) ||
                input.IsNewKeyHeld(ButtonMappings.Keyboard_RightStickLeft, controllingPlayer[0], out controllingPlayer[1]))
            {
                if (Position.Z > 130)
                {
                    Position.X -= Speed;
                    View.X += Speed;
                }
                else
                {
                    Position.X += Speed;
                    View.X -= Speed;
                }
            }
            if (input.IsNewButtonHeld(ButtonMappings.Pad_RightStickRight, controllingPlayer[0], out controllingPlayer[1]) ||
                input.IsNewKeyHeld(ButtonMappings.Keyboard_RightStickRight, controllingPlayer[0], out controllingPlayer[1]))
            {
                if (Position.Z <= 130)
                {
                    Position.X -= Speed;
                    View.X += Speed;
                }
                else
                {
                    Position.X += Speed;
                    View.X -= Speed;
                }
            }
            if (input.IsNewButtonHeld(ButtonMappings.Pad_RightStickUp, controllingPlayer[0], out controllingPlayer[1]) ||
                input.IsNewKeyHeld(ButtonMappings.Keyboard_RightStickUp, controllingPlayer[0], out controllingPlayer[1]))
            {
                Position.Y += Speed;
                View.Y -= Speed;
            }
            if (input.IsNewButtonHeld(ButtonMappings.Pad_RightStickDown, controllingPlayer[0], out controllingPlayer[1]) ||
                input.IsNewKeyHeld(ButtonMappings.Keyboard_RightStickDown, controllingPlayer[0], out controllingPlayer[1]))
            {
                Position.Y -= Speed;
                View.Y += Speed;
            }
            if (input.IsNewButtonHeld(ButtonMappings.Pad_LeftShoulder, controllingPlayer[0], out controllingPlayer[1]) ||
                input.IsNewKeyHeld(ButtonMappings.Keyboard_LeftShoulder, controllingPlayer[0], out controllingPlayer[1]))
            {
                Position.Z += Speed;
                View.Z -= Speed;
            }
            if (input.IsNewButtonHeld(ButtonMappings.Pad_RightShoulder, controllingPlayer[0], out controllingPlayer[1]) ||
                input.IsNewKeyHeld(ButtonMappings.Keyboard_RightShoulder, controllingPlayer[0], out controllingPlayer[1]))
            {
                Position.Z -= Speed;
                View.Z += Speed;
            }
            if (input.IsNewButtonHeld(ButtonMappings.Pad_RightStickPress, controllingPlayer[0], out controllingPlayer[1]) ||
                input.IsNewKeyHeld(ButtonMappings.Keyboard_RightStickPress, controllingPlayer[0], out controllingPlayer[1]))
            {
                ResetCamera();
            }

            Position.X = MathHelper.Clamp(Position.X, positionLimits[0].X, positionLimits[1].X);
            View.X = MathHelper.Clamp(View.X, viewLimits[0].X, viewLimits[1].X);
            Position.Y = MathHelper.Clamp(Position.Y, positionLimits[0].Y, positionLimits[1].Y);
            View.Y = MathHelper.Clamp(View.Y, viewLimits[0].Y, viewLimits[1].Y);
            Position.Z = MathHelper.Clamp(Position.Z, positionLimits[0].Z, positionLimits[1].Z);
            View.Z = MathHelper.Clamp(View.Z, viewLimits[0].Z, viewLimits[1].Z);

            cameraFrustum.Matrix = GetViewMatrix() * GetProjectionMatrix();
        }
示例#11
0
        public void Update(GameTime gameTime, InputState input, PlayerIndex[] controllingPlayer, ref ApplicationState appState, ref Player playerOne)
        {
            scene.Camera.Move(input, controllingPlayer);
            skybox.Update(gameTime);
            map.Update(gameTime);
            playerOne.Move(input, controllingPlayer);
            playerOne.Update(gameTime);

            playerCollisionCheck = map.CheckBuildingCollision(playerOne);
            //has player hit the building, if so they deaded
            if (playerCollisionCheck == CollisionType.Building)
            {
                playerOne.Die();
                soundPlayer.StopAllSounds();
                soundPlayer.PlaySound("Explosion");
            }
            //has player landed too hard, if so they deaded, if there is a peep they deaded too
            if (playerCollisionCheck == CollisionType.Roof && playerOne.SafeDescent() == false)
            {
                if (map.CheckPeepCollision(playerOne))
                {
                    peepsLeft--;
                }
                playerOne.Die();
                soundPlayer.StopAllSounds();
                soundPlayer.PlaySound("Explosion");
            }
            //has the player landed safely, if there is a peep he is abducted
            if (playerCollisionCheck == CollisionType.Roof && playerOne.SafeDescent() == true)
            {
                if (map.CheckPeepCollision(playerOne))
                {
                    peepsLeft--;
                    playerOne.Score += gameOptions.PeepValue;
                    soundPlayer.PlaySound("Scream");
                }

                if (map.CheckPowerupCollision(playerOne))
                {
                    playerOne.Fuel += gameOptions.PowerupFuel;
                    soundPlayer.PlaySound("Reward");
                }
            }

            if (playerOne.Lives <= 0)
            {
                soundPlayer.StopAllSounds();
                appState = ApplicationState.GameOver;
            }
            if (peepsLeft <= 0 && playerOne.Lives>0)
            {
                soundPlayer.StopAllSounds();
                soundPlayer.PlaySound("ScoreUp");
                appState = ApplicationState.LevelComplete;
            }

            gameHud.Update(gameTime, playerOne.Lives, playerOne.Score, playerOne.Fuel, peepsLeft);

            if (Keyboard.GetState().IsKeyDown(Keys.P))
            {
                Console.WriteLine(scene.Camera.Position + " - " + scene.Camera.View + "." + " - " + playerOne.Position);
            }
        }
示例#12
0
        public void Move(InputState input, PlayerIndex[] controllingPlayer)
        {
            if (Active == true)
            {
                Rotation.Y += MathHelper.ToRadians(5.0f);
                if (
                    (input.IsNewButtonHeld(ButtonMappings.Pad_LeftStickLeft, controllingPlayer[0], out controllingPlayer[1]) ||
                    input.IsNewKeyHeld(ButtonMappings.Keyboard_LeftStickLeft, controllingPlayer[0], out controllingPlayer[1]))
                    && (hasPlayArea == false || (hasPlayArea == true && Bounds.Max.X > playArea.Min.X))
                    )
                {
                    velocity.X = -1;
                    acceleration.X += accelerationBit;
                }
                else if (
                    (input.IsNewButtonHeld(ButtonMappings.Pad_LeftStickRight, controllingPlayer[0], out controllingPlayer[1]) ||
                    input.IsNewKeyHeld(ButtonMappings.Keyboard_LeftStickRight, controllingPlayer[0], out controllingPlayer[1]))
                    && (hasPlayArea == false || (hasPlayArea == true && Bounds.Min.X < playArea.Max.X))
                    )
                {
                    velocity.X = 1;
                    acceleration.X += accelerationBit;
                }
                else
                {
                    acceleration.X -= accelerationBit;
                }

                if (
                    (input.IsNewButtonHeld(ButtonMappings.Pad_LeftStickUp, controllingPlayer[0], out controllingPlayer[1]) ||
                    input.IsNewKeyHeld(ButtonMappings.Keyboard_LeftStickUp, controllingPlayer[0], out controllingPlayer[1]))
                    && (hasPlayArea == false || (hasPlayArea == true && Bounds.Max.Z > playArea.Min.Z))
                    )
                {
                    velocity.Z = -1;
                    acceleration.Z += accelerationBit;
                }
                else if (
                    (input.IsNewButtonHeld(ButtonMappings.Pad_LeftStickDown, controllingPlayer[0], out controllingPlayer[1]) ||
                    input.IsNewKeyHeld(ButtonMappings.Keyboard_LeftStickDown, controllingPlayer[0], out controllingPlayer[1]))
                    && (hasPlayArea == false || (hasPlayArea == true && Bounds.Min.Z < playArea.Max.Z))
                    )
                {
                    velocity.Z = 1;
                    acceleration.Z += accelerationBit;
                }
                else
                {
                    acceleration.Z -= accelerationBit;
                }

                if (Fuel>0 &&
                    ((input.IsNewButtonHeld(ButtonMappings.Pad_RightTrigger, controllingPlayer[0], out controllingPlayer[1]) ||
                    input.IsNewButtonHeld(ButtonMappings.Pad_LeftTrigger, controllingPlayer[0], out controllingPlayer[1]) ||
                    input.IsNewButtonHeld(ButtonMappings.Pad_ABtn, controllingPlayer[0], out controllingPlayer[1]) ||
                    input.IsNewKeyHeld(ButtonMappings.Keyboard_ABtn, controllingPlayer[0], out controllingPlayer[1]))
                    && (hasPlayArea == false || (hasPlayArea == true && Bounds.Min.Y < playArea.Max.Y)))
                    )
                {
                    GenerateThrustParticles();
                    velocity.Y += thrust;
                    Fuel--;
                    acceleration.Y += accelerationBit;
                    soundPlayer.PlaySound("Thrust");
                }
                else if ((hasPlayArea == false || (hasPlayArea == true && Bounds.Max.Y > playArea.Min.Y)))
                {
                    velocity.Y -= gravity;
                    acceleration.Y += accelerationBit;
                    soundPlayer.StopSound("Thrust");
                }
                else
                {
                    velocity.Y = 0;
                    soundPlayer.StopSound("Thrust");
                }
                velocity.Y = MathHelper.Clamp(velocity.Y, -1.0f, 1.0f);
            }
        }
示例#13
0
        public void Update(InputState input, PlayerIndex[] controllingPlayer)
        {
            if (loaded < 2)
            {
                loaded++;
            }
            if((input.IsNewButtonPress(ButtonMappings.Pad_LeftStickUp, controllingPlayer[0], out controllingPlayer[1]) ||
                    input.IsNewKeyPress(ButtonMappings.Keyboard_LeftStickUp, controllingPlayer[0], out controllingPlayer[1])))
            {
                menuIndex--;
            }
            if ((input.IsNewButtonPress(ButtonMappings.Pad_LeftStickDown, controllingPlayer[0], out controllingPlayer[1]) ||
                    input.IsNewKeyPress(ButtonMappings.Keyboard_LeftStickDown, controllingPlayer[0], out controllingPlayer[1])))
            {
                menuIndex++;
            }

            menuIndex = (int)MathHelper.Clamp(menuIndex, 0, options.Count-1);

            if ((input.IsNewButtonPress(ButtonMappings.Pad_ABtn, controllingPlayer[0], out controllingPlayer[1]) ||
                    input.IsNewKeyPress(ButtonMappings.Keyboard_ABtn, controllingPlayer[0], out controllingPlayer[1])))
            {
                selectedIndex = menuIndex;
                soundPlayer.PlaySound("Select");
            }
            else
            {
                selectedIndex = -1;
            }
            if (overlayAlpha > 0.0f && transitionOut == false)
            {
                overlayAlpha -= fadeSpeed;
                overlay.Alpha = overlayAlpha;
            }

            if (overlayAlpha < 1.1f && transitionOut == true)
            {
                overlayAlpha += fadeSpeed;
                overlay.Alpha = overlayAlpha;
            }
        }
示例#14
0
        /// <summary>
        /// Allows the game to perform any initialization it needs to before starting to run.
        /// This is where it can query for any required services and load any non-graphic
        /// related content.  Calling base.Initialize will enumerate through any components
        /// and initialize them as well.
        /// </summary>
        protected override void Initialize()
        {
            // TODO: Add your initialization logic here
            input = new InputState();
            controllingPlayer = new PlayerIndex[2]{PlayerIndex.One, new PlayerIndex()};

            splashScreen = new SplashScreen(this.Content, "Screens/splash", "Fonts/OCR");
            homeScreen = new HomeScreen(this.Content, "Screens/home", "Fonts/OCR");
            optionsScreen = new OptionsScreen(this.Content, "Screens/options", "Fonts/OCR");
            gameOverScreen = new GameOverScreen(this.Content, "Screens/gameover", "Fonts/OCR");
            quitScreen = new QuitScreen(this.Content, "Screens/quit", "Fonts/OCR");
            trialScreen = new TrialScreen(this.Content, "Screens/trial", "Fonts/OCR");

            base.Initialize();
        }