public void Add(Bullet bullet) { lock (_locker) { Bullets.Add(bullet); } }
public object[] Compress(Bullet bullet) { object[] result = new object[16]; SetCollidableContractMembers(result, bullet); result[BulletCompressionContract.DamageDealt] = bullet.DamageDealt; return result; }
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; } }
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); }
/// <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; }
public void Fired(Bullet bullet) { if (OnFire != null) { OnFire(bullet); } }
public void AddBulletToGame(Bullet bullet) { _space.Insert(bullet); }