Ejemplo n.º 1
0
 public override void Update(GameTime gameTime, InputManager input)
 {
     handleInput(input);
     centerCamera(centerPos);
     unit.Right = (int)centerPos.X;
     unit.Bottom = (int)centerPos.Y;
 }
Ejemplo n.º 2
0
 public override void Update(GameTime gameTime, InputManager input)
 {
     //return to main menu if any key is pressed
     newState = Keyboard.GetState();
     if (newState != oldState)
     {
         NewState = new MainMenu(graphics, Font1, sprite);
     }
 }
Ejemplo n.º 3
0
        public override void Update(GameTime gameTime, InputManager input)
        {
            //TODO -- add move animation between levels, checking for whether levels are connected/completed

            if (input.SelectLeft && _progressData.CurrentLevel > 0)
            {
                SoundPlayer.playSoundEffects("hihatloop");
                _progressData.CurrentLevel--;
            }
            else if (input.SelectRight && _progressData.CurrentLevel < Nodes.Length - 1)
            {
                SoundPlayer.playSoundEffects("hihatloop");
                _progressData.CurrentLevel++;
            }
            else if (input.ConfirmSelection)
            {
                SoundPlayer.playSoundEffects("bassdrum");
                SoundPlayer.StopSound();
                SelectLevel(_progressData.CurrentLevel);
            }
        }
Ejemplo n.º 4
0
 public override void Update(GameTime gameTime, InputManager input)
 {
     throw new NotImplementedException();
 }
Ejemplo n.º 5
0
 private void handleInput(InputManager input)
 {
     if (input.MoveLeft)
         centerPos.X -= 10;
     else if (input.MoveRight)
     {
         centerPos.X += 10;
     }
     if (input.MoveUp)
         centerPos.Y -= 10;
     if (input.MoveDown)
         centerPos.Y += 10;
 }
Ejemplo n.º 6
0
 private void handleInput(InputManager input)
 {
     if (input.MoveLeft)
         _gino.Walk(Direction.West);
     else if (input.MoveRight)
         _gino.Walk(Direction.East);
     if (input.Jump)
         _gino.Jump();
     if (input.Fire)
         _gino.EquippedWeapon.Fire(_gino.Center, _gino.Sprite.FacingRight ? Vector2.UnitX : -Vector2.UnitX);
     if (input.Debug1)
         _gino.Damage(50, Direction.East);
 }
Ejemplo n.º 7
0
        public override void Update(GameTime gameTime, InputManager input)
        {
            if (_progressData.CurrentLevel == 0)
            {
                SoundPlayer.Update("howhighthemoon");
            }
            else if (_progressData.CurrentLevel == 1)
            {
                SoundPlayer.Update("djangostiger");// these are 24-bit .wav PCMs
            }
            else if (_progressData.CurrentLevel == 2)
            {
                SoundPlayer.Update("sweetsue");
            }
            else if (_progressData.CurrentLevel == 3)
            {
                SoundPlayer.Update("shine");
            }
            else if (_progressData.CurrentLevel == 4)
            {
                SoundPlayer.Update("chinaboy");
            }
            else if (_progressData.CurrentLevel ==5)
            {
                SoundPlayer.Update("younger");
            }
            handleInput(input);
            foreach (Pickup p in _pickups)
                p.Update(gameTime);
            foreach (Enemy e in _enemies)
            {
                e.Update(gameTime, onGround(e.Bottom, e.Left, e.Right));
                e.CheckAgainstPlayer(_gino);
                moveUnit(e, gameTime);
            }
            _gino.EquippedWeapon.Update(gameTime);
            Weapon.UpdateProjectiles(gameTime);
            moveProjectiles(gameTime);
            centerCamera(_gino.Center);
            _gino.Update(gameTime, onGround(_gino.Bottom, _gino.Left, _gino.Right));
            if (_gino.HitRect.Contains(_endPoint))
            {
                endLevel(true);
            }
            moveUnit(_gino, gameTime);

            if (_gino.State == Unit.UnitState.Dead)
            {
                _endTimer -= gameTime.ElapsedGameTime;
                if (_endTimer < TimeSpan.Zero)
                {
                    endLevel(false);
                }
            }
        }
Ejemplo n.º 8
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.º 9
0
 /// <summary>
 /// GameStates should override this to provide all update logic
 /// </summary>
 /// <param name="gameTime">gameTime.ElapsedGameTime contains the amount of time elapsed since last update</param>
 /// <param name="input">Check this object for any relevant inputs. It is updated by Game1 every cycle before passing in</param>
 public abstract void Update(GameTime gameTime, InputManager input);
Ejemplo n.º 10
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;
         }
     }
 }