示例#1
0
        private void AffectByMomentumConservationLaw(Bullet bullet)
        {
            double absoluteRotation = RelatedGameObject.GetEquipmentAbsoluteRotation(this);

            Vector impulse = (InitialBulletVelocity * bullet.Mass).Rotate(absoluteRotation);

            RelatedGameObject.AffectImpulse(-impulse, bullet.Position);
        }
示例#2
0
        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;
            }
        }
示例#3
0
        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);
            }
        }