Esempio n. 1
0
 public void Add(Bullet bullet)
 {
     lock (_locker)
     {
         Bullets.Add(bullet);
     }
 }
Esempio n. 2
0
        public object[] Compress(Bullet bullet)
        {
            object[] result = new object[16];

            SetCollidableContractMembers(result, bullet);

            result[BulletCompressionContract.DamageDealt] = bullet.DamageDealt;

            return result;
        }
Esempio n. 3
0
        public virtual void BulletCollision(Bullet bullet)
        {
            DamageTaken += bullet.DamageDealt;

            // Only increment dealt statistics if it's not by me
            if (bullet.FiredBy != _me)
            {                
                bullet.FiredBy.StatRecorder.DamageDealt += bullet.DamageDealt;
            }            
        }
Esempio n. 4
0
        public override void BulletCollision(Bullet bullet)
        {
            // Only seek those who hit me X% of the time
            if (Game.GEN.NextDouble() >= CHANCE_TO_SEEK)
            {
                (_me as ShipAI).SeekingShip = bullet.FiredBy.ID;
            }

            base.BulletCollision(bullet);
        }
Esempio n. 5
0
        /// <summary>
        /// Create's a bullet in the direction of the ship
        /// </summary>
        /// <returns>Newly created bullet</returns>
        public bool Fire(DateTime now)
        {
            var timeSinceLastFired = (now - LastFired).TotalMilliseconds;
            var newEnergy = Math.Min(Energy + timeSinceLastFired / ENERGY_RECHARGE_RATE, 1);
            if (timeSinceLastFired >= MIN_FIRE_RATE && newEnergy > ENERGY_TO_FIRE)
            {
                var shipCenter = new Vector2(_me.MovementController.Position.X + HALF_SHIP_WIDTH, _me.MovementController.Position.Y + HALF_SHIP_HEIGHT);
                var shipDirection = new Vector2(_me.MovementController.Rotation);
                var startPosition = new Vector2((shipCenter + (BULLET_LEAD * shipDirection)) - BULLET_OFFSET);

                Bullet spawnedBullet = new Bullet(startPosition, shipDirection, _me, DamageModifier);
                _bulletManager.Add(spawnedBullet);

                LastFired = now;

                _me.Fired(spawnedBullet);

                Energy = newEnergy - ENERGY_TO_FIRE;
                return true;
            }
            return false;
        }
Esempio n. 6
0
 public void Fired(Bullet bullet)
 {
     if (OnFire != null)
     {
         OnFire(bullet);
     }
 }
Esempio n. 7
0
 public void AddBulletToGame(Bullet bullet)
 {
     _space.Insert(bullet);
 }
Esempio n. 8
0
 public void AddBulletToGame(Bullet bullet)
 {
     _space.Insert(bullet);
 }