Esempio n. 1
0
File: Enemy.cs Progetto: MyEyes/BGJ5
        void Die(Player p)
        {
            _map.Objects.Remove(this);
            light.Radius = 0;
            Sounds.PlaySound("DeathFlash");
            for (int x = 0; x < 40; x++)
            {
                Vector2 dir = new Vector2((float)(2 * _rand.NextDouble() - 1), (float)(2 * _rand.NextDouble() - 1));
                dir.Normalize();
                dir *= 4.5f + (float)_rand.NextDouble();
                AntiLightParticle alp = new AntiLightParticle(Position, dir, null, _map, null);
                _map.Objects.Add(alp);
            }
            for (int x = 0; x < 20; x++)
            {
                Vector2 dir = new Vector2((float)(2 * _rand.NextDouble() - 1), (float)(2 * _rand.NextDouble() - 1));
                dir.Normalize();
                dir *= 1 + (float)_rand.NextDouble();
                LightParticle alp = new LightParticle(Position, dir, null, Color.White, _map, null);
                _map.Objects.Add(alp);
            }

            LightRefill refill = new LightRefill(Position, _map, null);

            refill.RefillLeft = 150;
            _map.Objects.Add(refill);
        }
Esempio n. 2
0
 public override void Update(float seconds)
 {
     Player p = _map.Objects[0] as Player;
     coolDown -= seconds;
     light.Radius = RefillLeft / 5.0f;
     if (p != null)
     {
         if ((p.Position - Position).Length() < 300 && coolDown<=0 && p.Health<Player.MaxHealth)
         {
             Vector2 dir = new Vector2((float)(2 * _rand.NextDouble() - 1), (float)(2 * _rand.NextDouble() - 1));
             dir.Normalize();
             dir *= 5;
             LightParticle lp = new LightParticle(Position, dir, p,Color.White, _map, null,true);
             _map.Objects.Add(lp);
             RefillLeft -= 10;
             coolDown = coolDownTime;
         }
     }
     if (RefillLeft <= 0)
     {
         _map.Objects.Remove(this);
         light.Radius = 0;
         _map.Objects.Add(new LightRefill(new Vector2((float)_rand.NextDouble() * Map.SizeX * Map.TileSize, (float)_rand.NextDouble() * Map.SizeY * Map.TileSize), _map, null));
     }
     base.Update(seconds);
 }
Esempio n. 3
0
        public void Attack(Enemy e)
        {
            Vector2 dir = new Vector2((float)(2 * _rand.NextDouble() - 1), (float)(2 * _rand.NextDouble() - 1));

            dir.Normalize();
            dir *= 5;
            LightParticle lp = new LightParticle(Position, dir, e, berserkCountdown > 0 ? Color.Red : Color.White, _map, null, particleCounter % 8 == 0);

            _map.Objects.Add(lp);

            particleCounter++;

            if (berserkCountdown > 0)
            {
                dir *= -1.25f;
                lp   = new LightParticle(Position, dir, e, berserkCountdown > 0 ? Color.Red : Color.White, _map, null, false);
                _map.Objects.Add(lp);
            }
        }
Esempio n. 4
0
        public override void Update(float seconds)
        {
            Player p = _map.Objects[0] as Player;


            if (p != null && (p.Position - Position).Length() < 150)
            {
                Vector2 dir = new Vector2((float)(2 * _rand.NextDouble() - 1), (float)(2 * _rand.NextDouble() - 1));
                dir.Normalize();
                dir *= 5;
                LightParticle light = new LightParticle(Position, dir, p, Color.Red, _map, null, bleeps++ % 8 == 0);
                lifeCountdown -= seconds;
                _map.Objects.Add(light);
                if (lifeCountdown < 0)
                {
                    p.berserkCountdown = 8;
                    this.light.Radius  = 0;
                    _map.Objects.Remove(this);
                }
            }
        }