Ejemplo n.º 1
0
 public override void Update()
 {
     this.timer -= 0.01f;
     if (timer <= 0 && !exploded)
     {
         exploded = true;
         float num1 = this.y - 2f;
         for (int index = 0; index < 20; ++index)
         {
             float      num2       = (float)((double)index * 18.0 - 5.0) + Rando.Float(10f);
             ATShrapnel atShrapnel = new ATShrapnel();
             atShrapnel.range = 60f + Rando.Float(18f);
             Bullet bullet = new Bullet(x + (float)(Math.Cos((double)Maths.DegToRad(num2)) * 6.0), num1 - (float)(Math.Sin((double)Maths.DegToRad(num2)) * 6.0), (AmmoType)atShrapnel, num2, (Thing)null, false, -1f, false, true);
             bullet.firedFrom = (Thing)this;
             Level.Add((Thing)bullet);
         }
         foreach (Window window in Level.CheckCircleAll <Window>(this.position, 40f))
         {
             if (Level.CheckLine <Block>(this.position, window.position, (Thing)window) == null)
             {
                 window.Destroy((DestroyType) new DTImpact((Thing)this));
             }
         }
     }
     if (exploded)
     {
         Level.Remove(this);
         Level.Remove(detonator);
     }
     if (this.owner as Duck != null)
     {
         var duck = (Duck)this.owner;
     }
     base.Update();
 }
Ejemplo n.º 2
0
        public override bool Destroy(DestroyType type = null)
        {
            AmmoType gun = new ATShrapnel();

            gun.FireBullet(new Vec2(x, y));
            //Level.Remove(gun);
            return(base.Destroy(type));
        }
Ejemplo n.º 3
0
        public GrenadeBase(float xval, float yval)
            : base(xval, yval)
        {
            TimerBinding = new StateBinding("Timer");
            PinBinding   = new StateBinding("HasPin");

            ammo                  = 1;
            _type                 = "gun";
            _ammoType             = new ATShrapnel();
            _ammoType.penetration = 0.2f;
        }
Ejemplo n.º 4
0
        public override void OnPressAction()
        {
            if (ammo > 0 && duck != null)
            {
                duck.immobilized   = true;
                duck.remoteControl = true;
                sprite._frame      = 1;


                float cx = base.x;
                float cy = base.y;
                Graphics.flashAdd = 1.3f;
                Layer.Game.darken = 1.3f;
                if (base.isServerForObject)
                {
                    for (int i = 0; i < 20; i++)
                    {
                        float      dir   = (float)i * 18f - 5f + Rando.Float(10f);
                        ATShrapnel shrap = new ATShrapnel();
                        shrap.range = 60f + Rando.Float(18f);
                        Bullet bullet = new Bullet(cx + (float)(System.Math.Cos((double)Maths.DegToRad(dir)) * 6.0), cy - (float)(System.Math.Sin((double)Maths.DegToRad(dir)) * 6.0), shrap, dir, null, false, -1f, false, true);
                        bullet.firedFrom = this;
                        this.firedBullets.Add(bullet);
                        Level.Add(bullet);
                    }
                    System.Collections.Generic.IEnumerable <Window> windows = Level.CheckCircleAll <Window>(this.position, 40f);
                    foreach (Window w in windows)
                    {
                        if (Level.CheckLine <Block>(this.position, w.position, w) == null)
                        {
                            w.Destroy(new DTImpact(this));
                        }
                    }
                    this.bulletFireIndex += 20;
                    if (Network.isActive)
                    {
                        NMFireGun gunEvent = new NMFireGun(this, this.firedBullets, this.bulletFireIndex, false, 4, false);
                        Send.Message(gunEvent, NetMessagePriority.ReliableOrdered, null);
                        this.firedBullets.Clear();
                    }
                }
            }
            else
            {
                SFX.Play("click");
            }
        }
Ejemplo n.º 5
0
 public override void Update()
 {
     base.Update();
     if (!this._pin)
     {
         this._timer -= 0.01f;
     }
     if (this._timer < 0.5f && this.owner == null && !this._didBonus)
     {
         this._didBonus = true;
         if (Recorder.currentRecording != null)
         {
             Recorder.currentRecording.LogBonus();
         }
     }
     if (!this._localDidExplode && this._timer < 0f)
     {
         if (this._explodeFrames < 0)
         {
             this.CreateExplosion(this.position);
             this._explodeFrames = 4;
         }
         else
         {
             this._explodeFrames--;
             if (this._explodeFrames == 0)
             {
                 float cx = base.x;
                 float cy = base.y - 2f;
                 Graphics.flashAdd = 1.3f;
                 Layer.Game.darken = 1.3f;
                 if (base.isServerForObject)
                 {
                     for (int i = 0; i < 20; i++)
                     {
                         float      dir   = (float)i * 18f - 5f + Rando.Float(10f);
                         ATShrapnel shrap = new ATShrapnel();
                         shrap.range = 60f + Rando.Float(18f);
                         Bullet bullet = new Bullet(cx + (float)(System.Math.Cos((double)Maths.DegToRad(dir)) * 6.0), cy - (float)(System.Math.Sin((double)Maths.DegToRad(dir)) * 6.0), shrap, dir, null, false, -1f, false, true);
                         bullet.firedFrom = this;
                         this.firedBullets.Add(bullet);
                         Level.Add(bullet);
                     }
                     System.Collections.Generic.IEnumerable <Window> windows = Level.CheckCircleAll <Window>(this.position, 40f);
                     foreach (Window w in windows)
                     {
                         if (Level.CheckLine <Block>(this.position, w.position, w) == null)
                         {
                             w.Destroy(new DTImpact(this));
                         }
                     }
                     this.bulletFireIndex += 20;
                     if (Network.isActive)
                     {
                         NMFireGun gunEvent = new NMFireGun(this, this.firedBullets, this.bulletFireIndex, false, 4, false);
                         Send.Message(gunEvent, NetMessagePriority.ReliableOrdered, null);
                         this.firedBullets.Clear();
                     }
                 }
                 Level.Remove(this);
                 base._destroyed     = true;
                 this._explodeFrames = -1;
             }
         }
     }
     if (base.prevOwner != null && this._cookThrower == null)
     {
         this._cookThrower     = (base.prevOwner as Duck);
         this._cookTimeOnThrow = this._timer;
     }
 }
