Esempio n. 1
0
 public override void Update(GameTime gameTime)
 {
     if (UIContainers.Count > 0)
     {
         UIContainers.Peek().Update(gameTime);
     }
 }
Esempio n. 2
0
        public override void Update(GameTime gameTime)
        {
            if (UIContainers.Count > 0 && UIContainers.Peek() is UI.Containers.GameGui)
            {
                UIContainers.Peek().Update(gameTime);
            }
            else if (UIContainers.Count > 0)
            {
                UIContainers.Peek().Update(gameTime);
                return;
            }

            player.Update(gameTime);
            allDead = true;

            for (int i = 6; i < items.Count; i++)
            {
                if (items[i] is Enemy)
                {
                    ((Enemy)items[i]).Update(gameTime);
                    if (((Enemy)items[i]).isAlive)
                    {
                        allDead = false;
                    }
                }
                else if (items[i] is Weapon)
                {
                    ((Weapon)items[i]).Update(gameTime);
                }
            }



            if (!isEscPressed && Keyboard.GetState().IsKeyDown(Keys.Escape))
            {
                isEscPressed = true;
            }

            if (isEscPressed && Keyboard.GetState().IsKeyUp(Keys.Escape))
            {
                isEscPressed = false;
                UIContainers.Push(new UI.Containers.PauseContainer());
            }

            if (room.texture != TextureManager.background_clear && allDead)
            {
                room.texture = TextureManager.background_clear;
                ((UI.Containers.GameGui)gameGui).AddLevelClearLabel(roomNumber);
                items.Add(new Models.LadderTrigger());
            }

            if (player.hp <= 0)
            {
                player.hp           = 0;
                player.spriteSource = TextureManager.skull;
                player.position.X  += 30;
                player.position.Y  += 40;
                UIContainers.Push(new UI.Containers.GameOverContainer());
            }
        }