Exemplo n.º 1
0
        public override void FireInternal()
        {
            var targetAngle    = CalculateAngleToTarget();
            var sprayAngle     = SpaceExtensions.NormalizeQuantity(30.0f, targetAngle, true);
            var sprayIncrement = 5;
            var startAngle     = SpaceExtensions.AddToAngle(targetAngle, -sprayAngle / 2);
            var sprayedSoFar   = 0;

            Sound.Play("pistol");

            while (sprayedSoFar < sprayAngle)
            {
                sprayedSoFar += sprayIncrement;
                var angle  = SpaceExtensions.AddToAngle(startAngle, sprayedSoFar);
                var bullet = new Projectile(Holder.Left, Holder.Top, angle)
                {
                    Range = SpaceExtensions.NormalizeQuantity(8, angle), HealthPoints = HealthPoints, PlaySoundOnImpact = true
                };
                bullet.Speed.HitDetectionTypes.Remove(Holder.GetType());

                if (Holder.Target != null)
                {
                    bullet.Speed.HitDetectionTypes.Add(Holder.Target.GetType());
                }
                SpaceTime.CurrentSpaceTime.Add(bullet);
            }
        }
Exemplo n.º 2
0
        private void FireDoubleInternal(float x, float y, float angle) // :)
        {
            Sound.Play("thump");
            var rpg = new TimedMine(TimeSpan.FromSeconds(2))
            {
                Silent = true
            };

            rpg.MoveTo(x, y);
            var rpgSpeed = new SpeedTracker(rpg);

            rpgSpeed.HitDetectionTypes.Add(typeof(Wall));
            rpgSpeed.HitDetectionTypes.Add(typeof(Character));
            rpgSpeed.HitDetectionExclusions.Add(Holder);
            rpgSpeed.ImpactOccurred.SubscribeForLifetime((impact) =>
            {
                if (impact.ElementHit is IDestructible)
                {
                    var destructible = impact.ElementHit as IDestructible;
                    destructible.TakeDamage(5 * rpg.HealthPointsPerShrapnel);
                }

                rpg.Explode();
            }, rpg.Lifetime);

            new Force(rpgSpeed, SpaceExtensions.NormalizeQuantity(25, angle), angle);
            SpaceTime.CurrentSpaceTime.Add(rpg);
        }
Exemplo n.º 3
0
        public override void FireInternal()
        {
            activeBlades.ForEach(b => { if (b.Lifetime.IsExpired == false)
                                        {
                                            b.Lifetime.Dispose();
                                        }
                                 });
            activeBlades.Clear();

            Sound.Play("sword");
            for (var i = 1; i < 1 + SpaceExtensions.NormalizeQuantity(Range, CalculateAngleToTarget()); i++)
            {
                var location  = Holder.Center().MoveTowards(CalculateAngleToTarget(), i);
                var newBounds = Rectangular.Create(location.Left - .5f, location.Top - .5f, 1, 1);
                if (SpaceTime.CurrentSpaceTime.IsInBounds(newBounds))
                {
                    var blade = new Blade()
                    {
                        Holder = this.Holder
                    };
                    var holderLocation = Holder.TopLeft();
                    blade.MoveTo(newBounds.Left, newBounds.Top);
                    SpaceTime.CurrentSpaceTime.Add(blade);
                    activeBlades.Add(blade);
                }
            }
        }
Exemplo n.º 4
0
        public override void FireInternal()
        {
            Sound.Play("thrownet");

            var matterList = new List <NetMatter>();
            StructuralIntegrity <NetMatter> matterIntegrity = null;

            for (var y = 0; y < 3; y++)
            {
                for (var x = 0; x < 7; x++)
                {
                    var matter = new NetMatter();

                    var force   = new Force(matter.Speed, SpaceExtensions.NormalizeQuantity(45, CalculateAngleToTarget()), CalculateAngleToTarget());
                    var matterX = this.Holder.Left + 1 + x;
                    var matterY = this.Holder.Top - 1 + y;
                    matter.MoveTo(matterX, matterY, 1);
                    matterList.Add(matter);

                    matter.Speed.HitDetectionTypes.Add(typeof(Character));
                    matter.Speed.HitDetectionTypes.Add(typeof(Wall));

                    // wraps the character in the net if it hits them
                    matter.Speed.ImpactOccurred.SubscribeForLifetime((i) =>
                    {
                        if (i.ElementHit != Holder && i.ElementHit is Character)
                        {
                            Sound.Play("wrapped");
                            matterList.ForEach(m => m.Lifetime.Dispose());
                            matterList.Clear();
                            matterIntegrity.Lifetime.Dispose();
                            for (var newX = i.ElementHit.Left - 2; newX <= i.ElementHit.Left + 2; newX++)
                            {
                                for (var newY = i.ElementHit.Top - 1; newY <= i.ElementHit.Top + 1; newY++)
                                {
                                    var newMatter = new NetMatter();
                                    newMatter.MoveTo(newX, newY);
                                    matterList.Add(newMatter);
                                }
                            }

                            matterList.ForEach(m =>
                            {
                                m.Composite = matterList;
                                SpaceTime.CurrentSpaceTime.Add(m);
                            });
                        }
                    }, matter.Lifetime);
                }
            }

            matterList.ForEach(m =>
            {
                m.Composite = matterList;
                SpaceTime.CurrentSpaceTime.Add(m);
            });

            matterIntegrity = new StructuralIntegrity <NetMatter>(matterList);
            SpaceTime.CurrentSpaceTime.Add(matterIntegrity);
        }
Exemplo n.º 5
0
        public override void Evaluate()
        {
            if (MainCharacter.Current == null)
            {
                return;
            }

            var angle           = MainCharacter.Current.CalculateAngleTo(this);
            var normalizedRange = SpaceExtensions.NormalizeQuantity(Range, angle);

            if (this.CalculateDistanceTo(MainCharacter.Current) <= normalizedRange)
            {
                Fired.Fire(Id);
                Lifetime.Dispose();
            }
        }
Exemplo n.º 6
0
        public void MoveUp()
        {
            if (FreeAimCursor != null)
            {
                FreeAimCursor.MoveBy(0, -1);
                return;
            }

            if (Speed.SpeedY < 0 && Math.Abs(Speed.SpeedY) > Math.Abs(Speed.SpeedX))
            {
                Speed.SpeedY = 0;
                Speed.SpeedX = 0;
            }
            else
            {
                Speed.SpeedY = -SpaceExtensions.NormalizeQuantity(PlayerMovementSpeed, 90);
                Speed.SpeedX = 0;
            }

            TrySendBounds();
        }
Exemplo n.º 7
0
        public void MoveRight()
        {
            if (FreeAimCursor != null)
            {
                FreeAimCursor.MoveBy(1, 0);
                return;
            }

            if (Speed.SpeedX > Math.Abs(Speed.SpeedY))
            {
                Speed.SpeedX = 0;
                Speed.SpeedY = 0;
            }
            else
            {
                Speed.SpeedX = SpaceExtensions.NormalizeQuantity(PlayerMovementSpeed, 0);
                Speed.SpeedY = 0;
            }

            TrySendBounds();
        }
Exemplo n.º 8
0
 public override void Initialize()
 {
     startLocation = this.Bounds;
     // todo - replace with bullet speed from config
     force = new Force(Speed, SpaceExtensions.NormalizeQuantity(Accelleration, angle), angle);
 }