Exemplo n.º 1
0
        public void Shoot(Vector2D gunLocation, Vector2D missileBayLocation)
        {
            switch (ShotCount)
            {
                case 3:
                    if (_level.Ticks >= Bullet.LastFired + Bullet.FireRate)
                    {
                        Bullet.LastFired = _level.Ticks;
                        _projectiles.Add(new Bullet(gunLocation, ShotPower, new StraightMotion(new Vector2D(0.41f, 0.25f))));
                        _projectiles.Add(new Bullet(gunLocation, ShotPower, new StraightMotion(new Vector2D(0.5f, 0))));
                        _projectiles.Add(new Bullet(gunLocation, ShotPower, new StraightMotion(new Vector2D(0.41f, -0.25f))));
                    }
                    break;
                case 2:
                    if (_level.Ticks >= Bullet.LastFired + Bullet.FireRate / 2)
                    {
                        _lastShotIndex = (_lastShotIndex + 1) % 2;
                        Bullet.LastFired = _level.Ticks;
                        _projectiles.Add(new Bullet(gunLocation.Clone().TranslateByCoordinates(0, _lastShotIndex * -5), ShotPower, new StraightMotion(new Vector2D(0.5f, 0))));
                    }
                    break;
                default:
                    if (_level.Ticks >= Bullet.LastFired + Bullet.FireRate)
                    {
                        Bullet.LastFired = _level.Ticks;
                        _projectiles.Add(new Bullet(gunLocation, ShotPower, new StraightMotion(new Vector2D(0.5f, 0))));
                    }
                    break;
            }

            if (TotalMissiles < MissileCount && _level.Ticks >= Missile.LastFired + Missile.FireRate)
            {
                Missile.LastFired = _level.Ticks;
                _projectiles.Add(new Missile(missileBayLocation));
            }
        }
Exemplo n.º 2
0
 public StraightMotion(Vector2D motionVector)
 {
     _motionVector = motionVector.Clone();
 }