コード例 #1
0
 public override void Update()
 {
     if ((double)this.hitWait > 0.0)
     {
         this.hitWait -= 0.1f;
     }
     else
     {
         this.hitWait = 0.0f;
     }
     this._alternate                = !this._alternate;
     this._scanner.alpha            = (float)(0.400000005960464 + (double)this._wave.normalized * 0.600000023841858);
     this._projector.alpha          = (float)(0.400000005960464 + (double)this._wave.normalized * 0.600000023841858) * this._projectorAlpha;
     this._currentProjection.alpha  = (float)(0.400000005960464 + (double)this._projectionFlashWave.normalized * 0.600000023841858);
     this._currentProjection.alpha -= this._glitch * 3f;
     this._currentProjection.alpha *= this._projectorAlpha;
     this._double = Maths.CountDown(this._double, 0.15f);
     this._glitch = Maths.CountDown(this._glitch, 0.1f);
     if ((double)Rando.Float(1f) < 0.00999999977648258)
     {
         this._glitch = 0.3f;
         this._projectorGlitch.xscale = 0.8f + Rando.Float(0.7f);
         this._projectorGlitch.yscale = 0.6f + Rando.Float(0.5f);
         this._projectorGlitch.flipH  = (double)Rando.Float(1f) > 0.5;
     }
     if ((double)Rando.Float(1f) < 0.00499999988824129)
     {
         this._glitch = 0.3f;
         this._projectorGlitch.xscale = 0.8f + Rando.Float(0.7f);
         this._projectorGlitch.yscale = 0.6f + Rando.Float(0.5f);
         this._projectorGlitch.flipH  = (double)Rando.Float(1f) > 0.5;
         this._useWave = !this._useWave;
     }
     if ((double)Rando.Float(1f) < 0.00800000037997961)
     {
         this._glitch = 0.3f;
         this._projectorGlitch.xscale = 0.8f + Rando.Float(0.7f);
         this._projectorGlitch.yscale = 0.6f + Rando.Float(0.5f);
         this._projectorGlitch.flipH  = (double)Rando.Float(1f) > 0.5;
         this._useWave = !this._useWave;
         this._double  = 0.6f + Rando.Float(0.6f);
     }
     this._close.Clear();
     if (this._hoverItem != null && this._hoverItem.owner != null)
     {
         this.BreakHoverBond();
     }
     if (this._hoverItem == null)
     {
         Holdable holdable = Level.Nearest <Holdable>(this.x, this.y);
         if (holdable != null && holdable.owner == null && (holdable != null && holdable.canPickUp) && ((double)holdable.bottom <= (double)this.top && (double)Math.Abs(holdable.hSpeed) + (double)Math.Abs(holdable.vSpeed) < 2.0))
         {
             float num = 999f;
             if (holdable != null)
             {
                 num = (this.position - holdable.position).length;
             }
             if ((double)num < 24.0)
             {
                 this._hoverItem = holdable;
             }
         }
     }
     else if ((double)Math.Abs(this._hoverItem.hSpeed) + (double)Math.Abs(this._hoverItem.vSpeed) > 2.0 || (double)(this._hoverItem.position - this.position).length > 25.0)
     {
         this.BreakHoverBond();
     }
     else
     {
         this._hoverItem.position       = Lerp.Vec2Smooth(this._hoverItem.position, this.position + new Vec2(0.0f, (float)(-12.0 - (double)this._hoverItem.collisionSize.y / 2.0 + (double)(float)this._projectionWave * 2.0)), 0.2f);
         this._hoverItem.vSpeed         = 0.0f;
         this._hoverItem.gravMultiplier = 0.0f;
     }
     foreach (Duck duck in this._level.things[typeof(Duck)])
     {
         if (!duck.dead && (double)(duck.position - this.position).length < 64.0)
         {
             this._close.Add(duck.profile);
             this._closeGlitch = false;
         }
     }
     this._closeWait = Maths.CountDown(this._closeWait, 0.05f);
     for (int index = 0; index < this._close.Count; ++index)
     {
         if (this._close.Count == 1)
         {
             this._closeIndex = 0;
         }
         else if (this._close.Count > 1 && index == this._closeIndex && (double)this._closeWait <= 0.0)
         {
             this._closeIndex             = (this._closeIndex + 1) % this._close.Count;
             this._closeWait              = 1f;
             this._glitch                 = 0.3f;
             this._projectorGlitch.xscale = 0.8f + Rando.Float(0.7f);
             this._projectorGlitch.yscale = 0.6f + Rando.Float(0.5f);
             this._projectorGlitch.flipH  = (double)Rando.Float(1f) > 0.5;
             this._useWave                = !this._useWave;
             this._double                 = 0.6f + Rando.Float(0.6f);
             break;
         }
     }
     if (this._closeIndex >= this._close.Count)
     {
         this._closeIndex = 0;
     }
     if (this._close.Count == 0)
     {
         if (!this._closeGlitch)
         {
             this._closeWait = 1f;
             this._glitch    = 0.3f;
             this._projectorGlitch.xscale = 0.8f + Rando.Float(0.7f);
             this._projectorGlitch.yscale = 0.6f + Rando.Float(0.5f);
             this._projectorGlitch.flipH  = (double)Rando.Float(1f) > 0.5;
             this._useWave     = !this._useWave;
             this._double      = 0.6f + Rando.Float(0.6f);
             this._closeGlitch = true;
         }
         this._projectorAlpha    = Maths.CountDown(this._projectorAlpha, 0.1f);
         this._currentProjection = this._none;
     }
     else
     {
         StoredItem storedItem = PurpleBlock.GetStoredItem(this._close[this._closeIndex]);
         this._currentProjection = storedItem.sprite != null ? (!this._served.Contains(this._close[this._closeIndex]) ? storedItem.sprite : (this._alternate ? storedItem.sprite : this._none)) : this._none;
         this._projectorAlpha    = Maths.CountUp(this._projectorAlpha, 0.1f);
     }
     this._projectorGlitch.alpha = this._glitch * this._projectorAlpha;
     base.Update();
 }