Ejemplo n.º 6
0
        public override void Update()
        {
            base.Update();
            if (_explodeFrames <= 0f && laserTimer <= 2f)
            {
                laserTimer = laserTimer - 0.01f;
            }

            if (laserTimer <= 1.5f)
            {
                if (laserTimer < 1.5f && laserTimer > 1.1f)
                {
                    Vec2 barrel = this.Offset(base.barrelOffset);
                    this.ApplyForce(new Vec2(1f, -4f));
                    this.hSpeed  = 0.005f;
                    this.vSpeed += 0.0003f;
                    QuadLaserBullet b = new QuadLaserBullet(barrel.x, barrel.y, barrelVector);
                    b.killThingType = base.GetType();
                    Level.Add(b);
                }
                else if (laserTimer < 1.1f && laserTimer > 0f)
                {
                    Vec2 barrel = this.Offset(base.barrelOffset);
                    //this.ApplyForce(new Vec2(1f, -4f));
                    this.hSpeed = -0.0025f;
                    this.vSpeed = -0.02f;
                    QuadLaserBullet b = new QuadLaserBullet(barrel.x, barrel.y, barrelVector);
                    b.killThingType = base.GetType();
                    Level.Add(b);
                }
            }

            if (laserTimer <= 0f)
            {
                Level.Remove(this);
            }

            if (!this._pin)
            {
                this._timer -= 0.01f;
            }
            if (this._timer < 0.5f && this.owner == null && !this._didBonus)
            {
                this._didBonus = true;
                if (Recorder.currentRecording != null)
                {
                    Recorder.currentRecording.LogBonus();
                }
            }
            if (!this._localDidExplode && this._timer < 0f)
            {
                if (this._explodeFrames < 0)
                {
                    this.CreateExplosion(this.position);
                    this._explodeFrames = 4;
                }
                else
                {
                    this._explodeFrames--;
                    if (this._explodeFrames == 0 && finsihedExploding == false)
                    {
                        float cx = base.x;
                        float cy = base.y - 2f;
                        Graphics.flashAdd = 1.3f;
                        Layer.Game.darken = 1.3f;
                        if (base.isServerForObject)
                        {
                            for (int i = 0; i < 20; i++)
                            {
                                float      dir   = (float)i * 18f - 5f + Rando.Float(10f);
                                ATShrapnel shrap = new ATShrapnel();
                                shrap.range = 60f + Rando.Float(18f);
                                Bullet bullet = new Bullet(cx + (float)(System.Math.Cos((double)Maths.DegToRad(dir)) * 6.0), cy - (float)(System.Math.Sin((double)Maths.DegToRad(dir)) * 6.0), shrap, dir, null, false, -1f, false, true);
                                bullet.firedFrom = this;
                                this.firedBullets.Add(bullet);
                                Level.Add(bullet);
                                laserTimer = 2f;
                            }

                            System.Collections.Generic.IEnumerable <Window> windows = Level.CheckCircleAll <Window>(this.position, 40f);
                            foreach (Window w in windows)
                            {
                                if (Level.CheckLine <Block>(this.position, w.position, w) == null)
                                {
                                    w.Destroy(new DTImpact(this));
                                }
                            }
                            this.bulletFireIndex += 20;
                            if (Network.isActive)
                            {
                                // public NMFireGun(Gun g, List<Bullet> varBullets, byte fIndex, bool rel, byte ownerIndex = 4, bool onlyFireActionVar = false);
                                NMFireGun gunEvent = new NMFireGun(this, this.firedBullets, this.bulletFireIndex, false, 4, false);
                                Send.Message(gunEvent, NetMessagePriority.ReliableOrdered, null);
                                this.firedBullets.Clear();
                            }
                            this.laserTimer = 2f;
                        }
                        // Level.Remove(this);
                        finsihedExploding   = true;
                        base._destroyed     = true;
                        this._explodeFrames = -1;
                        this.laserTimer     = 2f;
                    }
                }
            }
            if (base.prevOwner != null && this._cookThrower == null)
            {
                this._cookThrower     = (base.prevOwner as Duck);
                this._cookTimeOnThrow = this._timer;
            }
            this._sprite.frame = (this._pin ? 0 : 1);
        }