Пример #1
0
        public new void Update(GameTime gameTime)
        {
            position += velocity;
            hitbox    = new Rectangle((int)position.X, (int)position.Y, texture.Width, texture.Height);
            if (KeymouseReader.KeyPressed(Keys.Left) || KeymouseReader.KeyPressed(Keys.A))
            {
                velocity.X = -2;
            }
            else if (KeymouseReader.KeyPressed(Keys.Right) || KeymouseReader.KeyPressed(Keys.D))
            {
                velocity.X = 2;
            }
            else if ((KeymouseReader.KeyPressed(Keys.Up) || KeymouseReader.KeyPressed(Keys.W)) && hasJumped == false)
            {
                position.Y -= 10f;
                velocity.Y  = -5f;
                hasJumped   = true;
            }
            else
            {
                velocity.X = 0;
            }
            float i = 1;

            velocity.Y += 0.15f * 1;
        }
Пример #2
0
        public void Update(GameTime gameTime)
        {
            LevelGain();
            if (pClass == PlayerClass.Mage)
            {
            }
            else if (pClass == PlayerClass.Warrior)
            {
                foreach (Warrior w in rm.heroes)
                {
                    w.ResetBuff();
                }
            }
            position += velocity;
            hitbox    = new Rectangle((int)position.X, (int)position.Y, texture.Width, texture.Height);
            // Movement.
            if (KeymouseReader.KeyPressed(Keys.Left) || KeymouseReader.KeyPressed(Keys.A))
            {
                velocity.X = -speed;
                heroFX     = SpriteEffects.FlipHorizontally;
            }
            else if (KeymouseReader.KeyPressed(Keys.Right) || KeymouseReader.KeyPressed(Keys.D))
            {
                velocity.X = speed;
                heroFX     = SpriteEffects.None;
            }
            else if ((KeymouseReader.KeyPressed(Keys.Up) || KeymouseReader.KeyPressed(Keys.W)) && hasJumped == false)
            {
                position.Y -= 10f;
                velocity.Y  = -5f;
                hasJumped   = true;
            }
            else // Gravity.
            {
                velocity.X = 0;
            }
            float i = 1;

            velocity.Y += 0.15f * 1;
        }
Пример #3
0
        public void Update(GameTime gameTime)
        {
            speed = 2 + (int)(agility * 0.1);
            LevelGain();
            if (pClass == PlayerClass.Mage)
            {
            }
            else if (pClass == PlayerClass.Warrior)
            {
                foreach (Warrior w in rm.heroes)
                {
                    w.ResetBuff();
                }
            }

            position += velocity;
            hitbox    = new Rectangle((int)position.X, (int)position.Y, fakeHitbox.Width - 25, fakeHitbox.Height - 6);
            // Movement.
            if (KeymouseReader.KeyPressed(Keys.Left) || KeymouseReader.KeyPressed(Keys.A))
            {
                deltaTime  += gameTime.ElapsedGameTime.TotalSeconds;
                rotation    = MathHelper.ToRadians(0);
                velocity.X  = -speed;
                heroFX      = SpriteEffects.FlipHorizontally;
                frameTimer -= gameTime.ElapsedGameTime.TotalMilliseconds;
                if ((KeymouseReader.KeyPressed(Keys.Up) || KeymouseReader.KeyPressed(Keys.W)) && hasJumped == false)
                {
                    position.Y -= 10f;
                    velocity.Y  = -5f;
                    hasJumped   = true;
                }
            }
            else if (KeymouseReader.KeyPressed(Keys.Right) || KeymouseReader.KeyPressed(Keys.D))
            {
                deltaTime  += gameTime.ElapsedGameTime.TotalSeconds;
                rotation    = MathHelper.ToRadians(0);
                velocity.X  = speed;
                heroFX      = SpriteEffects.None;
                frameTimer -= gameTime.ElapsedGameTime.TotalMilliseconds;
                if ((KeymouseReader.KeyPressed(Keys.Up) || KeymouseReader.KeyPressed(Keys.W)) && hasJumped == false)
                {
                    position.Y -= 10f;
                    velocity.Y  = -5f;
                    hasJumped   = true;
                }
            }
            else if ((KeymouseReader.KeyPressed(Keys.Up) || KeymouseReader.KeyPressed(Keys.W)) && hasJumped == false)
            {
                position.Y -= 10f;
                velocity.Y  = -5f;
                hasJumped   = true;
            }
            else if ((KeymouseReader.KeyPressed(Keys.Up) || KeymouseReader.KeyPressed(Keys.W)))
            {
                frame = 2;
            }
            else // Gravity.
            {
                velocity.X = 0;
                frame      = 1;
            }
            float i = 1;

            velocity.Y += 0.15f * 1;

            frameUpdate();
        }