コード例 #2
0
        public override void Update()
        {
            this._selectBeam.color = new Color(0.5f, (float)(0.200000002980232 + (double)this._wave2.normalized * 0.200000002980232), (float)(0.300000011920929 + (double)this._wave.normalized * 0.300000011920929)) * (1f + this._flash);
            this._flash            = Maths.CountDown(this._flash, 0.1f);
            this._spawnWait       -= 0.025f;
            if ((double)this._spawnWait < 0.0)
            {
                Level.Add((Thing) new MultiBeamParticle(this.x, this.y + 190f, -0.8f - this._wave.normalized, false, Color.Cyan * 0.8f));
                Level.Add((Thing) new MultiBeamParticle(this.x, this.y + 190f, -0.8f - this._wave2.normalized, true, Color.LightBlue * 0.8f));
                this._spawnWait = 1f;
            }
            using (IEnumerator <Duck> enumerator = Level.CheckRectAll <Duck>(this.position - this.center, this.position - this.center + new Vec2(this._collisionSize.x, this._collisionSize.y)).GetEnumerator())
            {
                while (enumerator.MoveNext())
                {
                    Duck d = enumerator.Current;
                    if (!this._ducks.Any <BeamDuck>((Func <BeamDuck, bool>)(t => t.duck == d)))
                    {
                        float num = (double)d.y >= 100.0 ? 130f : 40f;
                        SFX.Play("stepInBeam");
                        d.immobilized = true;
                        d.crouch      = false;
                        d.sliding     = false;
                        if (d.holdObject != null)
                        {
                            this._guns.Add((Thing)d.holdObject);
                        }
                        d.ThrowItem();
                        d.solid    = false;
                        d.grounded = false;
                        this._ducks.Add(new BeamDuck()
                        {
                            duck        = d,
                            entryHeight = num,
                            leaving     = false,
                            entryDir    = (double)d.x < (double)this.x ? -1 : 1,
                            sin         = new SinWave(0.1f),
                            sin2        = new SinWave(0.05f)
                        });
                        this.entered = true;
                    }
                }
            }
            foreach (Holdable holdable in Level.CheckRectAll <Holdable>(this.position - this.center, this.position - this.center + new Vec2(this._collisionSize.x, this._collisionSize.y)))
            {
                if (holdable.owner == null && !this._guns.Contains((Thing)holdable))
                {
                    this._guns.Add((Thing)holdable);
                }
            }
            int   count = this._ducks.Count;
            int   num1  = 0;
            float num2  = 150f;
            float num3  = (float)(((double)this._beamHeight - (double)num2 * 2.0) / (count > 1 ? (double)(count - 1) : 1.0));

            for (int index = 0; index < this._ducks.Count; ++index)
            {
                BeamDuck duck = this._ducks[index];
                if (duck.leaving)
                {
                    duck.duck.solid  = true;
                    duck.duck.hSpeed = this._leaveLeft ? -4f : 4f;
                    duck.duck.vSpeed = 0.0f;
                    if ((double)Math.Abs(duck.duck.position.x - this.x) > 24.0)
                    {
                        duck.duck.immobilized = false;
                        this._ducks.RemoveAt(index);
                        --index;
                        continue;
                    }
                }
                else
                {
                    duck.duck.position.x = Lerp.FloatSmooth(duck.duck.position.x, this.position.x + (float)duck.sin2 * 1f, 0.2f);
                    duck.duck.position.y = Lerp.FloatSmooth(duck.duck.position.y, (float)((double)num2 + (double)num3 * (double)index + (double)(float)duck.sin * 2.0), 0.08f);
                    duck.duck.vSpeed     = 0.0f;
                    duck.duck.hSpeed     = 0.0f;
                }
                if (!TitleScreen.hasMenusOpen && duck.duck.inputProfile.Pressed("LEFT"))
                {
                    duck.leaving     = true;
                    this._leaveLeft  = true;
                    duck.duck.offDir = (sbyte)-1;
                    this.entered     = false;
                }
                ++num1;
            }
            for (int index = 0; index < this._guns.Count; ++index)
            {
                Thing gun = this._guns[index];
                gun.vSpeed = 0.0f;
                gun.hSpeed = 0.0f;
                if ((double)Math.Abs(this.position.x - gun.position.x) < 6.0)
                {
                    gun.position = Vec2.Lerp(gun.position, new Vec2(this.position.x, gun.position.y - 3f), 0.1f);
                    gun.alpha    = Maths.LerpTowards(gun.alpha, 0.0f, 0.1f);
                    if ((double)gun.alpha <= 0.0)
                    {
                        gun.y = -200f;
                        this._guns.RemoveAt(index);
                        --index;
                    }
                }
                else
                {
                    gun.position = Vec2.Lerp(gun.position, new Vec2(this.position.x, gun.position.y), 0.2f);
                }
            }
            base.Update();
        }
