示例#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 GlobalUpdate(GameTime gameTime, InventoryManager im)
 {
     foreach (Item i in im.itemsEquipped)
     {
         if (equipmentItems.SelectedValue == i.name)
         {
             equipmentItems.SelectedValue = i.desc;
         }
     }
     if (KeymouseReader.KeyPressed2(Keys.I))
     {
         if (inventoryPanel.Visible == true)
         {
             inventoryPanel.Visible = false;
         }
         else
         {
             inventoryPanel.Visible = true;
         }
     }
     foreach (Hero h in rm.heroes)
     {
         if (sHealth != null)
         {
             sHealth.Text   = "Health: " + h.health + "/" + h.maxHealth;
             sMana.Text     = "Mana: " + h.mana + "/" + h.maxMana;
             sStr.Text      = "Strength: " + h.strength;
             sInt.Text      = "Intelligence: " + h.intelligence;
             sAgi.Text      = "Agility: " + h.agility;
             attribute.Text = "Attribute points: " + h.attributePoint;
             rank1.Text     = h.spell1Name + ": " + h.spell1Rank;
             rank2.Text     = h.spell2Name + ": " + h.spell2Rank;
             rank3.Text     = h.spell3Name + ": " + h.spell3Rank;
             rank4.Text     = h.spell4Name + ": " + h.spell4Rank;
             skill.Text     = "Skill points: " + h.skillPoint;
         }
     }
 }
示例#4
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();
        }
示例#5
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;
                }
            }
        }
示例#6
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);
        }
示例#7
0
        protected override void Update(GameTime gameTime)
        {
            lights.Update(gameTime, rm);
            if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed || Keyboard.GetState().IsKeyDown(Keys.Escape))
            {
                Exit();
            }
            foreach (Hero h in rm.heroes)
            {
                if (h.health <= 0)
                {
                    gameOver = true;
                }
            }
            UserInterface.Active.Update(gameTime);
            KeymouseReader.Update();
            im.Update(gameTime);
            interfaces.GlobalUpdate(gameTime, im);
            switch (enums.gState)
            {
            case GameState.Game:
                if (!gameOver)
                {
                    combat = true;
                    menu   = true;
                    foreach (DynamicSpikeTrap s in rm.spikeList)
                    {
                        s.Update(gameTime);
                    }
                    foreach (Hero h in rm.heroes)
                    {
                        h.Update(gameTime);
                        camera.Update(gameTime, h, true);
                    }
                    foreach (Monster m in rm.monsters)
                    {
                        m.Update(gameTime);
                    }
                    foreach (Tile t in rm.invisibleTiles)
                    {
                        t.Update(gameTime);
                    }
                    foreach (RestorationBlock r in rm.restoList)
                    {
                        r.Update(gameTime);
                    }
                    foreach (Lever l in rm.leverList)
                    {
                        l.Update(gameTime);
                    }
                    foreach (Chests c in rm.chestList)
                    {
                        c.Update(gameTime, interfaces);
                    }
                    cm.Update(gameTime);
                    if (game)
                    {
                        interfaces.Game(im);
                        game = false;
                    }
                }
                interfaces.UpdateGame(gameTime, im);
                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);
        }