コード例 #1
0
        public override void Update()
        {
            if (this.isServerForObject)
            {
                this.xscale = this.yscale = Maths.CountUp(this.yscale, 0.05f);
                this._fade -= 0.05f;
                if ((double)this._fade < 0.0)
                {
                    Level.Remove((Thing)this);
                }
                this.alpha = Maths.NormalizeSection(this._fade, 0.2f, 0.3f);
                Vec2 p2 = Vec2.Zero;
                if (this._owner.controlledDuck == null && !this._isNotControlRay)
                {
                    p2 = new Vec2((float)Math.Cos((double)this.angle), (float)-Math.Sin((double)this.angle));
                    foreach (IAmADuck amAduck in Level.CheckCircleAll <IAmADuck>(this.position, 3f))
                    {
                        switch (amAduck)
                        {
                        case Duck _:
                            if (!(amAduck as Duck).HasEquipment(typeof(TinfoilHat)) && !((amAduck as Duck).holdObject is MindControlRay))
                            {
                                this._owner.ControlDuck(amAduck as Duck);
                                continue;
                            }
                            continue;

                        case RagdollPart _ when(amAduck as RagdollPart).doll.captureDuck != null:
                            this._owner.ControlDuck((amAduck as RagdollPart).doll.captureDuck);

                            continue;

                        case TrappedDuck _ when(amAduck as TrappedDuck).captureDuck != null:
                            this._owner.ControlDuck((amAduck as TrappedDuck).captureDuck);

                            continue;

                        default:
                            continue;
                        }
                    }
                }
                else
                {
                    if (this._owner.controlledDuck != null)
                    {
                        p2 = this._owner.controlledDuck.cameraPosition - this.position;
                        p2.Normalize();
                        this.angleDegrees = -Maths.PointDirection(Vec2.Zero, p2);
                    }
                    this._isNotControlRay = true;
                }
                ControlWave controlWave = this;
                controlWave.position = controlWave.position + p2 * 2.6f;
            }
            else
            {
                this.xscale = this.yscale = 1f;
                Vec2        vec2        = new Vec2((float)Math.Cos((double)this.angle), (float)-Math.Sin((double)this.angle));
                ControlWave controlWave = this;
                controlWave.position = controlWave.position + vec2 * 2.6f;
            }
        }
コード例 #2
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();
 }