コード例 #1
0
        public void ShowBulletsFlying(Point DamagePointOfOrigin, double DamageDirection, WeaponInfo Weapon)
        {
            if (Weapon == null)
                return;

            if (Weapon.VisibleBulletLines > 0)
                (1 + ((Weapon.VisibleBulletLines - 1).Random())).Times(
                    delegate
                    {
                        var VisibleBullet = new Shape().AttachTo(GetWarzone());

                        var RandomGray = (0x40 + 0x80.Random()).ToInt32();

                        VisibleBullet.graphics.lineStyle(1, RandomGray.ToGrayColor(), 1);


                        var BulletDirection = DamageDirection + (2.0.Random() - 1.0) * (Weapon.ArcRange * 0.75);
                        var BulletDropFromRange = 32 + (Weapon.Range / 2 - 32).Random();
                        var BulletDropFrom = DamagePointOfOrigin.MoveToArc(BulletDirection, BulletDropFromRange);

                        VisibleBullet.graphics.moveTo(BulletDropFrom.x, BulletDropFrom.y);

                        var BulletDropTo = DamagePointOfOrigin.MoveToArc(BulletDirection, BulletDropFromRange + (Weapon.Range.Random() / 2));

                        VisibleBullet.graphics.lineTo(BulletDropTo.x, BulletDropTo.y);

                        50.AtDelayDo(() => VisibleBullet.Orphanize());
                    }
                );
        }
コード例 #2
0
        public void CreateExplosion(WeaponInfo ExplosiveWeaponType, Point Target, NetworkMode Mode)
        {
            Sounds.explosion.ToSoundAsset().play();

            if (Mode == NetworkMode.Local)
            {
                var Range = ExplosiveWeaponType.Range;

                foreach (var v in from i in AllMortals
                                  let p = i.ToPoint() - Target
                                  where p.length < Range
                                  select new { i, p })
                {
                    var Damage = (ExplosiveWeaponType.Damage * ((Range - v.p.length) / Range)).ToInt32();

                    if (NetworkAddDamageFromDirection != null)
                        NetworkAddDamageFromDirection(v.i.NetworkId, Damage, v.p.GetRotation().RadiansToDegrees());

                    v.i.AddDamageFromDirection(Damage, v.p.GetRotation());
                }
            }

            var a = new Animation(null, Images.Explosions.ani6);

            a.LastFrame +=
                delegate
                {
                    a.AnimationEnabled = false;
                    a.Orphanize();
                };


            a.MoveTo(Target).AttachTo(GetWarzone());
            a.AnimationEnabled = true;
        }
コード例 #3
0
        private void DoSomeDamage(Point DamagePointOfOrigin, double DamageDirection, WeaponInfo Weapon)
        {

            ShowBulletsFlying(DamagePointOfOrigin, DamageDirection, Weapon);

            if (NetworkShowBulletsFlying != null)
                NetworkShowBulletsFlying(
                    DamagePointOfOrigin.x.ToInt32(),
                    DamagePointOfOrigin.y.ToInt32(),
                    DamageDirection.RadiansToDegrees(),
                    Weapon.NetworkId
                    );

            var AllMortals = this.AllMortals.ToArray();

            //Console.WriteLine("mortals in warzone: " + AllMortals.Length);

            foreach (var DeadManWalking in AllMortals)
            {
                var DamageThisDude = true;

                // why bother shooting itself?
                if (DeadManWalking == Ego)
                    if (!Weapon.CanHurtEgo)
                        DamageThisDude = false;

                if (!DeadManWalking.IsAlive)
                    DamageThisDude = false;

                if (DamageThisDude)
                {
                    var Location = new Point { x = DamagePointOfOrigin.x, y = DamagePointOfOrigin.y }.MoveToArc(DamageDirection, -32);
                    var Offset = new Point { y = DeadManWalking.y - Location.y, x = DeadManWalking.x - Location.x };
                    var Arc = Offset.GetRotation();
                    var Distance = Offset.length;

                    Func<double, double> Warp = i => i % (Math.PI * 2);

                    var LessThan = Arc < (Warp(DamageDirection) + Weapon.ArcRange);
                    var MoreThan = Arc > (Warp(DamageDirection) - Weapon.ArcRange);

                    var Hit = LessThan && MoreThan;

                    if (Distance < Weapon.Range)
                        if (Hit)
                        {
                            // calculate damage variation here based on hit approximity

                            DeadManWalking.AddDamageFromDirection(Weapon.Damage, Arc, true);

                            if (NetworkAddDamageFromDirection != null)
                                NetworkAddDamageFromDirection(
                                    DeadManWalking.NetworkId,
                                    Weapon.Damage,
                                    Arc.RadiansToDegrees()
                                );
                        }
                }

            }
        }