Ejemplo n.º 1
0
        public bool timer1(ref bool won)
        {
            foreach (var item in BossBullets)
            {
                item.Move(Width, Height);
            }
            hero.MoveBullets(Width, Height);

            if (hero.Kills >= 15)
            {
                hasBoss = true;
            }
            foreach (Bullet b in ZombieBullets)
            {
                b.Move(Width, Height);
            }

            foreach (Bullet b in hero.Bullets)
            {
                foreach (Zombie z in zombies)
                {
                    if (b.isHit(z.Position))
                    {
                        z.Alive = false;
                        b.Alive = false;
                        hero.Kills++;
                    }
                }
                if (hasBoss)
                {
                    if (b.isHit(boss.Position))
                    {
                        boss.Health -= 20;
                        b.Alive      = false;
                    }

                    if (boss.Health <= 0)
                    {
                        hasBoss = false;
                        won     = true;
                        return(false);
                    }
                }
            }
            foreach (Bullet b in ZombieBullets)
            {
                if (b.isHit(hero.Position))
                {
                    hero.Health -= 10;
                    if (hero.Health <= 0)
                    {
                        hero.Image = Properties.Resources.dead;
                        return(true);
                    }
                    b.Alive = false;
                }
            }

            foreach (Bullet b in BossBullets)
            {
                if (b.isHit(hero.Position))
                {
                    hero.Health -= 20;
                    if (hero.Health <= 0)
                    {
                        hero.Image = Properties.Resources.dead;
                        return(true);
                    }
                    b.Alive = false;
                }
            }

            for (int i = ZombieBullets.Count - 1; i >= 0; i--)
            {
                if (!ZombieBullets[i].Alive)
                {
                    ZombieBullets.RemoveAt(i);
                }
            }
            for (int i = BossBullets.Count - 1; i >= 0; i--)
            {
                if (!BossBullets[i].Alive)
                {
                    BossBullets.RemoveAt(i);
                }
            }
            for (int i = zombies.Count - 1; i >= 0; i--)
            {
                if (!zombies[i].Alive)
                {
                    zombies.RemoveAt(i);
                }
            }
            return(false);
        }