Пример #1
0
        public void CheckHealth(healthbar healthbar, List <particle> particles)
        {
            Random random = new Random();

            if (hp <= 3)
            {
                bleedDelay += 1;
                if (bleedDelay >= 16)
                {
                    particles.Add(new particle(new Vector2(pos.X + random.Next(20), pos.Y + random.Next(20)), 1, "grey", random.Next(3, 5), 0.01f, random.Next(-300, -210), 4));
                    bleedDelay = 0;
                }
            }
            healthbar.height = hp * 10;
            if (hp <= 0)
            {
                imx = 1;
                if (pos.X > 640)
                {
                    lifes       -= 1;
                    respawnDelay = 1;
                    pos.Y        = 480;
                }
                else
                {
                    imx    = Frame(2);
                    pos.X += 3;
                    pos.Y += 3;
                }
                inputActive = false;
            }
            if (respawnDelay >= 1)
            {
                pos.X         = 320;
                respawnDelay += 1;
                if (respawnDelay >= 32)
                {
                    imx    = 1;
                    pos.Y -= 1;
                    if (hp <= 9)
                    {
                        addHealthDelay += 1;
                        if (addHealthDelay >= 16)
                        {
                            hp            += 1;
                            addHealthDelay = 0;
                        }
                    }
                }
                if (respawnDelay >= 32 + 320)
                {
                    inputActive  = true;
                    respawnDelay = 0;
                }
            }
        }
Пример #2
0
 public void drawGui(SpriteBatch spriteBatch, SpriteFont fontSmall, Texture2D spritesheet, healthbar healthbar, player player, int level)
 {
     healthbar.DrawSprite(spriteBatch, spritesheet);
     if (player.gunType != 1)
     {
         spriteBatch.DrawString(fontSmall, "Power Down In: " + player.powerDownCount, new Vector2(20, 14), Color.Gold);
     }
     spriteBatch.DrawString(fontSmall, "Score: " + player.score, new Vector2(20, 28), Color.PeachPuff);
     spriteBatch.Draw(spritesheet, new Vector2(20, 28 + 32), new Rectangle(1, 351, 24, 24), Color.White);
     spriteBatch.Draw(spritesheet, new Vector2(22, 28 + 34), new Rectangle(Frame(currentFrame), 351, 20, 20), Color.White);
     if (level == 1 && dialogCount <= maxDialogDisplay)
     {
         spriteBatch.Draw(spritesheet, new Vector2(117, 15), new Rectangle(350, 540, 450, 60), Color.White);
         spriteBatch.DrawString(fontSmall, level1Dialog[currentDialog], new Vector2(120, 20), Color.White);
     }
 }
Пример #3
0
        public void CheckHealth(healthbar healthbar, List <particle> particles)
        {
            Random random = new Random();

            if (hp <= 3)
            {
                bleedDelay += 1;
                if (bleedDelay >= 5)
                {
                    for (int i = 0; i < 2; i++)
                    {
                        particles.Add(new particle(new Vector2(pos.X + 12, pos.Y + 12 - 5), 1, "smoke", random.Next(3, 5), 0.01f, random.Next(-300, -250)));
                        particles.Add(new particle(new Vector2(pos.X + 12, pos.Y + 12 - 5), 1, "fire smoke", random.Next(3, 5), 0.01f, random.Next(-300, -250)));
                    }
                    bleedDelay = 0;
                }
            }
            healthbar.height = hp * 10;
            if (hp < 0)
            {
                hp = 0;
            }
            if (hp > 10)
            {
                hp = 10;
            }
            if (hp <= 0)
            {
                gunType        = 1;
                powerDownCount = 128 * 10;
                imx            = 1;
                if (pos.X > 640 || pos.Y > 480)
                {
                    vulnerable = false;
                    if (respawnDelay <= 0)
                    {
                        lives -= 1;
                    }
                    respawnDelay = 1;
                    pos.Y        = 480;
                }
                else
                {
                    imx    = Frame(2);
                    pos.X += 3;
                    pos.Y += 3;
                }
                inputActive = false;
            }
            if (respawnCutScene)
            {
                bleedDelay = 0;
                imx        = 1;
                pos.Y     -= 1;
                if (hp <= 9)
                {
                    addHealthDelay += 1;
                    if (addHealthDelay >= 16)
                    {
                        hp            += 1;
                        addHealthDelay = 0;
                    }
                }
                if (pos.Y <= 240)
                {
                    vulnerable      = true;
                    inputActive     = true;
                    respawnDelay    = 0;
                    powerDownCount  = 128 * 10;
                    respawnCutScene = false;
                }
            }
            if (respawnDelay >= 1)
            {
                pos.X           = 320;
                respawnDelay   += 1;
                respawnCutScene = true;
            }
        }