コード例 #3
0
        public override void Update()
        {
            this._selectBeam.color = new Color(0.3f, (float)(0.300000011920929 + (double)this._wave2.normalized * 0.200000002980232), (float)(0.5 + (double)this._wave.normalized * 0.300000011920929)) * (1f + this._flash);
            this._flash            = Maths.CountDown(this._flash, 0.1f);
            this._spawnWait       -= 0.1f;
            if ((double)this._spawnWait < 0.0)
            {
                Level.Add((Thing) new BeamParticle(this.x, this.y + 190f, -0.8f - this._wave.normalized, false, Color.Cyan * 0.8f));
                Level.Add((Thing) new BeamParticle(this.x, this.y + 190f, -0.8f - this._wave2.normalized, true, Color.LightBlue * 0.8f));
                this._spawnWait = 1f;
            }
            foreach (Duck d in Level.CheckRectAll <Duck>(this.topLeft, this.bottomRight))
            {
                if (d.isServerForObject)
                {
                    this.TakeDuck(d);
                }
            }
            foreach (Holdable holdable in Level.CheckRectAll <Holdable>(this.topLeft, this.bottomRight))
            {
                if (holdable.isServerForObject)
                {
                    if (holdable is RagdollPart)
                    {
                        Duck captureDuck = (holdable as RagdollPart).doll.captureDuck;
                        if (captureDuck != null)
                        {
                            (holdable as RagdollPart).doll.Unragdoll();
                            this.TakeDuck(captureDuck);
                        }
                    }
                    else if (holdable.owner == null && !this._guns.Contains((Thing)holdable))
                    {
                        this._guns.Add((Thing)holdable);
                    }
                }
            }
            int   count = this._ducks.Count;
            int   num1  = 0;
            float num2  = (float)((double)this._beamHeight / (double)count / 2.0 + 20.0 * (count > 1 ? 1.0 : 0.0));
            float num3  = (float)(((double)this._beamHeight - (double)num2 * 2.0) / (count > 1 ? (double)(count - 1) : 1.0));

            for (int index = 0; index < this._ducks.Count; ++index)
            {
                BeamDuck duck = this._ducks[index];
                if (duck.leaving)
                {
                    duck.duck.solid  = true;
                    duck.duck.y      = MathHelper.Lerp(duck.duck.position.y, duck.entryHeight, 0.35f);
                    duck.duck.vSpeed = 0.0f;
                    if ((double)Math.Abs(duck.duck.position.y - duck.entryHeight) < 4.0)
                    {
                        duck.duck.position.y = duck.entryHeight;
                        duck.duck.hSpeed     = (float)duck.entryDir * 3f;
                        duck.duck.vSpeed     = 0.0f;
                    }
                    if ((double)Math.Abs(duck.duck.position.x - this.x) > 24.0)
                    {
                        duck.duck.gravMultiplier = 1f;
                        duck.duck.immobilized    = false;
                        duck.duck.beammode       = false;
                        this._ducks.RemoveAt(index);
                        --index;
                        continue;
                    }
                }
                else
                {
                    duck.duck.position.x     = Lerp.FloatSmooth(duck.duck.position.x, this.position.x + (float)duck.sin2 * 1f, 0.4f);
                    duck.duck.position.y     = Lerp.FloatSmooth(duck.duck.position.y, (float)((double)num2 + (double)num3 * (double)index + (double)(float)duck.sin * 2.0), 0.1f);
                    duck.duck.vSpeed         = 0.0f;
                    duck.duck.hSpeed         = 0.0f;
                    duck.duck.gravMultiplier = 0.0f;
                }
                if (duck.duck.inputProfile.Pressed("QUACK") && (double)Math.Abs(duck.duck.position.x - this.x) < 2.0)
                {
                    duck.leaving = true;
                }
                ++num1;
            }
            for (int index = 0; index < this._guns.Count; ++index)
            {
                Thing gun = this._guns[index];
                gun.vSpeed = 0.0f;
                gun.hSpeed = 0.0f;
                if ((double)Math.Abs(this.position.x - gun.position.x) < 6.0)
                {
                    gun.position = Vec2.Lerp(gun.position, new Vec2(this.position.x, gun.position.y - 3f), 0.1f);
                    gun.alpha    = Maths.LerpTowards(gun.alpha, 0.0f, 0.1f);
                    if ((double)gun.alpha <= 0.0)
                    {
                        gun.y = -200f;
                        this._guns.RemoveAt(index);
                        --index;
                    }
                }
                else
                {
                    gun.position = Vec2.Lerp(gun.position, new Vec2(this.position.x, gun.position.y), 0.2f);
                }
            }
            base.Update();
        }