Ejemplo n.º 1
0
        public override void Update(GameTime gameTime, InputManager input)
        {
            MouseState mouseState = Mouse.GetState();
            image.X = (Game1.SCREEN_WIDTH / 8);
            image.Y = mouseState.Y - 20;
            if (previousMouseState.LeftButton == ButtonState.Released
                && mouseState.LeftButton == ButtonState.Pressed)
            {
                fireBullet(image);
                previousMouseState = mouseState;
            }
            if (previousMouseState.LeftButton == ButtonState.Pressed
                && mouseState.LeftButton == ButtonState.Released)
                previousMouseState = mouseState;

            for (int i = 0; i < numButtons; i++)
            {
                if (buttonSt[i] == buttonState.down) //decide where to go
                {
                    GameState _current_state = this;

                    if (buttonSt[0] == buttonState.down)
                    {//******************************start game
                        NewState = new Overworld(
                            new ProgressData()
                            {
                                NumCoins = 0,
                                CurrentLevel = 0,
                                addHealth = 0,
                                shopWeapon = "Revolver",
                                addAmmo = 0,
                                LevelCompleted = new bool[Overworld.Nodes.Length]
                            }
                        );

                    }
                    if (buttonSt[1] == buttonState.down) //******************************************LoadGame********
                    {
                        NewState = new Overworld(Data.DataLoader.LoadProgress());
                    }
                    if (buttonSt[2] == buttonState.down) //instructions
                        NewState = new InstructionScreen(graphics, Font1, sprite);
                    if (buttonSt[3] == buttonState.down) //quit
                        _current_state.RequestExit = true;
                }
                if (inButton(i))
                    buttonSt[i] = buttonState.down;
            }

            for (int i = 0; i < numBullets; i++)
            {
                if (bulletFired[i])
                {
                    bulletRect[i].X += 10;
                    if (bulletRect[i].X > Game1.SCREEN_WIDTH)
                        bulletFired[i] = false;
                }
            }
        }
Ejemplo n.º 2
0
        private void endLevel(bool success)
        {
            //record level as completed if successful
            _progressData.LevelCompleted[_progressData.CurrentLevel - 1] =
                _progressData.LevelCompleted[_progressData.CurrentLevel - 1] || success;
            Data.DataLoader.SaveProgress(_progressData);
            SoundPlayer.StopSound();
            //trigger the end-level sound

            SoundPlayer.playSoundEffects("endgamesound");
            SoundPlayer.StartSound("rosesdepicardie");

            _progressData.shopWeapon = "Revolver";
            _progressData.addAmmo = 0;
            NewState = new Overworld(_progressData);
        }
Ejemplo n.º 3
0
 public override void Update(GameTime gameTime, InputManager input)
 {
     //TODO -- probably need stuff here
     //where is the mouse, change the picture based on the mouse click
     MouseState mouseState = Mouse.GetState();
     mouse.X = mouseState.X - 5;
     mouse.Y = mouseState.Y - 5;
     mainPic = ShopView.CheckLocation(mouse.X, mouse.Y); //returns != 0 if mouse is hovering over item
     if (pmouseState.LeftButton == ButtonState.Released
         && mouseState.LeftButton == ButtonState.Pressed)
     {
         pmouseState = mouseState;
     }
     if (pmouseState.LeftButton == ButtonState.Pressed
         && mouseState.LeftButton == ButtonState.Released)
     {
         pmouseState = mouseState;
         if (mainPic == 7)
         {
             //alter progress data to reflect items bought
             if (countBought[3] > 0) //bought a machine pistol
             {
                 progressData.shopWeapon = "MachinePistol";
                 countBought[3]--;
                 while (countBought[3] != 0)
                 {
                     progressData.addAmmo++;
                     countBought[3]--;
                 }
             }
             else if (countBought[2] > 0) //bought a rifle
             {
                 progressData.shopWeapon = "Rifle";
                 countBought[2]--;
                 while (countBought[2] != 0)
                 {
                     progressData.addAmmo++;
                     countBought[2]--;
                 }
             }
             else if (countBought[1] > 0) //bought a shotgun
             {
                 progressData.shopWeapon = "Shotgun";
                 countBought[1]--;
                 while (countBought[1] != 0)
                 {
                     progressData.addAmmo++;
                     countBought[1]--;
                 }
             }
             else if (countBought[0] > 0) //bought a revolver
             {
                 progressData.shopWeapon = "Revolver";
                 while (countBought[0] != 0)
                 {
                     progressData.addAmmo++;
                     countBought[0]--;
                 }
             }
             SoundPlayer.StopSound();
             SoundPlayer.StartSound("rosesdepicardie");
             NewState = new Overworld(progressData);//return to overworld
         }
         else if (mainPic == 6) //attempt to buy
         {
             locked = 0;
             gotPrice = ShopView.getPrice(lmainPic - 1);
             if (progressData.NumCoins >= gotPrice)
             {
                 progressData.NumCoins -= gotPrice;
                 if (lmainPic > 0)
                     indices[lmainPic - 1] = 1;
                 if (lmainPic == 5)
                     progressData.addHealth++;
                 if ((lmainPic < 5) && (lmainPic > 0))
                     countBought[lmainPic - 1]++;
             }
             lmainPic = 0;
         }
         else if ((mainPic > 0) && (mainPic < 6))
         {
             locked = 1;
             lmainPic = mainPic;
         }
     }
 }