private void AffectByMomentumConservationLaw(Bullet bullet) { double absoluteRotation = RelatedGameObject.GetEquipmentAbsoluteRotation(this); Vector impulse = (InitialBulletVelocity * bullet.Mass).Rotate(absoluteRotation); RelatedGameObject.AffectImpulse(-impulse, bullet.Position); }
public override void Update(TimeSpan elapsed) { base.Update(elapsed); if (IsActive && Charge > elapsed.TotalSeconds) { double absoluteRotation = RelatedGameObject.GetEquipmentAbsoluteRotation(this); Vector absolutePosition = RelatedGameObject.GetEquipmentAbsolutePosition(this); Vector tractionForce = new Vector(0, TractionForce).Rotate(absoluteRotation); RelatedGameObject.Affect(tractionForce, absolutePosition); Charge -= elapsed.TotalSeconds; } }
public void Fire() { if (Charge >= 1.0 && ElapsedTimeForShot == TimeSpan.Zero) { Charge -= 1.0; ElapsedTimeForShot = ReloadingTime; LastShotDateTime = DateTime.Now; double absoluteRotation = RelatedGameObject.GetEquipmentAbsoluteRotation(this); Vector absolutePosition = RelatedGameObject.GetEquipmentAbsolutePosition(this); Vector initialVelocity = RelatedGameObject.Velocity + InitialBulletVelocity.Rotate(absoluteRotation); Bullet bullet = (Bullet)BulletPrototype.Clone(); bullet.PlayerGuid = RelatedGameObject.PlayerGuid; bullet.Fire(absolutePosition + BulletOffset.Rotate(absoluteRotation), initialVelocity, absoluteRotation); AffectByMomentumConservationLaw(bullet); RelatedGameObject.GameWorldAddObjectDelegate.Invoke(bullet); } }