Пример #4
0
        public void Update(GameTime gameTime)
        {
            foreach (Hero h in rm.heroes)
            {
                if (h.yourTurn)
                {
                    doThisOnce1 = true;
                    foreach (Monster m in rm.monstersInCombat)
                    {
                        if (m.IsAlive)
                        {
                            if (enums.pClass == PlayerClass.Warrior)
                            {
                                rm.warrior.UpdateCombat(gameTime);
                            }
                            else if (enums.pClass == PlayerClass.Mage)
                            {
                                rm.mage.UpdateCombat(gameTime);
                            }
                        }
                    }
                }
            }
            foreach (Hero h in rm.heroes)
            {
                if (!h.yourTurn)
                {
                    foreach (Monster m in rm.monstersInCombat)
                    {
                        if (m.IsAlive)
                        {
                            if (enums.mRace == MonsterRace.Goblin)
                            {
                                foreach (Goblin g in rm.monstersInCombat)
                                {
                                    g.UpdateCombat(gameTime);
                                }
                            }
                            else if (enums.mRace == MonsterRace.Devil)
                            {
                                foreach (Devil d in rm.monstersInCombat)
                                {
                                    d.UpdateCombat(gameTime);
                                }
                            }
                        }
                    }
                }
            }

            foreach (Monster m in rm.monstersInCombat)
            {
                if (KeymouseReader.KeyPressed(Keys.R))
                {
                    m.IsAlive = false;
                }

                if (m.Health <= 0)
                {
                    m.IsAlive = false;
                }

                if (!m.IsAlive && rm.monstersInCombat.Count != 0)
                {
                    foreach (Hero h in rm.heroes)
                    {
                        h.position = h.positionBeforeCombat;
                    }
                    //rm.monstersInCombat.RemoveAll(P => m.IsAlive = false);

                    ResetCombat();
                    enums.mRace = MonsterRace.None;
                }
            }
        }
Пример #5
0
        protected override void Update(GameTime gameTime)
        {
            if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed || Keyboard.GetState().IsKeyDown(Keys.Escape))
            {
                Exit();
            }
            UserInterface.Active.Update(gameTime);
            KeymouseReader.Update();
            switch (state)
            {
            case GameState.Game:
                combat = true;
                menu   = true;
                foreach (Hero h in rm.heroes)
                {
                    h.Update(gameTime);
                    camera.Update(gameTime, h, true);
                }
                if (KeymouseReader.KeyPressed(Keys.H))
                {
                    im.AddItem(lel, false);
                    rm.warrior.agility += 1;
                }
                foreach (Monster m in rm.monsters)
                {
                    m.Update(gameTime);
                }
                cm.Update(gameTime);
                if (game)
                {
                    interfaces.Game();
                    game = false;
                }
                break;

            case GameState.Combat:
                game = true;
                menu = true;
                com.Update(gameTime);
                cm.Update(gameTime);
                foreach (Hero h in rm.heroes)
                {
                    camera.Update(gameTime, h, false);
                }
                if (combat)
                {
                    interfaces.Combat();
                    combat = false;
                }
                interfaces.Update(gameTime);
                break;

            case GameState.Menu:
                game   = true;
                combat = true;
                if (menu)
                {
                    menu = false;
                }
                break;
            }
            base.Update(gameTime);
        }