示例#1
0
 public override void Update()
 {
     Layer.HUD.camera.x = CategoryPage.camOffset;
     if (this._state == CategoryState.OpenPage)
     {
         this._strip.active     = false;
         CategoryPage.camOffset = Lerp.FloatSmooth(CategoryPage.camOffset, 360f, 0.1f);
         if ((double)CategoryPage.camOffset <= 330.0 || !(this._pageToOpen.specialText == "VIEW ALL"))
         {
             return;
         }
         Level.current = (Level) new CategoryPage(this._cards, true);
     }
     else
     {
         if (this._state != CategoryState.Idle)
         {
             return;
         }
         CategoryPage.camOffset = Lerp.FloatSmooth(CategoryPage.camOffset, -40f, 0.1f);
         if ((double)CategoryPage.camOffset < 0.0)
         {
             CategoryPage.camOffset = 0.0f;
         }
         this._strip.active = (double)CategoryPage.camOffset == 0.0;
     }
 }
        public override void Update()
        {
            if (!this._skip && Vote.Passed(VoteType.Skip))
            {
                this._skip = true;
            }
            if (this._skip)
            {
                this._fadeOut = true;
            }
            DuckGame.Graphics.fade = Lerp.Float(DuckGame.Graphics.fade, this._fadeOut ? 0.0f : 1f, 0.02f);
            if ((double)DuckGame.Graphics.fade < 0.00999999977648258 && this._skip)
            {
                HighlightLevel.didSkip = true;
                Vote.CloseVoting();
                Level.current = !Main.isDemo ? (Level) new RockScoreboard(RockScoreboard.returnLevel, ScoreBoardMode.ShowWinner, true) : (Level) new HighlightLevel(true);
            }
            if (!this._showHighlight && (double)DuckGame.Graphics.fade > 0.949999988079071)
            {
                this._waitToShow -= 0.02f;
                if ((double)this._waitToShow <= 0.0)
                {
                    this._waitToShow = 0.0f;
                    this._fadeOut    = true;
                }
            }
            if ((double)DuckGame.Graphics.fade < 0.00999999977648258 && !this._showHighlight && this._fadeOut)
            {
                this._fadeOut       = false;
                this._showHighlight = true;
            }
            if (this._showHighlight && (double)DuckGame.Graphics.fade > 0.949999988079071)
            {
                this._keepPaused -= 0.03f;
            }
            if (!this._highlights[this._currentHighlight].finished)
            {
                return;
            }
            this._endWait -= 0.03f;
            if ((double)this._endWait > 0.0)
            {
                return;
            }
            this._fadeOut = true;
            if ((double)DuckGame.Graphics.fade >= 0.00999999977648258)
            {
                return;
            }
            int highlight = this._currentHighlight - 1;

            if (this._currentHighlight == 0)
            {
                Level.current = (Level) new HighlightLevel(true);
            }
            else
            {
                Level.current = (Level) new HighlightPlayback(highlight);
            }
        }
 public override void Update()
 {
   base.Update();
   this._shakeInc += 0.8f;
   this._shakeMult = Lerp.Float(this._shakeMult, 0.0f, 0.05f);
   if (this._alternate == 0)
   {
     foreach (FluidStream hole in this._holes)
     {
       hole.onFire = this.onFire;
       hole.hSpeed = this.hSpeed;
       hole.vSpeed = this.vSpeed;
       hole.DoUpdate();
       hole.position = this.Offset(hole.offset);
       hole.sprayAngle = this.OffsetLocal(hole.startSprayAngle);
       float num1 = (float) (1.0 - ((double) hole.offset.y - (double) this.topLocal) / ((double) this.bottomLocal - (double) this.topLocal));
       if ((double) hole.x > (double) this.left - 2.0 && (double) hole.x < (double) this.right + 2.0 && (double) num1 < (double) this._fluidLevel)
       {
         float num2 = Maths.Clamp(this._fluidLevel - num1, 0.1f, 1f) * 0.0012f * hole.holeThickness;
         FluidData fluid = this._fluid;
         fluid.amount = num2;
         hole.Feed(fluid);
         this._fluidLevel -= num2;
       }
     }
   }
   this.weight = this._fluidLevel * 10f;
   ++this._alternate;
   if (this._alternate <= 4)
     return;
   this._alternate = 0;
 }
示例#4
0
 public static void Update()
 {
     if (Vote._voteButton != "")
     {
         foreach (Profile who in Profiles.all.Where <Profile>((Func <Profile, bool>)(x => x.team != null)))
         {
             if (who.inputProfile != null && who.inputProfile.Pressed(Vote._voteButton))
             {
                 Vote.RegisterVote(who, VoteType.Skip);
             }
         }
     }
     if (!Vote._votes.Exists((Predicate <RegisteredVote>)(x => x.open && (double)x.slide < 0.899999976158142)))
     {
         foreach (RegisteredVote vote in Vote._votes)
         {
             if (vote.doClose)
             {
                 vote.open = false;
             }
         }
     }
     foreach (RegisteredVote vote in Vote._votes)
     {
         vote.slide      = Lerp.FloatSmooth(vote.slide, vote.open ? 1f : -0.1f, 0.1f, 1.1f);
         vote.wobble     = Lerp.Float(vote.wobble, 0.0f, 0.05f);
         vote.wobbleInc += 0.5f;
     }
     Vote._votes.RemoveAll((Predicate <RegisteredVote>)(x => !x.open && (double)x.slide < 0.00999999977648258));
 }
        public override void Update()
        {
            if (GameMode.started)
            {
                Level.Remove((Thing)this);
            }
            this.distOut = Lerp.FloatSmooth(this.distOut, 16f, 0.08f, 1.2f);
            this.distLen = Lerp.FloatSmooth(this.distLen, 10f, 0.08f, 1.2f);
            this.rot     = Lerp.FloatSmooth(this.rot, 45f, 0.08f, 1.1f);
            if ((double)Math.Abs(this.rot - 45f) < 20.0)
            {
                this.streamAlpha -= 0.03f;
                if ((double)this.streamAlpha < 0.0)
                {
                    this.streamAlpha = 0.0f;
                }
            }
            Vec2 to = Vec2.Transform(this.targetPos, Level.current.camera.getMatrix());

            to.x         *= this.layer.camera.width / (float)Graphics.width;
            to.y         *= this.layer.camera.height / (float)Graphics.height;
            this.position = Lerp.Vec2Smooth(this.position, to, 0.2f);
            if ((double)(this.position - to).length > 16.0)
            {
                this.prevPos.Add(this.position);
            }
            this.sizeWaver += 0.2f;
        }
 public override void Update()
 {
     if (this._mode != null)
     {
         this._mode.DoUpdate();
     }
     if (this._level == "RANDOM")
     {
         if (this.wait < 4)
         {
             ++this.wait;
         }
         if (this.wait == 4)
         {
             ++this.wait;
             foreach (AutoBlock autoBlock in this.things[typeof(AutoBlock)])
             {
                 autoBlock.PlaceBlock();
             }
             foreach (AutoPlatform autoPlatform in this.things[typeof(AutoPlatform)])
             {
                 autoPlatform.PlaceBlock();
                 autoPlatform.UpdateNubbers();
             }
             foreach (BlockGroup blockGroup in this.things[typeof(BlockGroup)])
             {
                 foreach (Block block in blockGroup.blocks)
                 {
                     if (block is AutoBlock)
                     {
                         (block as AutoBlock).PlaceBlock();
                     }
                 }
             }
         }
     }
     if (this._showInfo && !GameMode.started)
     {
         this._infoSlide = Lerp.Float(this._infoSlide, 1f, 0.06f);
         if ((double)this._infoSlide > 0.949999988079071)
         {
             this._infoWait += Maths.IncFrameTimer();
             if ((double)this._infoWait > 2.5)
             {
                 this._showInfo = false;
             }
         }
     }
     else
     {
         this._infoSlide = Lerp.Float(this._infoSlide, 0.0f, 0.1f);
     }
     base.Update();
 }
        public override void Update()
        {
            bool hover = this.hover;
            Duck duck  = Level.Nearest <Duck>(this.x, this.y);

            this.hover = duck != null && (double)(duck.position - (this.position + new Vec2(8f, 0.0f))).length < 16.0;
            if (!hover && this.hover)
            {
                HUD.AddCornerControl(HUDCorner.BottomRight, "@SHOOT@PROFILE");
            }
            else if (hover && !this.hover)
            {
                HUD.CloseAllCorners();
            }
            this._consoleFade = Lerp.Float(this._consoleFade, this.hover ? 1f : 0.0f, 0.1f);
            base.Update();
        }
 public override void Update()
 {
     if (this._fade)
     {
         Graphics.fade = Lerp.Float(Graphics.fade, 0.0f, 0.02f);
         if ((double)Graphics.fade > 0.0)
         {
             return;
         }
         Main.isDemo   = this._demo;
         Level.current = (Level) new TitleScreen();
     }
     else
     {
         Graphics.fade = Lerp.Float(Graphics.fade, 1f, 0.02f);
         this._wave   += 0.1f;
         if (Input.Pressed("UP"))
         {
             this._buy = true;
             SFX.Play("textLetter", 0.9f);
         }
         if (Input.Pressed("DOWN"))
         {
             this._buy = false;
             SFX.Play("textLetter", 0.9f);
         }
         if (!Input.Pressed("SELECT"))
         {
             return;
         }
         if (this._buy)
         {
             this._fade = true;
             this._demo = false;
         }
         else
         {
             this._fade = true;
             this._demo = true;
         }
         SFX.Play("rockHitGround", 0.9f);
     }
 }
示例#9
0
 public override void Draw()
 {
     base.Draw();
     if (this._ruined)
     {
         return;
     }
     this._frame.depth = this.depth + 1;
     Graphics.Draw(this._frame, this.x, this.y);
     this._channels.alpha = Lerp.Float(this._channels.alpha, this.owner != null ? 1f : 0.0f, 0.1f);
     this._channels.depth = this.depth + 4;
     this._channels.frame = this.channel ? 1 : 0;
     Graphics.Draw((Sprite)this._channels, this.x - 4f, this.y - 4f);
     if (this.owner != null)
     {
         Vec2 p1   = Vec2.Zero;
         bool flag = false;
         foreach (Vec2 p2 in this.trail)
         {
             if (!flag)
             {
                 flag = true;
             }
             else
             {
                 Graphics.DrawTexturedLine(this._rainbow.texture, p1, p2, Color.White, depth: (new Depth(0.1f)));
             }
             p1 = p2;
         }
     }
     if (this._switchFrames > 0)
     {
         this._tvNoise.alpha = 1f;
     }
     else
     {
         this._tvNoise.alpha = 0.2f;
     }
     this._tvNoise.depth = this.depth + 8;
     Graphics.Draw((Sprite)this._tvNoise, this.x - 4f, this.y - 4f);
 }
示例#10
0
 public override void Draw()
 {
     this.depth = new Depth(-0.12f);
     if ((double)this._vertPush > 0.0)
     {
         this.depth = new Depth(-0.11f);
     }
     if (this._graphic != null)
     {
         this._graphic.position = this.position + new Vec2(0.0f * this.shiftTime, this._vertPush * 1.5f);
         this._graphic.alpha    = this.alpha;
         this._graphic.angle    = this.angle;
         this._graphic.depth    = this.depth;
         this._graphic.scale    = this.scale + new Vec2(Math.Abs((float)this.shiftAmount * 0.0f) * this.shiftTime, this._vertPush * 0.2f);
         this._graphic.center   = this.center;
         this._graphic.Draw();
     }
     if ((double)this.shiftTime > 0.0)
     {
         this._graphic.position = this.position + new Vec2((float)(this.shiftAmount * 2) * this.shiftTime, 0.0f);
         this._graphic.alpha    = this.alpha;
         this._graphic.angle    = this.angle;
         this._graphic.depth    = this.depth + 10;
         this._graphic.scale    = this.scale + new Vec2(Math.Abs((float)this.shiftAmount * 0.0f) * this.shiftTime, 0.0f);
         this._graphic.center   = this.center;
         this._graphic.alpha    = 0.6f;
         this._graphic.Draw();
     }
     this.shiftTime = Lerp.FloatSmooth(this.shiftTime, 0.0f, 0.1f);
     if ((double)this.shiftTime < 0.0500000007450581)
     {
         this.shiftTime = 0.0f;
     }
     this._vertPush = Lerp.FloatSmooth(this._vertPush, 0.0f, 0.3f);
     if ((double)this._vertPush >= 0.0500000007450581)
     {
         return;
     }
     this._vertPush = 0.0f;
 }
 public override void Apply()
 {
     if (DuckGame.Graphics.device.Textures[0] != null)
     {
         Tex2D texture = (Tex2D)(DuckGame.Graphics.device.Textures[0] as Texture2D);
         this.SetValue("width", texture.frameWidth / (float)texture.width);
         this.SetValue("height", texture.frameHeight / (float)texture.height);
         this.SetValue("frameWidth", texture.frameWidth);
         this.SetValue("amount", this.amount);
         this.SetValue("yoff", this.yoffset);
         this.SetValue("xpos", this._thing.x);
         this.SetValue("ypos", this._thing.y);
     }
     DuckGame.Graphics.device.Textures[1]      = (Texture)(Texture2D)this._goldTexture;
     DuckGame.Graphics.device.SamplerStates[1] = SamplerState.PointWrap;
     foreach (EffectPass pass in this._effect.effect.CurrentTechnique.Passes)
     {
         pass.Apply();
     }
     if (this.lockframes > 0)
     {
         --this.lockframes;
     }
     else
     {
         if ((double)Rando.Float(1f) > 0.850000023841858)
         {
             this.lockframes = Rando.Int(2, 12);
         }
         if ((double)Rando.Float(1f) > 0.200000002980232)
         {
             this.amount = Lerp.Float(this.amount, 0.0f, 0.05f);
         }
         if ((double)Rando.Float(1f) <= 0.980000019073486)
         {
             return;
         }
         this.amount += 0.3f;
     }
 }
        public override void Draw()
        {
            this._move = Lerp.Float(this._move, 0.0f, 0.04f);
            if ((double)this._move <= 0.00999999977648258)
            {
                this._move += 1.570796f;
            }
            if ((double)this._length > (double)this.dist)
            {
                this.show = false;
            }
            this._alphaFade = Lerp.Float(this._alphaFade, this.show ? 1f : 0.0f, 0.1f);
            this._length    = this._startLength * (float)Math.Sin((double)this._move);
            this.alpha      = (float)(1.0 - (double)this._length / (double)this._startLength) * this._alphaFade;
            if ((double)this.alpha < 0.00999999977648258)
            {
                return;
            }
            this.position = this._attach.barrelPosition + this._attach.barrelVector * this._length;
            Vec2 vec2 = this._attach.barrelVector.Rotate(Maths.DegToRad(90f), Vec2.Zero);

            Graphics.DrawLine(this.position + vec2 * 7f, this.position - vec2 * 7f, Color.Blue * this.alpha, (float)(1.0 + (1.0 - (double)this._length / (double)this._startLength) * 4.0), new Depth(0.9f));
        }
 public override void Update()
 {
     if (this._playSwipe)
     {
         this._transitionWait += 0.02f;
         if ((double)this._transitionWait > 1.0)
         {
             this._doTransition = true;
         }
         if ((double)this._slideOutWait < 1.0)
         {
             this._duckLerp      = Lerp.FloatSmooth(this._duckLerp, 1f, 0.1f, 1.1f);
             this._channelLerp   = Lerp.FloatSmooth(this._channelLerp, 1f, 0.1f, 1.1f);
             this._fiveLerp      = Lerp.FloatSmooth(this._fiveLerp, 1f, 0.1f, 1.1f);
             this._slideOutWait += 0.012f;
         }
         else
         {
             this._duckLerp    = Lerp.FloatSmooth(this._duckLerp, 0.0f, 0.1f, 1.1f);
             this._channelLerp = Lerp.FloatSmooth(this._channelLerp, 0.0f, 0.1f, 1.1f);
             this._fiveLerp    = Lerp.FloatSmooth(this._fiveLerp, 0.0f, 0.1f, 1.1f);
             if ((double)this._duckLerp < 0.00999999977648258)
             {
                 this._playSwipe = false;
             }
         }
         for (int index = 0; index < this._swipeLines.Count; ++index)
         {
             this._swipeLines[index] = Lerp.Float(this._swipeLines[index], 1f, this._swipeSpeeds[index]);
         }
     }
     else
     {
         this._doTransition = false;
     }
 }
        public override void Draw()
        {
            this.menuSize.y = this._fdHeight;
            if (!this.opened)
            {
                return;
            }
            base.Draw();
            float num1 = 350f;
            float num2 = this._fdHeight + 22f;
            Vec2  p1_1 = new Vec2((float)((double)this.layer.width / 2.0 - (double)num1 / 2.0) + this.hOffset, (float)((double)this.layer.height / 2.0 - (double)num2 / 2.0 - 15.0));
            Vec2  p2_1 = new Vec2((float)((double)this.layer.width / 2.0 + (double)num1 / 2.0) + this.hOffset, (float)((double)this.layer.height / 2.0 + (double)num2 / 2.0 - 12.0));

            DuckGame.Graphics.DrawRect(p1_1, p2_1, new Color(70, 70, 70), this.depth, false);
            DuckGame.Graphics.DrawRect(p1_1, p2_1, new Color(30, 30, 30), this.depth - 8);
            DuckGame.Graphics.DrawRect(p1_1 + new Vec2(4f, 23f), p2_1 + new Vec2(-16f, -4f), new Color(10, 10, 10), this.depth - 4);
            Vec2 p1_2 = new Vec2(p2_1.x - 14f, p1_1.y + 23f);
            Vec2 p2_2 = p2_1 + new Vec2(-4f, -4f);

            DuckGame.Graphics.DrawRect(p1_2, p2_2, new Color(10, 10, 10), this.depth - 4);
            DuckGame.Graphics.DrawRect(p1_1 + new Vec2(3f, 3f), new Vec2(p2_1.x - 3f, p1_1.y + 19f), new Color(70, 70, 70), this.depth - 4);
            if (this._scrollBar)
            {
                this._scrollLerp = Lerp.Float(this._scrollLerp, this._scrollPosition, 0.05f);
                Vec2 p1_3 = new Vec2(p2_1.x - 12f, (float)((double)this.topRight.y + 7.0 + (240.0 * (double)this._scrollLerp - 4.0)));
                Vec2 p2_3 = new Vec2(p2_1.x - 6f, (float)((double)this.topRight.y + 11.0 + (240.0 * (double)this._scrollLerp + 8.0)));
                bool flag = false;
                if ((double)Mouse.x > (double)p1_3.x && (double)Mouse.x < (double)p2_3.x && ((double)Mouse.y > (double)p1_3.y && (double)Mouse.y < (double)p2_3.y))
                {
                    flag = true;
                    if (Mouse.left == InputState.Pressed)
                    {
                        this.drag = true;
                    }
                }
                if (Mouse.left == InputState.None)
                {
                    this.drag = false;
                }
                if (this.drag)
                {
                    this._scrollPosition = (float)(((double)Mouse.y - (double)p1_2.y - 10.0) / ((double)p2_2.y - (double)p1_2.y - 20.0));
                    if ((double)this._scrollPosition < 0.0)
                    {
                        this._scrollPosition = 0.0f;
                    }
                    if ((double)this._scrollPosition > 1.0)
                    {
                        this._scrollPosition = 1f;
                    }
                    this._scrollLerp = this._scrollPosition;
                }
                DuckGame.Graphics.DrawRect(p1_3, p2_3, this.drag ? new Color(190, 190, 190) : (flag ? new Color(120, 120, 120) : new Color(70, 70, 70)), this.depth + 4);
            }
            string str1        = this._currentDirectory;
            int    startIndex1 = this._currentDirectory.IndexOf(this._rootFolder);

            if (startIndex1 != -1)
            {
                str1 = this._currentDirectory.Remove(startIndex1, this._rootFolder.Length);
            }
            string str2 = Path.GetFileName(this._rootFolder) + str1;

            if (str2 == "")
            {
                str2 = this._type != ContextFileType.Block ? (this._type != ContextFileType.Platform ? (this._type != ContextFileType.Background ? (this._type != ContextFileType.Parallax ? (this._type != ContextFileType.ArcadeStyle ? "LEVELS" : "Custom/Arcade") : "Custom/Parallax") : "Custom/Background") : "Custom/Platform") : "Custom/Blocks";
            }
            if (this._save)
            {
                DuckGame.Graphics.DrawString("@SAVEICON@Save Level - " + str2, p1_1 + new Vec2(5f, 7f), Color.White, this.depth + 8);
            }
            else if (this._selectLevels)
            {
                DuckGame.Graphics.DrawString("Select Active Levels - " + str2, p1_1 + new Vec2(5f, 7f), Color.White, this.depth + 8);
            }
            else if (this._type == ContextFileType.Block)
            {
                DuckGame.Graphics.DrawString("@LOADICON@Custom - " + str2, p1_1 + new Vec2(5f, 7f), Color.White, this.depth + 8);
            }
            else if (this._type == ContextFileType.Platform)
            {
                DuckGame.Graphics.DrawString("@LOADICON@Custom - " + str2, p1_1 + new Vec2(5f, 7f), Color.White, this.depth + 8);
            }
            else if (this._type == ContextFileType.Background)
            {
                DuckGame.Graphics.DrawString("@LOADICON@Custom - " + str2, p1_1 + new Vec2(5f, 7f), Color.White, this.depth + 8);
            }
            else if (this._type == ContextFileType.Parallax)
            {
                DuckGame.Graphics.DrawString("@LOADICON@Custom - " + str2, p1_1 + new Vec2(5f, 7f), Color.White, this.depth + 8);
            }
            else if (this._type == ContextFileType.ArcadeStyle)
            {
                DuckGame.Graphics.DrawString("@LOADICON@Custom - " + str2, p1_1 + new Vec2(5f, 7f), Color.White, this.depth + 8);
            }
            else
            {
                DuckGame.Graphics.DrawString("@LOADICON@Load Level - " + str2, p1_1 + new Vec2(5f, 7f), Color.White, this.depth + 8);
            }
            Vec2 p1_4 = new Vec2(p2_1.x + 2f, p1_1.y);
            Vec2 p2_4 = p1_4 + new Vec2(166f, 120f);

            if (this._previewSprite != null && this._previewSprite.texture != null && (this._type == ContextFileType.Block || this._type == ContextFileType.Background || (this._type == ContextFileType.Platform || this._type == ContextFileType.Parallax) || (this._type == ContextFileType.ArcadeStyle || this._type == ContextFileType.ArcadeAnimation)))
            {
                p2_4 = this._type != ContextFileType.Parallax ? p1_4 + new Vec2((float)(this._previewSprite.width + 4), (float)(this._previewSprite.height + 4)) : p1_4 + new Vec2((float)(this._previewSprite.width / 2 + 4), (float)(this._previewSprite.height / 2 + 4));
            }
            DuckGame.Graphics.DrawRect(p1_4, p2_4, new Color(70, 70, 70), this.depth, false);
            DuckGame.Graphics.DrawRect(p1_4, p2_4, new Color(30, 30, 30), this.depth - 8);
            if (this._previewSprite == null || this._previewSprite.texture == null)
            {
                return;
            }
            this._previewSprite.depth = new Depth(0.95f);
            this._previewSprite.scale = new Vec2(0.5f);
            if (this._type == ContextFileType.Block || this._type == ContextFileType.Background || this._type == ContextFileType.Platform)
            {
                this._previewSprite.scale = new Vec2(1f);
            }
            DuckGame.Graphics.Draw(this._previewSprite, p1_4.x + 2f, p1_4.y + 2f);
            if (Content.renderingPreview || Content.previewLevel == null || !(Content.previewLevel.level + ".lev" == this._prevPreviewPath))
            {
                return;
            }
            bool flag1 = false;

            if (Content.previewLevel.things[typeof(ChallengeMode)].Count <Thing>() > 0)
            {
                flag1 = true;
            }
            bool flag2 = false;

            if (Content.previewLevel.things[typeof(SpawnPoint)].Count <Thing>() == 0)
            {
                flag2 = true;
            }
            bool flag3 = false;

            if (Content.previewLevel.things[typeof(ArcadeMode)].Count <Thing>() > 0)
            {
                flag3 = true;
            }
            string str3        = Content.previewLevel.level;
            int    startIndex2 = str3.LastIndexOf("/");

            if (startIndex2 != -1)
            {
                str3 = str3.Substring(startIndex2, str3.Length - startIndex2);
            }
            if (str3.Length > 19)
            {
                string str4 = str3.Substring(0, 18) + ".";
            }
            if (flag2)
            {
                DuckGame.Graphics.DrawString("STRANGE MAP", p1_4 + new Vec2(5f, 107f), Colors.DGPurple, this.depth + 8);
            }
            else if (flag3)
            {
                DuckGame.Graphics.DrawString("ARCADE LAYOUT", p1_4 + new Vec2(5f, 107f), Colors.DGYellow, this.depth + 8);
            }
            else if (flag1)
            {
                DuckGame.Graphics.DrawString("CHALLENGE MAP", p1_4 + new Vec2(5f, 107f), Colors.DGRed, this.depth + 8);
            }
            else if (Content.previewLevel.onlineEnabled)
            {
                DuckGame.Graphics.DrawString("ONLINE MAP", p1_4 + new Vec2(5f, 107f), Colors.DGGreen, this.depth + 8);
            }
            else
            {
                DuckGame.Graphics.DrawString("MULTIPLAYER MAP", p1_4 + new Vec2(5f, 107f), Colors.DGBlue, this.depth + 8);
            }
        }
 public override void Update()
 {
     if (!this.opened || this._dialog.opened || (this._deleteDialog.opened || this._overwriteDialog.opened) || this._opening)
     {
         this._opening = false;
         foreach (ContextMenu contextMenu in this._items)
         {
             contextMenu.disabled = true;
         }
     }
     else
     {
         bool flag = false;
         foreach (ContextMenu contextMenu in this._items)
         {
             contextMenu.disabled = false;
             if (!flag && contextMenu.hover)
             {
                 flag = true;
                 string str        = "";
                 int    startIndex = this._currentDirectory.IndexOf(this._rootFolder);
                 if (startIndex != -1)
                 {
                     str = this._currentDirectory.Remove(startIndex, this._rootFolder.Length);
                 }
                 if (str != "" && !str.EndsWith("/"))
                 {
                     str += "/";
                 }
                 if (str.StartsWith("/"))
                 {
                     str = str.Substring(1, str.Length - 1);
                 }
                 string path = str + contextMenu.data;
                 if (this._prevPreviewPath != path)
                 {
                     if (path.EndsWith(".lev"))
                     {
                         if (this._preview == null || !(this._preview is RenderTarget2D))
                         {
                             this._preview = (Tex2D) new RenderTarget2D(320, 200);
                         }
                         this._preview = (Tex2D)Content.GeneratePreview(path.Substring(0, path.Length - 4), this._preview as RenderTarget2D);
                     }
                     else if (path.EndsWith(".png"))
                     {
                         Texture2D texture2D = ContentPack.LoadTexture2D(this._currentDirectory + "/" + Path.GetFileName(path));
                         this._preview = texture2D == null ? Content.invalidTexture : (this._type != ContextFileType.Block && this._type != ContextFileType.Background && this._type != ContextFileType.Platform || texture2D.Width == 128 && texture2D.Height == 128 ? (this._type != ContextFileType.Parallax || texture2D.Width == 320 && texture2D.Height == 240 ? (this._type != ContextFileType.ArcadeStyle || texture2D.Width == 27 && texture2D.Height == 34 || texture2D.Width == 54 && texture2D.Height == 68 ? (Tex2D)texture2D : this._badArcade.texture) : this._badParallax.texture) : this._badTileset.texture);
                     }
                     else
                     {
                         this._previewSprite   = (Sprite)null;
                         this._prevPreviewPath = (string)null;
                     }
                     this._previewSprite = new Sprite(this._preview);
                     if (this._type == ContextFileType.Block || this._type == ContextFileType.Background || (this._type == ContextFileType.Platform || this._type == ContextFileType.Parallax))
                     {
                         this._previewSprite.scale = new Vec2(2f, 2f);
                     }
                     this._prevPreviewPath = path;
                 }
             }
         }
         if (!flag && this._type == ContextFileType.ArcadeStyle)
         {
             this._preview         = this._badArcade.texture;
             this._previewSprite   = new Sprite(this._preview);
             this._prevPreviewPath = (string)null;
         }
         Editor.lockInput = (ContextMenu)this;
         base.Update();
         this._scrollWait = Lerp.Float(this._scrollWait, 0.0f, 0.2f);
         if (this._dialog.result != null && this._dialog.result != "")
         {
             Editor current = Level.current as Editor;
             current._guid = Guid.NewGuid().ToString();
             Editor.ResetWorkshopData();
             current.DoSave(this._currentDirectory + "/" + this._dialog.result);
             this._dialog.result = "";
             this.Close();
         }
         if (!this._overwriteDialog.opened && this._doOverwriteDialog)
         {
             this._doOverwriteDialog = false;
             if (this._overwriteDialog.result)
             {
                 (Level.current as Editor).DoSave(this._currentDirectory + "/" + this._overwriteName);
                 this._overwriteDialog.result = false;
                 this._overwriteName          = "";
                 this.Close();
             }
         }
         if (!this._deleteDialog.opened && this._doDeleteDialog)
         {
             this._doDeleteDialog = false;
             if (this._deleteDialog.result)
             {
                 foreach (ContextMenu contextMenu in this._items)
                 {
                     if (contextMenu.hover)
                     {
                         Editor.Delete(this._currentDirectory + "/" + contextMenu.text);
                         break;
                     }
                 }
                 this.ClearItems();
                 this.SetDirectory(this._currentDirectory);
             }
         }
         if (Keyboard.Pressed(Keys.Escape) || Mouse.right == InputState.Pressed || Input.Pressed("QUACK"))
         {
             this.Close();
         }
         if (!this._selectLevels && Input.Pressed("GRAB"))
         {
             this._deleteDialog.Open("CONFIRM DELETE");
             Editor.lockInput          = (ContextMenu)this._deleteDialog;
             this._doDeleteDialog      = true;
             this._deleteDialog.result = false;
         }
         else
         {
             if (Input.Pressed("LEFT"))
             {
                 this._selectedIndex -= this._maxItems;
             }
             else if (Input.Pressed("RIGHT"))
             {
                 this._selectedIndex += this._maxItems;
             }
             this._selectedIndex = Maths.Clamp(this._selectedIndex, 0, this._items.Count - 1);
             if (this._items.Count <= this._maxItems)
             {
                 return;
             }
             float num1 = 1f / (float)(this._items.Count - this._maxItems);
             if ((double)Mouse.scroll != 0.0)
             {
                 this._scrollPosition += (float)Math.Sign(Mouse.scroll) * num1;
                 if ((double)this._scrollPosition > 1.0)
                 {
                     this._scrollPosition = 1f;
                 }
                 if ((double)this._scrollPosition < 0.0)
                 {
                     this._scrollPosition = 0.0f;
                 }
             }
             int num2 = (int)Math.Round(((double)(this._items.Count - this._maxItems) - 1.0) * (double)this._scrollPosition);
             int num3 = 0;
             int num4 = 0;
             for (int index = 0; index < this._items.Count; ++index)
             {
                 if (this._items[index].hover)
                 {
                     num4 = index;
                     break;
                 }
             }
             if (Editor.gamepadMode)
             {
                 if (num4 > num2 + this._maxItems)
                 {
                     this._scrollPosition += (float)(num4 - (num2 + this._maxItems)) * num1;
                 }
                 else if (num4 < num2)
                 {
                     this._scrollPosition -= (float)(num2 - num4) * num1;
                 }
             }
             for (int index = 0; index < this._items.Count; ++index)
             {
                 this._items[index].disabled = false;
                 if (index < num2 || index > num2 + this._maxItems)
                 {
                     this._items[index].visible = false;
                     this._items[index].hover   = false;
                 }
                 else
                 {
                     ContextMenu contextMenu = this._items[index];
                     this._items[index].visible  = true;
                     this._items[index].position = new Vec2(this._items[index].position.x, (float)((double)this.y + 3.0 + (double)num3 * (double)this._items[index].itemSize.y));
                     ++num3;
                 }
             }
         }
     }
 }
 public override void UpdateParts()
 {
     if (!this.doubleUpdating && Input.Down("JUMP"))
     {
         this.doubleUpdating = true;
         this.UpdateParts();
         this.doubleUpdating = false;
     }
     if ((double)this.yOffset < 1.0)
     {
         if ((double)this._insertCoin < 1.0)
         {
             this._insertCoinInc += 0.008f;
             this._insertCoin    += this._insertCoinInc;
         }
         else
         {
             if (!this._chinged)
             {
                 SFX.Play("ching", pitch: Rando.Float(0.4f, 0.6f));
                 this._chinged = true;
             }
             this._insertCoin = 1f;
             if ((double)this._afterInsertWait < 1.0)
             {
                 this._afterInsertWait += 0.32f;
             }
             else
             {
                 if ((double)this._gachaWait >= 0.5 && !this.played)
                 {
                     this.played = true;
                     SFX.Play("gachaSound", pitch: Rando.Float(-0.1f, 0.1f));
                 }
                 this._gachaWait += 0.1f;
                 if ((double)this._gachaWait >= 1.0)
                 {
                     this.gachaSpeed += 0.25f;
                     if ((double)this.gachaSpeed > 6.0)
                     {
                         this.gachaSpeed = 6f;
                     }
                     this.gachaY += this.gachaSpeed;
                     if ((double)this.gachaY > 50.0 && (double)this.gachaSpeed > 0.0)
                     {
                         if ((double)this.gachaSpeed > 0.800000011920929)
                         {
                             SFX.Play("gachaBounce", pitch: 0.2f);
                         }
                         this.gachaY     = 50f;
                         this.gachaSpeed = (float)(-(double)this.gachaSpeed * 0.400000005960464);
                     }
                     this._openWait += 0.019f;
                     if ((double)this._openWait >= 1.0)
                     {
                         if (!this.opened)
                         {
                             this.opened = true;
                             SFX.Play("gachaOpen", pitch: Rando.Float(0.1f, 0.3f));
                             this._gachaEgg.frame += 2;
                         }
                         this._swapWait += 0.06f;
                         if ((double)this._swapWait >= 1.0)
                         {
                             if (!this._swapped)
                             {
                                 SFX.Play("harp");
                                 HUD.AddCornerControl(HUDCorner.BottomRight, "@SELECT@CONTINUE");
                                 Profiles.experienceProfile.SetNumFurnitures((int)this._contains.index, Profiles.experienceProfile.GetNumFurnitures((int)this._contains.index) + 1);
                             }
                             this._starGrow += 0.05f;
                             this._swapped   = true;
                         }
                     }
                 }
             }
         }
     }
     this.yOffset = Lerp.FloatSmooth(this.yOffset, this.down ? 150f : 0.0f, 0.4f, 1.1f);
     if (this.down)
     {
         if (this._swapped)
         {
             this.finished = true;
             this.Close();
         }
         else
         {
             this._downWait -= 0.06f;
             if ((double)this._downWait <= 0.0)
             {
                 this._downWait = 1f;
                 this.down      = false;
                 SFX.Play("gachaGet", pitch: -0.4f);
             }
         }
     }
     if (this._swapped && Input.Pressed("SELECT"))
     {
         HUD.CloseAllCorners();
         SFX.Play("resume", 0.6f);
         this.down = true;
     }
     base.UpdateParts();
 }
 public override void Update()
 {
     if (this._testMode)
     {
         this._wait += Maths.IncFrameTimer();
         if (Keyboard.Pressed(Keys.F5) || (double)this._wait > 0.1)
         {
             this._wait = 0.0f;
             try
             {
                 this._tie        = new SpriteMap((Tex2D)ContentPack.LoadTexture2D("tieTest.png"), 64, 64);
                 this._tie.center = new Vec2(26f, 27f);
             }
             catch (Exception ex)
             {
             }
         }
     }
     DuckGame.Graphics.fadeAdd = Lerp.Float(DuckGame.Graphics.fadeAdd, 0.0f, 0.01f);
     if (Main.isDemo && this._skip && !this._firedSkipLogic)
     {
         this._firedSkipLogic = true;
         Vote.CloseVoting();
         HUD.CloseAllCorners();
         this.DoSkip();
     }
     if ((double)DuckGame.Graphics.fade > 0.990000009536743 && !this._skip && Vote.Passed(VoteType.Skip))
     {
         this._skip = true;
     }
     if (this._talker.finished || !HighlightLevel._cancelSkip && this._skip && !Main.isDemo)
     {
         this._done -= 0.04f;
     }
     DuckGame.Graphics.fade = Lerp.Float(DuckGame.Graphics.fade, (double)this._done < 0.0 ? 0.0f : 1f, 0.02f);
     if ((double)DuckGame.Graphics.fade < 0.00999999977648258 && (this._talker.finished || this._skip))
     {
         if (this._endOfHighlights || this._skip)
         {
             Vote.CloseVoting();
             Level.current = (Level) new RockScoreboard(RockScoreboard.returnLevel, ScoreBoardMode.ShowWinner, true);
         }
         else
         {
             Level.current = (Level) new HighlightPlayback(4);
         }
     }
     if (this._state == TVState.ShowPedestals)
     {
         this._waitZoom -= 0.008f;
         if ((double)this._waitZoom < 0.00999999977648258)
         {
             this._waitZoom     = 0.0f;
             this._desiredState = TVState.ShowNewscaster;
         }
     }
     if (this._state == TVState.ShowHotness && this._hotness.ready)
     {
         this._talker.Resume();
     }
     if (this._state == TVState.ShowInterview)
     {
         this._interviewWait -= 0.02f;
         if ((double)this._interviewWait < 0.0 && !this._askedQuestion)
         {
             this._talker.InsertLine(Script.winner() + "! To what do you attribute your success?", this._interviewIndex);
             this._talker.Resume();
             this._askedQuestion = true;
         }
     }
     this._cameraOffset.x = Lerp.Float(this._cameraOffset.x, HighlightLevel._image != null ? 20f : 0.0f, 2f);
     this._talker.active  = this._talker.visible = this._state != TVState.ShowPedestals;
     if (this._state == this._desiredState)
     {
         return;
     }
     this._talker.active = false;
     this._transition.PlaySwipe();
     if (!this._transition.doTransition)
     {
         return;
     }
     this._state = this._desiredState;
 }
示例#18
0
 // Token: 0x06000CCA RID: 3274
 public override void Update()
 {
     base.Update();
     if (this._swordSwing.finished)
     {
         this._swordSwing.speed = 0f;
     }
     if (this._hitWait > 0)
     {
         this._hitWait--;
     }
     this._framesExisting++;
     if (this._framesExisting > 100)
     {
         this._framesExisting = 100;
     }
     if (Math.Abs(this.hSpeed) + Math.Abs(this.vSpeed) > 4f && this._framesExisting > 10)
     {
         this._wasLifted = true;
     }
     if (this.owner != null)
     {
         this._hold              = -0.4f;
         this._wasLifted         = true;
         this.center             = new Vec2(4f, 21f);
         this._framesSinceThrown = 0;
     }
     else
     {
         if (this._framesSinceThrown == 1)
         {
             this._throwSpin = Maths.RadToDeg(this.angle) - 90f;
             this._hold      = 0f;
             this._swing     = 0f;
         }
         if (this._wasLifted)
         {
             base.angleDegrees = 90f + this._throwSpin;
             this.center       = new Vec2(4f, 11f);
         }
         this._volatile = false;
         bool spinning    = false;
         bool againstWall = false;
         if (Math.Abs(this.hSpeed) + Math.Abs(this.vSpeed) > 2f || !base.grounded)
         {
             if (!base.grounded && Level.CheckRect <Block>(this.position + new Vec2(-6f, -6f), this.position + new Vec2(6f, -2f), null) != null)
             {
                 againstWall = true;
                 if (this.vSpeed > 4f)
                 {
                     this._volatile = true;
                 }
             }
             if (!againstWall && !this._grounded && Level.CheckPoint <IPlatform>(this.position + new Vec2(0f, 8f), null, null) == null)
             {
                 if (this.hSpeed > 0f)
                 {
                     this._throwSpin += (Math.Abs(this.hSpeed) + Math.Abs(this.vSpeed)) * 2f + 4f;
                 }
                 else
                 {
                     this._throwSpin -= (Math.Abs(this.hSpeed) + Math.Abs(this.vSpeed)) * 2f + 4f;
                 }
                 spinning = true;
             }
         }
         if (this._framesExisting > 15 && Math.Abs(this.hSpeed) + Math.Abs(this.vSpeed) > 3f)
         {
             this._volatile = true;
         }
         if (!spinning || againstWall)
         {
             this._throwSpin %= 360f;
             if (againstWall)
             {
                 if (Math.Abs(this._throwSpin - 90f) < Math.Abs(this._throwSpin + 90f))
                 {
                     this._throwSpin = Lerp.Float(this._throwSpin, 90f, 16f);
                 }
                 else
                 {
                     this._throwSpin = Lerp.Float(-90f, 0f, 16f);
                 }
             }
             else if (this._throwSpin > 90f && this._throwSpin < 270f)
             {
                 this._throwSpin = Lerp.Float(this._throwSpin, 180f, 14f);
             }
             else
             {
                 if (this._throwSpin > 180f)
                 {
                     this._throwSpin -= 360f;
                 }
                 else if (this._throwSpin < -180f)
                 {
                     this._throwSpin += 360f;
                 }
                 this._throwSpin = Lerp.Float(this._throwSpin, 0f, 14f);
             }
         }
         if (this._volatile && this._hitWait == 0)
         {
             (this.Offset(base.barrelOffset) - this.position).Normalize();
             this.Offset(base.barrelOffset);
             bool rebound = false;
             foreach (Thing thing in Level.current.things[typeof(Sword)])
             {
                 Sword s = (Sword)thing;
                 if (s != this && s.owner != null && s._crouchStance && !s._jabStance && !s._jabStance && ((this.hSpeed > 0f && s.x > base.x - 4f) || (this.hSpeed < 0f && s.x < base.x + 4f)) && Collision.LineIntersect(this.barrelStartPos, base.barrelPosition, s.barrelStartPos, s.barrelPosition))
                 {
                     this.Shing();
                     s.Shing();
                     s.owner.hSpeed += (float)this.offDir * 1f;
                     s.owner.vSpeed -= 1f;
                     rebound         = true;
                     this._hitWait   = 4;
                     this.hSpeed     = -this.hSpeed * 0.6f;
                 }
             }
             int waitFrames = 12;
             if (!rebound)
             {
                 foreach (Thing thing2 in Level.current.things[typeof(Chainsaw)])
                 {
                     Chainsaw s2 = (Chainsaw)thing2;
                     if (s2.owner != null && s2.throttle && Collision.LineIntersect(this.barrelStartPos, base.barrelPosition, s2.barrelStartPos, s2.barrelPosition))
                     {
                         this.Shing();
                         s2.Shing(this);
                         s2.owner.hSpeed += (float)this.offDir * 1f;
                         s2.owner.vSpeed -= 1f;
                         rebound          = true;
                         this.hSpeed      = -this.hSpeed * 0.6f;
                         this._hitWait    = 4;
                         if (Recorder.currentRecording != null)
                         {
                             Recorder.currentRecording.LogBonus();
                         }
                     }
                 }
                 if (!rebound)
                 {
                     Helmet helmetHit = Level.CheckLine <Helmet>(this.barrelStartPos, base.barrelPosition, null);
                     if (helmetHit != null && helmetHit.equippedDuck != null && (helmetHit.owner != base.prevOwner || (int)this._framesSinceThrown > waitFrames))
                     {
                         this.hSpeed = -this.hSpeed * 0.6f;
                         this.Shing();
                         rebound       = true;
                         this._hitWait = 4;
                     }
                     else
                     {
                         ChestPlate chestHit = Level.CheckLine <ChestPlate>(this.barrelStartPos, base.barrelPosition, null);
                         if (chestHit != null && chestHit.equippedDuck != null && (chestHit.owner != base.prevOwner || (int)this._framesSinceThrown > waitFrames))
                         {
                             this.hSpeed = -this.hSpeed * 0.6f;
                             this.Shing();
                             rebound       = true;
                             this._hitWait = 4;
                         }
                     }
                 }
             }
             if (!rebound && base.isServerForObject)
             {
                 foreach (IAmADuck d in Level.CheckLineAll <IAmADuck>(this.barrelStartPos, base.barrelPosition))
                 {
                     if (d != base.duck)
                     {
                         MaterialThing realThing = d as MaterialThing;
                         if (realThing != null && (realThing != base.prevOwner || (int)this._framesSinceThrown > waitFrames))
                         {
                             realThing.Destroy(new DTImpale(this));
                             if (Recorder.currentRecording != null)
                             {
                                 Recorder.currentRecording.LogBonus();
                             }
                         }
                     }
                 }
             }
         }
     }
     if (this.owner == null)
     {
         this._swinging     = false;
         this._jabStance    = false;
         this._crouchStance = false;
         this._pullBack     = false;
         this._swung        = false;
         this._shing        = false;
         this._swing        = 0f;
         this._swingPress   = false;
         this._slamStance   = false;
         this._unslam       = 0;
     }
     if (base.isServerForObject)
     {
         if (this._unslam > 1)
         {
             this._unslam--;
             this._slamStance = true;
         }
         else if (this._unslam == 1)
         {
             this._unslam     = 0;
             this._slamStance = false;
         }
         if (this._pullBack)
         {
             if (base.duck != null)
             {
                 if (this._jabStance)
                 {
                     this._pullBack = false;
                     this._swinging = true;
                 }
                 else
                 {
                     this._swinging = true;
                     this._pullBack = false;
                 }
             }
         }
         else if (this._swinging)
         {
             if (this._jabStance)
             {
                 this._addOffsetX = MathHelper.Lerp(this._addOffsetX, 3f, 0.4f);
                 if (this._addOffsetX > 2f && !this.action)
                 {
                     this._swinging = false;
                 }
             }
             else if (base.raised)
             {
                 this._swing = MathHelper.Lerp(this._swing, -2.8f, 0.2f);
                 if (this._swing < -2.4f && !this.action)
                 {
                     this._swinging = false;
                     this._swing    = 1.8f;
                 }
             }
             else
             {
                 this._swing = MathHelper.Lerp(this._swing, 2.1f, 0.4f);
                 if (this._swing > 1.8f && !this.action)
                 {
                     this._swinging = false;
                     this._swing    = 1.8f;
                 }
             }
         }
         else
         {
             if (!this._swinging && (!this._swingPress || this._shing || (this._jabStance && this._addOffsetX < 1f) || (!this._jabStance && this._swing < 1.6f)))
             {
                 if (this._jabStance)
                 {
                     this._swing = MathHelper.Lerp(this._swing, 1.75f, 0.4f);
                     if (this._swing > 1.55f)
                     {
                         this._swing = 1.55f;
                         this._shing = false;
                         this._swung = false;
                     }
                     this._addOffsetX = MathHelper.Lerp(this._addOffsetX, -12f, 0.45f);
                     if (this._addOffsetX < -12f)
                     {
                         this._addOffsetX = -12f;
                     }
                     this._addOffsetY = MathHelper.Lerp(this._addOffsetY, -4f, 0.35f);
                     if (this._addOffsetX < -3f)
                     {
                         this._addOffsetY = -3f;
                     }
                 }
                 else if (this._slamStance)
                 {
                     this._swing = MathHelper.Lerp(this._swing, 3.14f, 0.8f);
                     if (this._swing > 3.1f && this._unslam == 0)
                     {
                         this._swing = 3.14f;
                         this._shing = false;
                         this._swung = true;
                     }
                     this._addOffsetX = MathHelper.Lerp(this._addOffsetX, -5f, 0.45f);
                     if (this._addOffsetX < -4.6f)
                     {
                         this._addOffsetX = -5f;
                     }
                     this._addOffsetY = MathHelper.Lerp(this._addOffsetY, -6f, 0.35f);
                     if (this._addOffsetX < -5.5f)
                     {
                         this._addOffsetY = -6f;
                     }
                 }
                 else
                 {
                     this._swing      = MathHelper.Lerp(this._swing, -0.22f, 0.36f);
                     this._addOffsetX = MathHelper.Lerp(this._addOffsetX, 1f, 0.2f);
                     if (this._addOffsetX > 0f)
                     {
                         this._addOffsetX = 0f;
                     }
                     this._addOffsetY = MathHelper.Lerp(this._addOffsetY, 1f, 0.2f);
                     if (this._addOffsetY > 0f)
                     {
                         this._addOffsetY = 0f;
                     }
                 }
             }
             if ((this._swing < 0f || this._jabStance) && this._swing < 0f)
             {
                 this._swing = 0f;
                 this._shing = false;
                 this._swung = false;
             }
         }
     }
     if (base.duck != null)
     {
         this.collisionOffset = new Vec2(-4f, 0f);
         this.collisionSize   = new Vec2(4f, 4f);
         if (this._crouchStance && !this._jabStance)
         {
             this.collisionOffset = new Vec2(-2f, -19f);
             this.collisionSize   = new Vec2(4f, 16f);
             this.thickness       = 3f;
         }
         this._swingPress = false;
         if (!this._pullBack && !this._swinging)
         {
             this._crouchStance = false;
             this._jabStance    = false;
             if (base.duck.crouch)
             {
                 if (!this._pullBack && !this._swinging && base.duck.inputProfile.Down((this.offDir > 0) ? "LEFT" : "RIGHT"))
                 {
                     this._jabStance = true;
                 }
                 this._crouchStance = true;
             }
             if (!this._crouchStance || this._jabStance)
             {
                 this._slamStance = false;
             }
         }
         if (!this._crouchStance)
         {
             this._hold       = -0.4f;
             this.handOffset  = new Vec2(this._addOffsetX, this._addOffsetY);
             this._holdOffset = new Vec2(-4f + this._addOffsetX, 4f + this._addOffsetY);
         }
         else
         {
             this._hold       = 0f;
             this._holdOffset = new Vec2(0f + this._addOffsetX, 4f + this._addOffsetY);
             this.handOffset  = new Vec2(3f + this._addOffsetX, this._addOffsetY);
         }
     }
     else
     {
         this.collisionOffset = new Vec2(-2f, -16f);
         this.collisionSize   = new Vec2(4f, 18f);
         if (this._wasLifted)
         {
             this.collisionOffset = new Vec2(-4f, -2f);
             this.collisionSize   = new Vec2(8f, 4f);
         }
         this.thickness = 0f;
     }
     if ((this._swung || this._swinging) && !this._shing)
     {
         (this.Offset(base.barrelOffset) - this.position).Normalize();
         this.Offset(base.barrelOffset);
         IEnumerable <IAmADuck> hit2 = Level.CheckLineAll <IAmADuck>(this.barrelStartPos, base.barrelPosition);
         Block wallHit = Level.CheckLine <Block>(this.barrelStartPos, base.barrelPosition, null);
         if (wallHit != null && !this._slamStance)
         {
             if (this.offDir < 0 && wallHit.x > base.x)
             {
                 wallHit = null;
             }
             else if (this.offDir > 0 && wallHit.x < base.x)
             {
                 wallHit = null;
             }
         }
         bool clashed = false;
         if (wallHit != null)
         {
             this.Shing();
             if (this._slamStance)
             {
                 this._swung       = false;
                 this._unslam      = 20;
                 this.owner.vSpeed = -5f;
             }
             if (wallHit is Window)
             {
                 wallHit.Destroy(new DTImpact(this));
             }
         }
         else if (!this._jabStance && !this._slamStance)
         {
             Thing ignore = null;
             if (base.duck != null)
             {
                 ignore = base.duck.GetEquipment(typeof(Helmet));
             }
             Vec2            barrel   = base.barrelPosition + base.barrelVector * 3f;
             Vec2            p3       = new Vec2((this.position.x < barrel.x) ? this.position.x : barrel.x, (this.position.y < barrel.y) ? this.position.y : barrel.y);
             Vec2            p2       = new Vec2((this.position.x > barrel.x) ? this.position.x : barrel.x, (this.position.y > barrel.y) ? this.position.y : barrel.y);
             QuadLaserBullet laserHit = Level.CheckRect <QuadLaserBullet>(p3, p2, null);
             if (laserHit != null)
             {
                 this.Shing();
                 base.Fondle(laserHit);
                 laserHit.safeFrames = 8;
                 laserHit.safeDuck   = base.duck;
                 Vec2  travel = laserHit.travel;
                 float mag    = travel.length;
                 float mul    = 1f;
                 if (this.offDir > 0 && travel.x < 0f)
                 {
                     mul = 1.5f;
                 }
                 else if (this.offDir < 0 && travel.x > 0f)
                 {
                     mul = 1.5f;
                 }
                 if (this.offDir > 0)
                 {
                     travel = new Vec2(mag * mul, 0f);
                 }
                 else
                 {
                     travel = new Vec2(-mag * mul, 0f);
                 }
                 laserHit.travel = travel;
             }
             else
             {
                 Helmet helmetHit2 = Level.CheckLine <Helmet>(this.barrelStartPos, base.barrelPosition, ignore);
                 if (helmetHit2 != null && helmetHit2.equippedDuck != null)
                 {
                     this.Shing();
                     helmetHit2.owner.hSpeed     += (float)this.offDir * 3f;
                     helmetHit2.owner.vSpeed     -= 2f;
                     helmetHit2.duck.crippleTimer = 1f;
                     helmetHit2.Hurt(0.53f);
                     clashed = true;
                 }
                 else
                 {
                     if (base.duck != null)
                     {
                         ignore = base.duck.GetEquipment(typeof(ChestPlate));
                     }
                     ChestPlate chestHit2 = Level.CheckLine <ChestPlate>(this.barrelStartPos, base.barrelPosition, ignore);
                     if (chestHit2 != null && chestHit2.equippedDuck != null)
                     {
                         this.Shing();
                         chestHit2.owner.hSpeed     += (float)this.offDir * 3f;
                         chestHit2.owner.vSpeed     -= 2f;
                         chestHit2.duck.crippleTimer = 1f;
                         chestHit2.Hurt(0.53f);
                         clashed = true;
                     }
                 }
             }
         }
         if (!clashed)
         {
             foreach (Thing thing3 in Level.current.things[typeof(Sword)])
             {
                 Sword s3 = (Sword)thing3;
                 if (s3 != this && s3.duck != null && !this._jabStance && !s3._jabStance && base.duck != null && Collision.LineIntersect(this.barrelStartPos, base.barrelPosition, s3.barrelStartPos, s3.barrelPosition))
                 {
                     this.Shing();
                     s3.Shing();
                     s3.owner.hSpeed       += (float)this.offDir * 3f;
                     s3.owner.vSpeed       -= 2f;
                     base.duck.hSpeed      += -(float)this.offDir * 3f;
                     base.duck.vSpeed      -= 2f;
                     s3.duck.crippleTimer   = 1f;
                     base.duck.crippleTimer = 1f;
                     clashed = true;
                 }
             }
         }
         if (clashed)
         {
             return;
         }
         using (IEnumerator <IAmADuck> enumerator5 = hit2.GetEnumerator())
         {
             while (enumerator5.MoveNext())
             {
                 IAmADuck d2 = enumerator5.Current;
                 if (d2 != base.duck)
                 {
                     MaterialThing realThing2 = d2 as MaterialThing;
                     if (realThing2 != null)
                     {
                         realThing2.Destroy(new DTImpale(this));
                     }
                 }
             }
             return;
         }
     }
     if (this._crouchStance && base.duck != null)
     {
         foreach (IAmADuck d3 in Level.CheckLineAll <IAmADuck>(this.barrelStartPos, base.barrelPosition))
         {
             if (d3 != base.duck)
             {
                 MaterialThing realThing3 = d3 as MaterialThing;
                 if (realThing3 != null)
                 {
                     if (realThing3.vSpeed > 0.5f && realThing3.bottom < this.position.y - 8f && realThing3.left < base.barrelPosition.x && realThing3.right > base.barrelPosition.x)
                     {
                         realThing3.Destroy(new DTImpale(this));
                     }
                     else if (!this._jabStance && !realThing3.destroyed && ((this.offDir > 0 && realThing3.x > base.duck.x) || (this.offDir < 0 && realThing3.x < base.duck.x)))
                     {
                         if (realThing3 is Duck)
                         {
                             (realThing3 as Duck).crippleTimer = 1f;
                         }
                         else if ((base.duck.x > realThing3.x && realThing3.hSpeed > 1.5f) || (base.duck.x < realThing3.x && realThing3.hSpeed < -1.5f))
                         {
                             realThing3.Destroy(new DTImpale(this));
                         }
                         base.Fondle(realThing3);
                         realThing3.hSpeed = (float)this.offDir * 3f;
                         realThing3.vSpeed = -2f;
                     }
                 }
             }
         }
     }
 }
 public override void Update()
 {
     this.yOffset = Lerp.FloatSmooth(this.yOffset, this.down ? 150f : 0.0f, 0.3f, 1.1f);
     if (this.down)
     {
         if (this._unlocks.Count == 0)
         {
             if (!this.finished)
             {
                 this.finished = true;
                 this.Close();
             }
         }
         else
         {
             this._downWait -= 0.06f;
             if ((double)this._downWait <= 0.0)
             {
                 this._openWait = 1f;
                 this._wrapped  = true;
                 this._downWait = 1f;
                 this._unlock   = this._unlocks.First <Unlockable>();
                 this._unlocks.RemoveAt(0);
                 this.down = false;
                 SFX.Play("pause", 0.6f);
             }
         }
     }
     else
     {
         this._openWait -= 0.06f;
         if ((double)this._openWait <= 0.0 && this._wrapped && !this._flash)
         {
             this._flash = true;
         }
         if (this._flash)
         {
             Graphics.flashAdd = Lerp.Float(Graphics.flashAdd, 1f, 0.2f);
             if ((double)Graphics.flashAdd > 0.990000009536743)
             {
                 this._wrapped = !this._wrapped;
                 if (!this._wrapped)
                 {
                     if (this._unlock != null && this._unlock.name == "UR THE BEST")
                     {
                         this._oldSong = Music.currentSong;
                         Music.Play("jollyjingle");
                     }
                     SFX.Play("harp");
                     HUD.AddCornerControl(HUDCorner.BottomRight, "@SELECT@CONTINUE");
                     this._unlock.DoUnlock();
                 }
                 this._flash = false;
             }
         }
         else
         {
             Graphics.flashAdd = Lerp.Float(Graphics.flashAdd, 0.0f, 0.2f);
         }
         if (!this._wrapped && Input.Pressed("SELECT"))
         {
             HUD.CloseAllCorners();
             SFX.Play("resume", 0.6f);
             if (this._oldSong != null && this._unlock != null && this._unlock.name == "UR THE BEST")
             {
                 Music.Play(this._oldSong);
             }
             this.down = true;
         }
     }
     base.Update();
 }
        public override void Update()
        {
            float num = this.stick;

            if (this.scanStage < 2)
            {
                Level.current.backgroundColor = Lerp.Color(Level.current.backgroundColor, this.backgroundColor, 0.04f);
                num = 0.0f;
            }
            else if (this._realBackground != null)
            {
                Level.current.backgroundColor = Lerp.Color(Level.current.backgroundColor, this._realBackground.backgroundColor, 0.04f);
            }
            Rectangle rectangle1 = new Rectangle((float)(int)((1.0 - (double)num) * (double)Graphics.width), 0.0f, (float)(Graphics.width - (int)((1.0 - (double)num) * (double)Graphics.width)), (float)Graphics.height);

            if (this._realBackground != null)
            {
                if ((double)rectangle1.width == 0.0)
                {
                    this._realBackground.SetVisible(false);
                }
                else
                {
                    this._realBackground.scissor = rectangle1;
                    this._realBackground.SetVisible(true);
                }
            }
            Rectangle rectangle2 = new Rectangle(0.0f, 0.0f, (float)Graphics.width - rectangle1.width, (float)Graphics.height);

            if ((double)rectangle2.width == 0.0)
            {
                this.SetVisible(false);
                this.visible = false;
            }
            else
            {
                this.scissor = rectangle2;
                this.SetVisible(true);
                this.visible = true;
            }
            if (this.virtualMode && this.done && this.scanStage == 3)
            {
                --this.scanStage;
            }
            else if (!this.virtualMode && !this.done && this.scanStage == -1)
            {
                ++this.scanStage;
            }
            float amount1 = 0.04f;
            float amount2 = 0.06f;

            if (Level.current != null)
            {
                amount1 *= Level.current.transitionSpeedMultiplier;
                amount2 *= Level.current.transitionSpeedMultiplier;
            }
            if (!this.done)
            {
                if (this.scanStage == 0)
                {
                    this.stick = Lerp.Float(this.stick, 1f, amount1);
                    if ((double)this.stick > 0.949999988079071)
                    {
                        this.stick    = 1f;
                        this.incStage = true;
                    }
                }
                else if (this.scanStage == 1)
                {
                    this.stick = Lerp.Float(this.stick, 0.0f, amount1);
                    if ((double)this.stick < 0.0500000007450581)
                    {
                        this.stick    = 0.0f;
                        this.incStage = true;
                    }
                }
                else if (this.scanStage == 2)
                {
                    this.stick = Lerp.Float(this.stick, 1f, amount1);
                    if ((double)this.stick > 0.949999988079071)
                    {
                        this.stick    = 1f;
                        this.incStage = true;
                        this.done     = true;
                    }
                }
            }
            else if (this.scanStage == 2)
            {
                this.stick = Lerp.Float(this.stick, 0.0f, amount2);
                if ((double)this.stick < 0.0500000007450581)
                {
                    this.stick    = 0.0f;
                    this.decStage = true;
                }
            }
            else if (this.scanStage == 1)
            {
                this.stick = Lerp.Float(this.stick, 1f, amount2);
                if ((double)this.stick > 0.949999988079071)
                {
                    this.stick    = 1f;
                    this.decStage = true;
                }
            }
            else if (this.scanStage == 0)
            {
                this.stick = Lerp.Float(this.stick, 0.0f, amount2);
                if ((double)this.stick < 0.0500000007450581)
                {
                    this.stick    = 0.0f;
                    this.decStage = true;
                    this.done     = false;
                }
            }
            if (this.scanStage < 2)
            {
                Layer.basicWireframeEffect.effect.Parameters["screenCross"].SetValue(this.stick);
                Layer.basicWireframeTex = this.scanStage == 1;
            }
            if (this.incStage)
            {
                this.incStage = false;
                ++this.scanStage;
            }
            if (this.decStage)
            {
                this.decStage = false;
                --this.scanStage;
            }
            this.fullyVirtual    = false;
            this.fullyNonVirtual = false;
            if (this.scanStage == 3)
            {
                this.needsWireframe  = false;
                this.fullyNonVirtual = true;
            }
            else
            {
                this.needsWireframe = true;
                if (this.scanStage == -1)
                {
                    this.fullyVirtual = true;
                }
            }
            base.Update();
        }
示例#21
0
 public override void Update()
 {
     if (Network.isActive && this._prevVisible && !this.visible)
     {
         for (int i = 0; i < 4; i++)
         {
             SmallSmoke s = SmallSmoke.New(base.x + Rando.Float(-4f, 4f), base.y + Rando.Float(-4f, 4f));
             s.hSpeed += this.hSpeed * Rando.Float(0.3f, 0.5f);
             s.vSpeed -= Rando.Float(0.1f, 0.2f);
             Level.Add(s);
         }
     }
     if (this._duckOwner == null)
     {
         return;
     }
     this._framesSinceTransfer++;
     base.Update();
     if (base.y > Level.current.lowestPoint + 100f)
     {
         this.OnDestroy(new DTFall());
     }
     this.jumpCountdown -= Maths.IncFrameTimer();
     this._prevVisible   = this.visible;
     this._shakeInc     += 0.8f;
     this._shakeMult     = Lerp.Float(this._shakeMult, 0f, 0.05f);
     if (Network.isActive && this._duckOwner._trapped == this && !this._duckOwner.isServerForObject && this._duckOwner.inputProfile.Pressed("JUMP", false))
     {
         this._shakeMult = 1f;
     }
     if (this._duckOwner.isServerForObject && this._duckOwner._trapped == this)
     {
         if (!this.visible)
         {
             base.y = -9999f;
         }
         if (!this.infinite)
         {
             this._duckOwner.profile.stats.timeInNet += Maths.IncFrameTimer();
             if (this._duckOwner.inputProfile.Pressed("JUMP", false))
             {
                 this._shakeMult    = 1f;
                 this._trapTime    -= 0.007f;
                 this.jumpCountdown = 0.25f;
             }
             if (base.grounded && this._duckOwner.inputProfile.Pressed("JUMP", false))
             {
                 this._shakeMult = 1f;
                 this._trapTime -= 0.028f;
                 if (this.owner == null)
                 {
                     if (Math.Abs(this.hSpeed) < 1f && this._framesSinceTransfer > 30)
                     {
                         this._duckOwner.Fondle(this);
                     }
                     this.vSpeed -= Rando.Float(0.8f, 1.1f);
                     if (this._duckOwner.inputProfile.Down("LEFT") && this.hSpeed > -1f)
                     {
                         this.hSpeed -= Rando.Float(0.6f, 0.8f);
                     }
                     if (this._duckOwner.inputProfile.Down("RIGHT") && this.hSpeed < 1f)
                     {
                         this.hSpeed += Rando.Float(0.6f, 0.8f);
                     }
                 }
             }
             if (this._duckOwner.inputProfile.Pressed("JUMP", false) && this._duckOwner.HasEquipment(typeof(Jetpack)))
             {
                 Equipment e = this._duckOwner.GetEquipment(typeof(Jetpack));
                 e.PressAction();
             }
             if (this._duckOwner.inputProfile.Released("JUMP") && this._duckOwner.HasEquipment(typeof(Jetpack)))
             {
                 Equipment e2 = this._duckOwner.GetEquipment(typeof(Jetpack));
                 e2.ReleaseAction();
             }
             this._trapTime -= 0.0028f;
             if (this._trapTime <= 0f || this._duckOwner.dead)
             {
                 this.OnDestroy(null);
             }
         }
         if (this.owner == null)
         {
             base.depth = this._duckOwner.depth;
         }
         this._duckOwner.position = this.position;
         this._duckOwner.UpdateSkeleton();
     }
 }
示例#22
0
 public override void Update()
 {
     base.Update();
     this._sprite.frame = this._owner == null || this._raised ? 0 : 1;
     this._raiseArm     = Lerp.Float(this._raiseArm, 0.0f, 0.05f);
     this._preachWait   = Lerp.Float(this._preachWait, 0.0f, 0.06f);
     this._ringPulse    = Lerp.Float(this._ringPulse, 0.0f, 0.05f);
     if (Network.isActive)
     {
         if (this.isServerForObject)
         {
             if (this.controlling1)
             {
                 Duck duck = this.GetDuck(0);
                 if (duck != null)
                 {
                     if (duck.listenTime <= 0)
                     {
                         this.controlling1 = false;
                     }
                     else
                     {
                         this.Fondle((Thing)duck);
                         this.Fondle((Thing)duck.holdObject);
                         foreach (Thing t in duck._equipment)
                         {
                             this.Fondle(t);
                         }
                         this.Fondle((Thing)duck._ragdollInstance);
                         this.Fondle((Thing)duck._trappedInstance);
                         this.Fondle((Thing)duck._cookedInstance);
                     }
                 }
             }
             if (this.controlling2)
             {
                 Duck duck = this.GetDuck(1);
                 if (duck != null)
                 {
                     if (duck.listenTime <= 0)
                     {
                         this.controlling2 = false;
                     }
                     else
                     {
                         this.Fondle((Thing)duck);
                         this.Fondle((Thing)duck.holdObject);
                         foreach (Thing t in duck._equipment)
                         {
                             this.Fondle(t);
                         }
                         this.Fondle((Thing)duck._ragdollInstance);
                         this.Fondle((Thing)duck._trappedInstance);
                         this.Fondle((Thing)duck._cookedInstance);
                     }
                 }
             }
             if (this.controlling3)
             {
                 Duck duck = this.GetDuck(2);
                 if (duck != null)
                 {
                     if (duck.listenTime <= 0)
                     {
                         this.controlling3 = false;
                     }
                     else
                     {
                         this.Fondle((Thing)duck);
                         this.Fondle((Thing)duck.holdObject);
                         foreach (Thing t in duck._equipment)
                         {
                             this.Fondle(t);
                         }
                         this.Fondle((Thing)duck._ragdollInstance);
                         this.Fondle((Thing)duck._trappedInstance);
                         this.Fondle((Thing)duck._cookedInstance);
                     }
                 }
             }
             if (this.controlling4)
             {
                 Duck duck = this.GetDuck(3);
                 if (duck != null)
                 {
                     if (duck.listenTime <= 0)
                     {
                         this.controlling4 = false;
                     }
                     else
                     {
                         this.Fondle((Thing)duck);
                         this.Fondle((Thing)duck.holdObject);
                         foreach (Thing t in duck._equipment)
                         {
                             this.Fondle(t);
                         }
                         this.Fondle((Thing)duck._ragdollInstance);
                         this.Fondle((Thing)duck._trappedInstance);
                         this.Fondle((Thing)duck._cookedInstance);
                     }
                 }
             }
         }
         else
         {
             Duck duck1 = this.GetDuck(0);
             if (duck1 != null)
             {
                 if (this.controlling1)
                 {
                     duck1.listening = true;
                     duck1.Fondle((Thing)duck1.holdObject);
                     foreach (Equipment equipment in duck1._equipment)
                     {
                         duck1.Fondle((Thing)equipment);
                     }
                     duck1.Fondle((Thing)duck1._ragdollInstance);
                     duck1.Fondle((Thing)duck1._trappedInstance);
                     duck1.Fondle((Thing)duck1._cookedInstance);
                 }
                 if (!this.controlling1 && this.prevControlling1)
                 {
                     duck1.listening = false;
                 }
                 this.prevControlling1 = this.controlling1;
             }
             Duck duck2 = this.GetDuck(1);
             if (duck2 != null)
             {
                 if (this.controlling2)
                 {
                     duck2.listening = true;
                     duck2.Fondle((Thing)duck2.holdObject);
                     foreach (Equipment equipment in duck2._equipment)
                     {
                         duck2.Fondle((Thing)equipment);
                     }
                     duck2.Fondle((Thing)duck2._ragdollInstance);
                     duck2.Fondle((Thing)duck2._trappedInstance);
                     duck2.Fondle((Thing)duck2._cookedInstance);
                 }
                 if (!this.controlling2 && this.prevControlling2)
                 {
                     duck2.listening = false;
                 }
                 this.prevControlling2 = this.controlling2;
             }
             Duck duck3 = this.GetDuck(2);
             if (duck3 != null)
             {
                 if (this.controlling3)
                 {
                     duck3.listening = true;
                     duck3.Fondle((Thing)duck3.holdObject);
                     foreach (Equipment equipment in duck3._equipment)
                     {
                         duck3.Fondle((Thing)equipment);
                     }
                     duck3.Fondle((Thing)duck3._ragdollInstance);
                     duck3.Fondle((Thing)duck3._trappedInstance);
                     duck3.Fondle((Thing)duck3._cookedInstance);
                 }
                 if (!this.controlling3 && this.prevControlling3)
                 {
                     duck3.listening = false;
                 }
                 this.prevControlling3 = this.controlling3;
             }
             Duck duck4 = this.GetDuck(3);
             if (duck4 != null)
             {
                 if (this.controlling4)
                 {
                     duck4.listening = true;
                     duck4.Fondle((Thing)duck4.holdObject);
                     foreach (Equipment equipment in duck4._equipment)
                     {
                         duck4.Fondle((Thing)equipment);
                     }
                     duck4.Fondle((Thing)duck4._ragdollInstance);
                     duck4.Fondle((Thing)duck4._trappedInstance);
                     duck4.Fondle((Thing)duck4._cookedInstance);
                 }
                 if (!this.controlling4 && this.prevControlling4)
                 {
                     duck4.listening = false;
                 }
                 this.prevControlling4 = this.controlling4;
             }
         }
     }
     if (this._triggerHeld && this.isServerForObject && (this.duck != null && (double)this._preachWait <= 0.0 & this.duck.quack < 1) && this.duck.grounded)
     {
         if (Network.isActive)
         {
             this._netPreach.Play();
         }
         else
         {
             SFX.Play("preach" + (object)Rando.Int(5), Rando.Float(0.8f, 1f), Rando.Float(-0.2f, -0.3f));
         }
         this.duck.quack = (int)(byte)Rando.Int(12, 30);
         this.duck.profile.stats.timePreaching += (float)this.duck.quack / 0.1f * Maths.IncFrameTimer();
         this._preachWait = Rando.Float(1.8f, 2.5f);
         this._ringPulse  = 1f;
         if (Rando.Int(1) == 0)
         {
             this._raiseArm = Rando.Float(1.2f, 2f);
         }
         Ragdoll ragdoll = Level.Nearest <Ragdoll>(this.x, this.y, (Thing)this);
         if (ragdoll != null && ragdoll.captureDuck != null && (ragdoll.captureDuck.dead && Level.CheckLine <Block>(this.duck.position, ragdoll.position) == null) && (double)(ragdoll.position - this.duck.position).length < (double)this._ammoType.range)
         {
             if (Network.isActive)
             {
                 this.Fondle((Thing)ragdoll.captureDuck);
                 this.Fondle((Thing)ragdoll);
                 Send.Message((NetMessage) new NMLayToRest(ragdoll.captureDuck.profile.networkIndex));
             }
             ragdoll.captureDuck.LayToRest(this.duck.profile);
         }
         foreach (Duck duck in Level.current.things[typeof(Duck)])
         {
             if (duck != this.duck && duck.grounded && (!(duck.holdObject is GoodBook) && Level.CheckLine <Block>(this.duck.position, duck.position) == null) && (double)(duck.position - this.duck.position).length < (double)this._ammoType.range)
             {
                 if (duck.dead)
                 {
                     this.Fondle((Thing)duck);
                     duck.LayToRest(this.duck.profile);
                 }
                 else if (duck.converted != this.duck && this.duck.converted != duck && duck.profile.team != this.duck.profile.team)
                 {
                     if (Network.isActive)
                     {
                         if (duck.profile.networkIndex == (byte)0)
                         {
                             this.controlling1 = true;
                         }
                         if (duck.profile.networkIndex == (byte)1)
                         {
                             this.controlling2 = true;
                         }
                         if (duck.profile.networkIndex == (byte)2)
                         {
                             this.controlling3 = true;
                         }
                         if (duck.profile.networkIndex == (byte)3)
                         {
                             this.controlling4 = true;
                         }
                     }
                     duck.listening = true;
                     this.Fondle((Thing)duck);
                     this.Fondle((Thing)duck.holdObject);
                     foreach (Thing t in duck._equipment)
                     {
                         this.Fondle(t);
                     }
                     this.Fondle((Thing)duck._ragdollInstance);
                     this.Fondle((Thing)duck._trappedInstance);
                     this.Fondle((Thing)duck._cookedInstance);
                     duck.listenTime = 80;
                     if ((double)this.owner.x < (double)duck.x)
                     {
                         duck.offDir = (sbyte)-1;
                     }
                     else
                     {
                         duck.offDir = (sbyte)1;
                     }
                     duck.ThrowItem(false);
                     duck.conversionResistance -= 30;
                     if (duck.conversionResistance <= 0)
                     {
                         duck.ConvertDuck(this.duck.converted != null ? this.duck.converted : this.duck);
                         if (Network.isActive)
                         {
                             Send.Message((NetMessage) new NMConversion(duck.profile.networkIndex, this.duck.profile.networkIndex));
                         }
                         duck.conversionResistance = 50;
                     }
                 }
             }
         }
     }
     this._haloAlpha = Lerp.Float(this._haloAlpha, !this._triggerHeld || this.duck == null || !this.duck.grounded ? 0.0f : 1f, 0.05f);
 }
示例#23
0
 public override void Update()
 {
     this.backgroundColor = Color.Black;
     if (UnlockScreen.open || ArcadeHUD.open)
     {
         this._background.visible = false;
         foreach (Thing challenge in this._challenges)
         {
             challenge.visible = false;
         }
         this._prizeTable.visible = false;
     }
     else
     {
         this._background.visible = true;
         foreach (Thing challenge in this._challenges)
         {
             challenge.visible = true;
         }
         this._prizeTable.visible = true;
     }
     if (this._state == this._desiredState && this._state != ArcadeState.UnlockMachine && this._state != ArcadeState.LaunchChallenge)
     {
         if (!this._quitting)
         {
             if (Input.Pressed("START"))
             {
                 this._pauseGroup.Open();
                 this._pauseMenu.Open();
                 MonoMain.pauseMenu = this._pauseGroup;
                 if (!this._paused)
                 {
                     Music.Pause();
                     SFX.Play("pause", 0.6f);
                     this._paused           = true;
                     this._duck.immobilized = true;
                 }
                 this.simulatePhysics = false;
                 return;
             }
             if (this._paused && MonoMain.pauseMenu == null)
             {
                 this._paused = false;
                 SFX.Play("resume", 0.6f);
                 if (this._quit.value)
                 {
                     this._quitting = true;
                 }
                 else
                 {
                     Music.Resume();
                     this._duck.immobilized = false;
                     this.simulatePhysics   = true;
                 }
             }
         }
         else
         {
             Graphics.fade = Lerp.Float(Graphics.fade, 0.0f, 0.02f);
             if ((double)Graphics.fade <= 0.00999999977648258)
             {
                 Level.current = (Level) new TitleScreen();
             }
         }
     }
     if (this._paused)
     {
         return;
     }
     this._hud.Update();
     if (this._hud.launchChallenge)
     {
         this._desiredState = ArcadeState.LaunchChallenge;
     }
     if (this._desiredState != this._state)
     {
         this._duck.active = false;
         bool flag = false;
         if (this._desiredState == ArcadeState.ViewChallenge)
         {
             this._duck.alpha = Lerp.FloatSmooth(this._duck.alpha, 0.0f, 0.1f);
             this._followCam.manualViewSize = Lerp.FloatSmooth(this._followCam.manualViewSize, 2f, 0.16f);
             if ((double)this._followCam.manualViewSize < 30.0)
             {
                 Layer.Game.fade       = Lerp.Float(Layer.Game.fade, 0.0f, 0.08f);
                 Layer.Background.fade = Lerp.Float(Layer.Game.fade, 0.0f, 0.08f);
                 this._hud.alpha       = Lerp.Float(this._hud.alpha, 1f, 0.08f);
                 if ((double)this._followCam.manualViewSize < 3.0 && (double)this._hud.alpha == 1.0 && (double)Layer.Game.fade == 0.0)
                 {
                     flag = true;
                 }
             }
         }
         else if (this._desiredState == ArcadeState.Normal)
         {
             if (!this._flipState)
             {
                 this._followCam.Clear();
                 this._followCam.Add((Thing)this._duck);
                 HUD.CloseAllCorners();
             }
             this._duck.alpha = Lerp.FloatSmooth(this._duck.alpha, 1f, 0.1f, 1.1f);
             if (this._state == ArcadeState.ViewChallenge || this._state == ArcadeState.UnlockScreen)
             {
                 this._followCam.manualViewSize = Lerp.FloatSmooth(this._followCam.manualViewSize, this._followCam.viewSize, 0.14f, 1.05f);
             }
             Layer.Game.fade          = Lerp.Float(Layer.Game.fade, 1f, 0.05f);
             Layer.Background.fade    = Lerp.Float(Layer.Game.fade, 1f, 0.05f);
             this._hud.alpha          = Lerp.Float(this._hud.alpha, 0.0f, 0.08f);
             this._unlockScreen.alpha = Lerp.Float(this._unlockScreen.alpha, 0.0f, 0.08f);
             if (((double)this._followCam.manualViewSize < 0.0 || (double)this._followCam.manualViewSize == (double)this._followCam.viewSize) && ((double)this._hud.alpha == 0.0 && (double)Layer.Game.fade == 1.0))
             {
                 flag = true;
                 this._followCam.manualViewSize = -1f;
                 this._duck.alpha = 1f;
             }
         }
         else if (this._desiredState == ArcadeState.UnlockMachine)
         {
             if (!this._flipState)
             {
                 this._followCam.Clear();
                 this._followCam.Add((Thing)this._unlockMachines[0]);
                 HUD.CloseAllCorners();
             }
             if (this._state == ArcadeState.ViewChallenge)
             {
                 this._followCam.manualViewSize = Lerp.FloatSmooth(this._followCam.manualViewSize, this._followCam.viewSize, 0.14f, 1.05f);
             }
             this._duck.alpha         = Lerp.FloatSmooth(this._duck.alpha, 1f, 0.1f, 1.1f);
             Layer.Game.fade          = Lerp.Float(Layer.Game.fade, 1f, 0.05f);
             Layer.Background.fade    = Lerp.Float(Layer.Game.fade, 1f, 0.05f);
             this._hud.alpha          = Lerp.Float(this._hud.alpha, 0.0f, 0.08f);
             this._unlockScreen.alpha = Lerp.Float(this._unlockScreen.alpha, 0.0f, 0.08f);
             this._unlockMachineWait  = 1f;
             if (((double)this._followCam.manualViewSize < 0.0 || (double)this._followCam.manualViewSize == (double)this._followCam.viewSize) && ((double)this._hud.alpha == 0.0 && (double)Layer.Game.fade == 1.0))
             {
                 flag = true;
                 this._followCam.manualViewSize = -1f;
                 this._duck.alpha = 1f;
             }
         }
         else if (this._desiredState == ArcadeState.LaunchChallenge)
         {
             if (!this._flipState)
             {
                 HUD.CloseAllCorners();
             }
             Music.volume             = Lerp.Float(Music.volume, 0.0f, 0.01f);
             this._hud.alpha          = Lerp.Float(this._hud.alpha, 0.0f, 0.02f);
             this._unlockScreen.alpha = Lerp.Float(this._unlockScreen.alpha, 0.0f, 0.08f);
             if ((double)this._hud.alpha == 0.0)
             {
                 flag = true;
             }
         }
         if (this._desiredState == ArcadeState.UnlockScreen)
         {
             this._duck.alpha = Lerp.FloatSmooth(this._duck.alpha, 0.0f, 0.1f);
             this._followCam.manualViewSize = Lerp.FloatSmooth(this._followCam.manualViewSize, 2f, 0.16f);
             if ((double)this._followCam.manualViewSize < 30.0)
             {
                 Layer.Game.fade          = Lerp.Float(Layer.Game.fade, 0.0f, 0.08f);
                 Layer.Background.fade    = Lerp.Float(Layer.Game.fade, 0.0f, 0.08f);
                 this._unlockScreen.alpha = Lerp.Float(this._unlockScreen.alpha, 1f, 0.08f);
                 if ((double)this._followCam.manualViewSize < 3.0 && (double)this._unlockScreen.alpha == 1.0 && (double)Layer.Game.fade == 0.0)
                 {
                     flag = true;
                 }
             }
         }
         this._flipState = true;
         if (this._launchedChallenge)
         {
             Layer.Background.fade = 0.0f;
             Layer.Game.fade       = 0.0f;
         }
         if (!flag)
         {
             return;
         }
         this._flipState = false;
         HUD.CloseAllCorners();
         this._state = this._desiredState;
         if (this._state == ArcadeState.ViewChallenge)
         {
             if (this._afterChallenge)
             {
                 Music.Play(nameof(Arcade));
                 this._afterChallenge = false;
             }
             this._hud.MakeActive();
             this._duck.active = false;
         }
         else if (this._state == ArcadeState.LaunchChallenge)
         {
             Arcade.currentArcade = this;
             foreach (Thing thing in this.things[typeof(ChallengeConfetti)])
             {
                 Level.Remove(thing);
             }
             Music.Stop();
             Level.current             = (Level) new ChallengeLevel(this._hud.selected.challenge.fileName);
             this._desiredState        = ArcadeState.ViewChallenge;
             this._hud.launchChallenge = false;
             this._launchedChallenge   = false;
             this._afterChallenge      = true;
         }
         else
         {
             if (this._state == ArcadeState.UnlockMachine)
             {
                 return;
             }
             if (this._state == ArcadeState.Normal)
             {
                 this._unlockMachines.Clear();
                 foreach (ArcadeMachine challenge in this._challenges)
                 {
                     if (challenge.CheckUnlocked())
                     {
                         this._unlockMachines.Add(challenge);
                     }
                 }
                 if (this._unlockMachines.Count > 0)
                 {
                     this._desiredState = ArcadeState.UnlockMachine;
                 }
                 else
                 {
                     this._duck.active = true;
                 }
             }
             else if (this._state == ArcadeState.UnlockScreen)
             {
                 this._unlockScreen.MakeActive();
                 this._duck.active = false;
             }
             else
             {
                 if (this._state != ArcadeState.ViewSpecialChallenge)
                 {
                     return;
                 }
                 if (this._afterChallenge)
                 {
                     Music.Play(nameof(Arcade));
                     this._afterChallenge = false;
                 }
                 Chancy.afterChallenge     = true;
                 Chancy.afterChallengeWait = 1f;
                 this._duck.active         = false;
             }
         }
     }
     else if (this._state == ArcadeState.Normal || this._state == ArcadeState.UnlockMachine)
     {
         Layer.Game.fade       = Lerp.Float(Layer.Game.fade, 1f, 0.08f);
         Layer.Background.fade = Lerp.Float(Layer.Game.fade, 1f, 0.08f);
         this._hud.alpha       = Lerp.Float(this._hud.alpha, 0.0f, 0.08f);
         if (this._state == ArcadeState.Normal)
         {
             object obj = (object)null;
             foreach (ArcadeMachine challenge in this._challenges)
             {
                 double length = (double)(this._duck.position - challenge.position).length;
                 if (challenge.hover)
                 {
                     obj = (object)challenge;
                     if (Input.Pressed("SHOOT"))
                     {
                         this._hud.activeChallengeGroup = challenge.data;
                         this._desiredState             = ArcadeState.ViewChallenge;
                         this._followCam.manualViewSize = this._followCam.viewSize;
                         this._followCam.Clear();
                         this._followCam.Add((Thing)challenge);
                         HUD.CloseAllCorners();
                         this._hoverMachine = (ArcadeMachine)null;
                         this._hoverThing   = (object)null;
                         return;
                     }
                 }
                 if (this._prizeTable.hover)
                 {
                     obj = (object)this._prizeTable;
                     if (Input.Pressed("SHOOT"))
                     {
                         this._desiredState             = ArcadeState.UnlockScreen;
                         this._followCam.manualViewSize = this._followCam.viewSize;
                         this._followCam.Clear();
                         this._followCam.Add((Thing)this._prizeTable);
                         HUD.CloseAllCorners();
                         this._hoverMachine = (ArcadeMachine)null;
                         this._hoverThing   = (object)null;
                         return;
                     }
                 }
             }
             if (this._hoverThing == obj)
             {
                 return;
             }
             HUD.CloseAllCorners();
             this._hoverThing   = obj;
             this._hoverMachine = !(this._hoverThing is ArcadeMachine) ? (ArcadeMachine)null : obj as ArcadeMachine;
             if (this._hoverMachine != null)
             {
                 HUD.AddCornerControl(HUDCorner.BottomLeft, "PLAY@SHOOT@", this._duck.inputProfile);
                 string text = this._hoverMachine.data.name + " ";
                 foreach (string challenge in this._hoverMachine.data.challenges)
                 {
                     ChallengeSaveData saveData = Challenges.GetSaveData(Challenges.GetChallenge(challenge).levelID, this._duck.profile);
                     if (saveData.trophy == TrophyType.Baseline)
                     {
                         text += "@BASELINE@";
                     }
                     else if (saveData.trophy == TrophyType.Bronze)
                     {
                         text += "@BRONZE@";
                     }
                     else if (saveData.trophy == TrophyType.Silver)
                     {
                         text += "@SILVER@";
                     }
                     else if (saveData.trophy == TrophyType.Gold)
                     {
                         text += "@GOLD@";
                     }
                     else if (saveData.trophy == TrophyType.Platinum)
                     {
                         text += "@PLATINUM@";
                     }
                     else if (saveData.trophy == TrophyType.Developer)
                     {
                         text += "@DEVELOPER@";
                     }
                 }
                 HUD.AddCornerMessage(HUDCorner.TopLeft, text);
             }
             else
             {
                 if (!this._prizeTable.hover)
                 {
                     return;
                 }
                 HUD.AddCornerControl(HUDCorner.BottomRight, "@SHOOT@SPEND TICKETS", this._duck.inputProfile);
                 HUD.AddCornerCounter(HUDCorner.BottomLeft, "@TICKET@ ", new FieldBinding((object)Profiles.active[0], "ticketCount"), animateCount: true);
             }
         }
         else
         {
             if (this._state != ArcadeState.UnlockMachine)
             {
                 return;
             }
             this._unlockMachineWait -= 0.02f;
             if ((double)this._unlockMachineWait >= 0.0)
             {
                 return;
             }
             if (this._unlockingMachine)
             {
                 this._unlockingMachine = false;
                 this._followCam.Clear();
                 this._followCam.Add((Thing)this._unlockMachines[0]);
                 this._unlockMachineWait = 1f;
             }
             else if (this._unlockMachines.Count > 0)
             {
                 this._unlockMachines[0].unlocked = true;
                 this._unlockMachines.RemoveAt(0);
                 this._unlockingMachine = this._unlockMachines.Count > 0;
                 SFX.Play("lightTurnOn", pitch: Rando.Float(-0.1f, 0.1f));
                 this._unlockMachineWait = 1f;
             }
             else
             {
                 this._desiredState = ArcadeState.Normal;
             }
         }
     }
     else if (this._state == ArcadeState.ViewChallenge)
     {
         Layer.Game.fade       = Lerp.Float(Layer.Game.fade, 0.0f, 0.05f);
         Layer.Background.fade = Lerp.Float(Layer.Game.fade, 0.0f, 0.05f);
         this._hud.alpha       = Lerp.Float(this._hud.alpha, 1f, 0.05f);
         if (!this._hud.quitOut)
         {
             return;
         }
         this._hud.quitOut  = false;
         this._desiredState = ArcadeState.Normal;
     }
     else
     {
         if (this._state != ArcadeState.UnlockScreen || !this._unlockScreen.quitOut)
         {
             return;
         }
         this._unlockScreen.quitOut = false;
         this._desiredState         = ArcadeState.Normal;
     }
 }
示例#24
0
 public override void Update()
 {
     if (this.isServerForObject)
     {
         this.ownerAction = this.action;
     }
     if (this.duck != null && this.ownerAction)
     {
         this._holdOffset = Lerp.Vec2(this._holdOffset, new Vec2(-13f, -4f), 2f);
         this.angle       = Lerp.Float(this.angle, -1f, 0.1f);
         this.handFlip    = true;
         this.handOffset  = Lerp.Vec2(this.handOffset, new Vec2(-3f, -4f), 1f);
         this._canRaise   = false;
     }
     else
     {
         float num = 1f;
         if (this.duck != null)
         {
             this.angle = Lerp.Float(this.angle, 0.0f, 0.1f * num);
         }
         else
         {
             num = 20f;
         }
         this._holdOffset = Lerp.Vec2(this._holdOffset, new Vec2(-2f, 0.0f), num * 2f);
         this.handFlip    = false;
         this.handOffset  = Lerp.Vec2(this.handOffset, new Vec2(0.0f, 0.0f), 1f * num);
         this._canRaise   = true;
     }
     if (this.owner == null && this.level.simulatePhysics)
     {
         if (this._framesSinceThrown == 0)
         {
             this._throwSpin = this.angleDegrees;
         }
         ++this._framesSinceThrown;
         if (this._framesSinceThrown > 15)
         {
             this._framesSinceThrown = 15;
         }
         this.angleDegrees = this._throwSpin;
         bool flag1 = false;
         bool flag2 = false;
         if (((double)Math.Abs(this.hSpeed) + (double)Math.Abs(this.vSpeed) > 2.0 || !this.grounded) && ((double)this.gravMultiplier > 0.0 && !flag2) && !this._grounded)
         {
             if (this.offDir > (sbyte)0)
             {
                 this._throwSpin += (float)(((double)Math.Abs(this.hSpeed * 2f) + (double)Math.Abs(this.vSpeed)) * 1.0 + 5.0);
             }
             else
             {
                 this._throwSpin -= (float)(((double)Math.Abs(this.hSpeed * 2f) + (double)Math.Abs(this.vSpeed)) * 1.0 + 5.0);
             }
             flag1 = true;
         }
         if (!flag1 || flag2)
         {
             this._throwSpin %= 360f;
             if ((double)this._throwSpin < 0.0)
             {
                 this._throwSpin += 360f;
             }
             if (flag2)
             {
                 this._throwSpin = (double)Math.Abs(this._throwSpin - 90f) >= (double)Math.Abs(this._throwSpin + 90f) ? Lerp.Float(-90f, 0.0f, 16f) : Lerp.Float(this._throwSpin, 90f, 16f);
             }
             else if ((double)this._throwSpin > 90.0 && (double)this._throwSpin < 270.0)
             {
                 this._throwSpin = Lerp.Float(this._throwSpin, 180f, 14f);
             }
             else
             {
                 if ((double)this._throwSpin > 180.0)
                 {
                     this._throwSpin -= 360f;
                 }
                 else if ((double)this._throwSpin < -180.0)
                 {
                     this._throwSpin += 360f;
                 }
                 this._throwSpin = Lerp.Float(this._throwSpin, 0.0f, 14f);
             }
         }
     }
     else
     {
         this._throwSpin = 0.0f;
     }
     base.Update();
 }
        public override void Update()
        {
            this._scroll += 0.1f;
            if ((double)this._scroll > 9.0)
            {
                this._scroll = 0.0f;
            }
            this._dots += 0.01f;
            if ((double)this._dots > 1.0)
            {
                this._dots = 0.0f;
            }
            if (this.open)
            {
                foreach (BlacklistServer failedAttempt in this._failedAttempts)
                {
                    failedAttempt.cooldown = Lerp.Float(failedAttempt.cooldown, 0.0f, Maths.IncFrameTimer());
                }
                if (this._signalCrossLocal.currentAnimation == "idle")
                {
                    if (UIMatchmakingBox.pulseLocal)
                    {
                        this._signalCrossLocal.SetAnimation("flicker");
                        UIMatchmakingBox.pulseLocal = false;
                    }
                }
                else if (this._signalCrossLocal.finished)
                {
                    this._signalCrossLocal.SetAnimation("idle");
                }
                if (this._signalCrossNetwork.currentAnimation == "idle")
                {
                    if (UIMatchmakingBox.pulseNetwork)
                    {
                        this._signalCrossNetwork.SetAnimation("flicker");
                        UIMatchmakingBox.pulseNetwork = false;
                    }
                }
                else if (this._signalCrossNetwork.finished)
                {
                    this._signalCrossNetwork.SetAnimation("idle");
                }
                if (Network.connections.Count > 0 && UIMatchmakingBox._state != MatchmakingState.Connecting)
                {
                    this.ChangeState(MatchmakingState.Connecting);
                    DevConsole.Log("|PURPLE|MATCHMAKING |DGGREEN|Network appears to be connecting...", Color.White);
                }
                if (DuckNetwork.status == DuckNetStatus.Connected)
                {
                    if (this._tryHostingLobby != null)
                    {
                        (Level.current as TeamSelect2).CloseAllDialogs();
                        Level.current = (Level) new TeamSelect2();
                        DevConsole.Log("|PURPLE|MATCHMAKING |DGGREEN|Finished! (HOST).", Color.White);
                        return;
                    }
                    if (Level.current is TeamSelect2)
                    {
                        (Level.current as TeamSelect2).CloseAllDialogs();
                        Level.current = (Level) new ConnectingScreen();
                        DevConsole.Log("|PURPLE|MATCHMAKING |DGGREEN|Finished! (CLIENT).", Color.White);
                        return;
                    }
                    Network.Disconnect();
                    this.ChangeState(MatchmakingState.SearchForLobbies);
                    DevConsole.Log("|PURPLE|MATCHMAKING |DGGREEN|Last minute connection error.", Color.White);
                    return;
                }
                switch (UIMatchmakingBox._state)
                {
                case MatchmakingState.ConnectToMoon:
                    Steam.AddLobbyStringFilter("started", "true", SteamLobbyComparison.Equal);
                    Steam.SearchForLobby((User)null);
                    Steam.RequestGlobalStats();
                    UIMatchmakingBox.pulseLocal = true;
                    this.ChangeState(MatchmakingState.ConnectingToMoon);
                    break;

                case MatchmakingState.ConnectingToMoon:
                    if (Steam.lobbySearchComplete)
                    {
                        if (this.searchTryIndex == 0)
                        {
                            this._totalInGameLobbies = Steam.lobbiesFound;
                            if (this._totalInGameLobbies < 0)
                            {
                                this._totalInGameLobbies = 0;
                            }
                            ++this.searchTryIndex;
                            Steam.AddLobbyStringFilter("started", "false", SteamLobbyComparison.Equal);
                            Steam.SearchForLobby((User)null);
                            break;
                        }
                        UIMatchmakingBox.pulseNetwork = true;
                        this._totalLobbiesFound       = Steam.lobbiesFound;
                        List <User> users = Steam.GetSearchLobbyAtIndex(0).users;
                        this._newStatusList.Add("|DGGREEN|Connected to Moon!");
                        this._newStatusList.Add("");
                        this._newStatusList.Add("|DGYELLOW|Searching for companions.");
                        this.ChangeState(MatchmakingState.SearchForLobbies);
                        break;
                    }
                    break;

                case MatchmakingState.SearchForLobbies:
                    if (this._triesSinceSearch == 3)
                    {
                        Steam.AddLobbyStringFilter("started", "true", SteamLobbyComparison.Equal);
                        Steam.SearchForLobby((User)null);
                        this.ChangeState(MatchmakingState.CheckingTotalGames);
                        return;
                    }
                    if (this._tries > 0 && this._tryHostingLobby == null)
                    {
                        DuckNetwork.Host(TeamSelect2.GetSettingInt("maxplayers"), NetworkLobbyType.Public);
                        this._tryHostingLobby = (Network.activeNetwork.core as NCSteam).lobby;
                        if (!this.triedHostingAlready)
                        {
                            this._newStatusList.Add("|DGYELLOW|Searching even harder.");
                        }
                        else
                        {
                            this._newStatusList.Add("|DGYELLOW|Searching.");
                        }
                        this.triedHostingAlready = true;
                        DevConsole.Log("|PURPLE|MATCHMAKING |DGYELLOW|Opened lobby while searching.", Color.White);
                        this._tryHostingWait = 5f + Rando.Float(2f);
                    }
                    foreach (MatchSetting matchSetting in TeamSelect2.matchSettings)
                    {
                        if (matchSetting.value is int)
                        {
                            if (matchSetting.filtered)
                            {
                                Steam.AddLobbyNumericalFilter(matchSetting.id, (int)matchSetting.value, (SteamLobbyComparison)matchSetting.filterMode);
                            }
                            else if (!matchSetting.filtered)
                            {
                                Steam.AddLobbyNearFilter(matchSetting.id, (int)matchSetting.defaultValue);
                            }
                        }
                        if (matchSetting.value is bool)
                        {
                            if (matchSetting.filtered)
                            {
                                Steam.AddLobbyNumericalFilter(matchSetting.id, (bool)matchSetting.value ? 1 : 0, (SteamLobbyComparison)matchSetting.filterMode);
                            }
                            else if (!matchSetting.filtered)
                            {
                                Steam.AddLobbyNearFilter(matchSetting.id, (bool)matchSetting.defaultValue ? 1 : 0);
                            }
                        }
                    }
                    foreach (MatchSetting onlineSetting in TeamSelect2.onlineSettings)
                    {
                        if (onlineSetting.value is int)
                        {
                            if (onlineSetting.filtered)
                            {
                                Steam.AddLobbyNumericalFilter(onlineSetting.id, (int)onlineSetting.value, (SteamLobbyComparison)onlineSetting.filterMode);
                            }
                            else if (!onlineSetting.filtered)
                            {
                                Steam.AddLobbyNearFilter(onlineSetting.id, (int)onlineSetting.defaultValue);
                            }
                        }
                        if (onlineSetting.value is bool)
                        {
                            if (onlineSetting.id == "modifiers")
                            {
                                if (onlineSetting.filtered)
                                {
                                    Steam.AddLobbyStringFilter(onlineSetting.id, (bool)onlineSetting.value ? "true" : "false", SteamLobbyComparison.Equal);
                                }
                            }
                            else if (onlineSetting.filtered)
                            {
                                Steam.AddLobbyNumericalFilter(onlineSetting.id, (bool)onlineSetting.value ? 1 : 0, (SteamLobbyComparison)onlineSetting.filterMode);
                            }
                            else if (!onlineSetting.filtered)
                            {
                                Steam.AddLobbyNearFilter(onlineSetting.id, (bool)onlineSetting.defaultValue ? 1 : 0);
                            }
                        }
                    }
                    Steam.AddLobbyStringFilter("started", "false", SteamLobbyComparison.Equal);
                    Steam.AddLobbyStringFilter("beta", "2.0", SteamLobbyComparison.Equal);
                    Steam.AddLobbyStringFilter("dev", DG.devBuild ? "true" : "false", SteamLobbyComparison.Equal);
                    Steam.AddLobbyStringFilter("modhash", ModLoader.modHash, SteamLobbyComparison.Equal);
                    if (!Steam.waitingForGlobalStats)
                    {
                        this._globalKills = (long)Steam.GetDailyGlobalStat("kills");
                    }
                    Steam.RequestGlobalStats();
                    UIMatchmakingBox.pulseLocal = true;
                    this.ChangeState(MatchmakingState.Searching);
                    ++this._triesSinceSearch;
                    ++this._tries;
                    break;

                case MatchmakingState.CheckingTotalGames:
                    if (Steam.lobbySearchComplete)
                    {
                        this._totalInGameLobbies = Steam.lobbiesFound;
                        if (this._totalInGameLobbies < 0)
                        {
                            this._totalInGameLobbies = 0;
                        }
                        this.ChangeState(MatchmakingState.SearchForLobbies);
                        this._triesSinceSearch = 0;
                        break;
                    }
                    break;

                case MatchmakingState.Searching:
                    if (Steam.lobbySearchComplete)
                    {
                        this._totalLobbiesFound = Steam.lobbiesFound;
                        if (this._tryHostingLobby != null)
                        {
                            --this._totalLobbiesFound;
                        }
                        List <Lobby> lobbyList = new List <Lobby>();
                        DevConsole.Log("|PURPLE|MATCHMAKING |LIME|found " + (object)Math.Max(this._totalLobbiesFound, 0) + " lobbies.", Color.White);
                        for (int index1 = 0; index1 < 2; ++index1)
                        {
                            int num1 = index1 != 0 ? lobbyList.Count : Steam.lobbiesFound;
                            for (int index2 = 0; index2 < num1; ++index2)
                            {
                                Lobby lobby = index1 != 0 ? lobbyList[index2] : Steam.GetSearchLobbyAtIndex(index2);
                                if (this._tryHostingLobby == null || (long)lobby.id != (long)this._tryHostingLobby.id)
                                {
                                    if (index2 == Steam.lobbiesFound - 1)
                                    {
                                        this._failedAttempts.RemoveAll((Predicate <BlacklistServer>)(x => (double)x.cooldown <= 0.0));
                                    }
                                    if (UIMatchmakingBox.nonPreferredServers.Contains(lobby.id) && index1 == 0)
                                    {
                                        lobbyList.Add(lobby);
                                        DevConsole.Log("|PURPLE|MATCHMAKING |DGRED|Skipping " + (object)lobby.id + " (NOT PREFERRED)", Color.White);
                                    }
                                    else if (this.IsBlacklisted(lobby.id))
                                    {
                                        DevConsole.Log("|PURPLE|MATCHMAKING |DGRED|Skipping " + (object)lobby.id + " (BLACKLISTED)", Color.White);
                                    }
                                    else
                                    {
                                        if (this._tryHostingLobby != null)
                                        {
                                            int num2 = -1;
                                            try
                                            {
                                                string lobbyData = lobby.GetLobbyData("randomID");
                                                if (lobbyData != "")
                                                {
                                                    num2 = Convert.ToInt32(lobbyData);
                                                }
                                            }
                                            catch
                                            {
                                            }
                                            if (num2 == -1)
                                            {
                                                DevConsole.Log("|PURPLE|MATCHMAKING |DGYELLOW|Bad lobby seed.", Color.White);
                                                num2 = Rando.Int(2147483646);
                                            }
                                            if (num2 >= this._tryHostingLobby.randomID)
                                            {
                                                DevConsole.Log("|PURPLE|MATCHMAKING |DGYELLOW|Lobby beats own lobby, Attempting join.", Color.White);
                                            }
                                            else
                                            {
                                                DevConsole.Log("|PURPLE|MATCHMAKING |DGYELLOW|Skipping lobby (Chose to keep hosting).", Color.White);
                                                NCSteam.UpdateRandomID(this._tryHostingLobby);
                                                continue;
                                            }
                                        }
                                        this._tryConnectLobby = lobby;
                                        if (lobby.owner != null)
                                        {
                                            this._newStatusList.Add("|LIME|Trying to join " + lobby.owner.name + ".");
                                        }
                                        else
                                        {
                                            this._newStatusList.Add("|LIME|Trying to join server.");
                                        }
                                        this.ChangeState(MatchmakingState.Disconnect);
                                        break;
                                    }
                                }
                            }
                        }
                        if (this._tryConnectLobby == null)
                        {
                            DevConsole.Log("|PURPLE|MATCHMAKING |DGYELLOW|Found no valid lobbies.", Color.White);
                            this.ChangeState(MatchmakingState.SearchForLobbies, 3f);
                            break;
                        }
                        break;
                    }
                    break;

                case MatchmakingState.Waiting:
                    this._stateWait -= Maths.IncFrameTimer();
                    if ((double)this._stateWait <= 0.0)
                    {
                        this._stateWait = 0.0f;
                        this.OnStateChange(this._pendingState);
                        break;
                    }
                    break;

                default:
                    int state = (int)UIMatchmakingBox._state;
                    break;
                }
                if (Input.Pressed("QUACK"))
                {
                    this._quit = true;
                    this.ChangeState(MatchmakingState.Disconnect);
                }
            }
            if (this._newStatusList.Count > 0)
            {
                this._newStatusWait -= 0.1f;
                if ((double)this._newStatusWait <= 0.0)
                {
                    this._newStatusWait = 1f;
                    while ((double)this._fancyFont.GetWidth(this._newStatusList[0]) > 98.0)
                    {
                        this._newStatusList[0] = this._newStatusList[0].Substring(0, this._newStatusList[0].Length - 1);
                    }
                    this._statusList.Add(this._newStatusList[0]);
                    if (this._statusList.Count > 7)
                    {
                        this._statusList.RemoveAt(0);
                    }
                    this._newStatusList.RemoveAt(0);
                }
            }
            base.Update();
        }
 public static void Update()
 {
     foreach (KeyValuePair <NetworkConnection, ConnectionIndicatorElement> connection in ConnectionIndicator._connections)
     {
         if (connection.Value.duck != null && (connection.Value.duck.removeFromLevel || connection.Value.duck.level != Level.current))
         {
             connection.Value.duck = (Duck)null;
         }
         connection.Value.position = connection.Value.duck == null ? new Vec2(-1000f, -1000f) : connection.Value.duck.cameraPosition;
         foreach (KeyValuePair <ConnectionIndicatorType, ConnectionIndicatorDetail> detail in connection.Value.details)
         {
             detail.Value.buildup -= Maths.IncFrameTimer() * 0.25f;
             if ((double)detail.Value.buildup > (double)detail.Value.maxBuildup)
             {
                 detail.Value.buildup = detail.Value.maxBuildup;
             }
             if ((double)detail.Value.buildup < 0.0)
             {
                 detail.Value.buildup = 0.0f;
                 detail.Value.popOut += 0.02f;
                 if ((double)detail.Value.popOut > 1.0)
                 {
                     detail.Value.popOut = 1f;
                 }
                 detail.Value.grow -= 0.1f;
                 if ((double)detail.Value.grow < 0.0)
                 {
                     detail.Value.grow = 0.0f;
                 }
             }
             else
             {
                 detail.Value.popOut = 0.0f;
                 detail.Value.grow   = Lerp.FloatSmooth(detail.Value.grow, 1f, 0.2f);
                 if ((double)detail.Value.grow > 1.0)
                 {
                     detail.Value.grow = 1f;
                 }
             }
         }
     }
     foreach (Duck duck in Level.current.things[typeof(Duck)])
     {
         NetworkConnection key = (NetworkConnection)null;
         if (duck.profile != null && duck.profile.connection != null)
         {
             key = duck.profile.connection;
         }
         if (Network.isActive && key != null)
         {
             ConnectionIndicatorElement indicatorElement = (ConnectionIndicatorElement)null;
             if (!ConnectionIndicator._connections.TryGetValue(key, out indicatorElement))
             {
                 indicatorElement = new ConnectionIndicatorElement();
                 ConnectionIndicator._connections[key] = indicatorElement;
             }
             indicatorElement.duck = duck;
             if ((double)key.manager.ping > 0.25)
             {
                 indicatorElement.GetDetail(ConnectionIndicatorType.Lag).buildup += Maths.IncFrameTimer();
             }
             if ((double)key.manager.ping > 0.899999976158142 || key.status != ConnectionStatus.Connected)
             {
                 indicatorElement.GetDetail(ConnectionIndicatorType.Failure).buildup += Maths.IncFrameTimer();
             }
             if (key.manager.lossThisFrame)
             {
                 indicatorElement.GetDetail(ConnectionIndicatorType.Loss).buildup += 0.2f;
                 key.manager.lossThisFrame = false;
             }
             if ((double)key.manager.jitter > 0.800000011920929)
             {
                 indicatorElement.GetDetail(ConnectionIndicatorType.Loss).buildup += 0.25f;
             }
             ConnectionIndicatorDetail detail1 = indicatorElement.GetDetail(ConnectionIndicatorType.AFK);
             if (!duck.afk)
             {
                 detail1.buildup = 0.0f;
             }
             else
             {
                 detail1.buildup += Maths.IncFrameTimer();
             }
             ConnectionIndicatorDetail detail2 = indicatorElement.GetDetail(ConnectionIndicatorType.Chatting);
             if (duck.chatting)
             {
                 detail2.buildup += 0.25f;
             }
             else
             {
                 detail2.buildup = 0.0f;
             }
         }
     }
     if (ConnectionIndicator._lagIcons != null)
     {
         return;
     }
     ConnectionIndicator._lagIcons = new SpriteMap("lagturtle", 16, 16);
     ConnectionIndicator._lagIcons.CenterOrigin();
     ConnectionIndicator._rainbowGradient = new Sprite("rainbowGradient");
 }
示例#27
0
        public override void Update()
        {
            Options.openOnClose = this._pauseMenu;
            if (this.spawnKey)
            {
                if ((double)this.spawnKeyWait > 0.0)
                {
                    this.spawnKeyWait -= Maths.IncFrameTimer();
                }
                else
                {
                    SFX.Play("ching");
                    this.spawnKey = false;
                    Key key = new Key(this._prizeTable.x, this._prizeTable.y);
                    key.vSpeed = -4f;
                    key.depth  = this._duck.depth + 50;
                    Level.Add((Thing)SmallSmoke.New(key.x + Rando.Float(-4f, 4f), key.y + Rando.Float(-4f, 4f)));
                    Level.Add((Thing)SmallSmoke.New(key.x + Rando.Float(-4f, 4f), key.y + Rando.Float(-4f, 4f)));
                    Level.Add((Thing)SmallSmoke.New(key.x + Rando.Float(-4f, 4f), key.y + Rando.Float(-4f, 4f)));
                    Level.Add((Thing)SmallSmoke.New(key.x + Rando.Float(-4f, 4f), key.y + Rando.Float(-4f, 4f)));
                    Level.Add((Thing)key);
                }
            }
            Chancy.Update();
            if (this._pendingSpawns != null && this._pendingSpawns.Count > 0)
            {
                Duck pendingSpawn = this._pendingSpawns[0];
                this.AddThing((Thing)pendingSpawn);
                this._pendingSpawns.RemoveAt(0);
                this._duck   = pendingSpawn;
                this._arcade = this.things[typeof(ArcadeMode)].First <Thing>() as ArcadeMode;
            }
            Layer.Lighting.fade  = Layer.Lighting2.fade = 1f - Math.Min(1f, Math.Max(0.0f, (float)((1.0 - (double)Layer.Game.fade) * 1.5)));
            this.backgroundColor = Color.Black;
            if (UnlockScreen.open || ArcadeHUD.open)
            {
                foreach (Thing challenge in this._challenges)
                {
                    challenge.visible = false;
                }
                this._prizeTable.visible = false;
            }
            else
            {
                foreach (Thing challenge in this._challenges)
                {
                    challenge.visible = true;
                }
                this._prizeTable.visible = true;
            }
            if (this._state == this._desiredState && this._state != ArcadeState.UnlockMachine && this._state != ArcadeState.LaunchChallenge)
            {
                if (!this._quitting)
                {
                    if (Input.Pressed("START"))
                    {
                        this._pauseGroup.Open();
                        this._pauseMenu.Open();
                        MonoMain.pauseMenu = this._pauseGroup;
                        if (!this._paused)
                        {
                            Music.Pause();
                            SFX.Play("pause", 0.6f);
                            this._paused           = true;
                            this._duck.immobilized = true;
                        }
                        this.simulatePhysics = false;
                        return;
                    }
                    if (this._paused && MonoMain.pauseMenu == null)
                    {
                        this._paused = false;
                        SFX.Play("resume", 0.6f);
                        if (this._quit.value)
                        {
                            this._quitting = true;
                        }
                        else
                        {
                            Music.Resume();
                            this._duck.immobilized = false;
                            this.simulatePhysics   = true;
                        }
                    }
                }
                else
                {
                    Graphics.fade = Lerp.Float(Graphics.fade, 0.0f, 0.02f);
                    if ((double)Graphics.fade > 0.00999999977648258)
                    {
                        return;
                    }
                    Level.current = (Level) new TitleScreen();
                    return;
                }
            }
            if (this._paused)
            {
                return;
            }
            if (this._hud.launchChallenge)
            {
                this._desiredState = ArcadeState.LaunchChallenge;
            }
            if (this._desiredState != this._state)
            {
                this._duck.active = false;
                bool flag = false;
                if (this._desiredState == ArcadeState.ViewChallenge)
                {
                    this._duck.alpha = Lerp.FloatSmooth(this._duck.alpha, 0.0f, 0.1f);
                    this._followCam.manualViewSize = Lerp.FloatSmooth(this._followCam.manualViewSize, 2f, 0.16f);
                    if ((double)this._followCam.manualViewSize < 30.0)
                    {
                        Layer.Game.fade       = Lerp.Float(Layer.Game.fade, 0.0f, 0.08f);
                        Layer.Background.fade = Lerp.Float(Layer.Game.fade, 0.0f, 0.08f);
                        this._hud.alpha       = Lerp.Float(this._hud.alpha, 1f, 0.08f);
                        if ((double)this._followCam.manualViewSize < 3.0 && (double)this._hud.alpha == 1.0 && (double)Layer.Game.fade == 0.0)
                        {
                            flag = true;
                        }
                    }
                }
                else if (this._desiredState == ArcadeState.Normal)
                {
                    if (!this._flipState)
                    {
                        this._followCam.Clear();
                        this._followCam.Add((Thing)this._duck);
                        HUD.CloseAllCorners();
                    }
                    this._duck.alpha = Lerp.FloatSmooth(this._duck.alpha, 1f, 0.1f, 1.1f);
                    if (this._state == ArcadeState.ViewChallenge || this._state == ArcadeState.UnlockScreen)
                    {
                        this._followCam.manualViewSize = Lerp.FloatSmooth(this._followCam.manualViewSize, this._followCam.viewSize, 0.14f, 1.05f);
                    }
                    Layer.Game.fade          = Lerp.Float(Layer.Game.fade, 1f, 0.05f);
                    Layer.Background.fade    = Lerp.Float(Layer.Game.fade, 1f, 0.05f);
                    this._hud.alpha          = Lerp.Float(this._hud.alpha, 0.0f, 0.08f);
                    this._unlockScreen.alpha = Lerp.Float(this._unlockScreen.alpha, 0.0f, 0.08f);
                    if (((double)this._followCam.manualViewSize < 0.0 || (double)this._followCam.manualViewSize == (double)this._followCam.viewSize) && ((double)this._hud.alpha == 0.0 && (double)Layer.Game.fade == 1.0))
                    {
                        flag = true;
                        this._followCam.manualViewSize = -1f;
                        this._duck.alpha = 1f;
                    }
                    if (Unlockables.HasPendingUnlocks())
                    {
                        MonoMain.pauseMenu = (UIComponent) new UIUnlockBox(Unlockables.GetPendingUnlocks().ToList <Unlockable>(), Layer.HUD.camera.width / 2f, Layer.HUD.camera.height / 2f, 190f);
                    }
                }
                else if (this._desiredState == ArcadeState.ViewSpecialChallenge || this._desiredState == ArcadeState.ViewChallengeList || this._desiredState == ArcadeState.ViewProfileSelector)
                {
                    if (!this._flipState)
                    {
                        this._followCam.Clear();
                        this._followCam.Add((Thing)this._duck);
                        HUD.CloseAllCorners();
                    }
                    this._duck.alpha = Lerp.FloatSmooth(this._duck.alpha, 1f, 0.1f, 1.1f);
                    if (this._state == ArcadeState.ViewChallenge || this._state == ArcadeState.UnlockScreen)
                    {
                        this._followCam.manualViewSize = Lerp.FloatSmooth(this._followCam.manualViewSize, this._followCam.viewSize, 0.14f, 1.05f);
                    }
                    Layer.Game.fade          = Lerp.Float(Layer.Game.fade, 1f, 0.05f);
                    Layer.Background.fade    = Lerp.Float(Layer.Game.fade, 1f, 0.05f);
                    this._hud.alpha          = Lerp.Float(this._hud.alpha, 0.0f, 0.08f);
                    this._unlockScreen.alpha = Lerp.Float(this._unlockScreen.alpha, 0.0f, 0.08f);
                    if (((double)this._followCam.manualViewSize < 0.0 || (double)this._followCam.manualViewSize == (double)this._followCam.viewSize) && ((double)this._hud.alpha == 0.0 && (double)Layer.Game.fade == 1.0))
                    {
                        flag = true;
                        this._followCam.manualViewSize = -1f;
                        this._duck.alpha = 1f;
                    }
                }
                else if (this._desiredState == ArcadeState.UnlockMachine)
                {
                    if (!this._flipState)
                    {
                        this._followCam.Clear();
                        this._followCam.Add((Thing)this._unlockMachines[0]);
                        HUD.CloseAllCorners();
                    }
                    if (this._state == ArcadeState.ViewChallenge)
                    {
                        this._followCam.manualViewSize = Lerp.FloatSmooth(this._followCam.manualViewSize, this._followCam.viewSize, 0.14f, 1.05f);
                    }
                    this._duck.alpha         = Lerp.FloatSmooth(this._duck.alpha, 1f, 0.1f, 1.1f);
                    Layer.Game.fade          = Lerp.Float(Layer.Game.fade, 1f, 0.05f);
                    Layer.Background.fade    = Lerp.Float(Layer.Game.fade, 1f, 0.05f);
                    this._hud.alpha          = Lerp.Float(this._hud.alpha, 0.0f, 0.08f);
                    this._unlockScreen.alpha = Lerp.Float(this._unlockScreen.alpha, 0.0f, 0.08f);
                    this._unlockMachineWait  = 1f;
                    if (((double)this._followCam.manualViewSize < 0.0 || (double)this._followCam.manualViewSize == (double)this._followCam.viewSize) && ((double)this._hud.alpha == 0.0 && (double)Layer.Game.fade == 1.0))
                    {
                        flag = true;
                        this._followCam.manualViewSize = -1f;
                        this._duck.alpha = 1f;
                    }
                }
                else if (this._desiredState == ArcadeState.LaunchChallenge)
                {
                    if (!this._flipState)
                    {
                        HUD.CloseAllCorners();
                    }
                    Music.volume             = Lerp.Float(Music.volume, 0.0f, 0.01f);
                    this._hud.alpha          = Lerp.Float(this._hud.alpha, 0.0f, 0.02f);
                    this._unlockScreen.alpha = Lerp.Float(this._unlockScreen.alpha, 0.0f, 0.08f);
                    if ((double)this._hud.alpha == 0.0)
                    {
                        flag = true;
                    }
                }
                if (this._desiredState == ArcadeState.UnlockScreen)
                {
                    this._duck.alpha = Lerp.FloatSmooth(this._duck.alpha, 0.0f, 0.1f);
                    this._followCam.manualViewSize = Lerp.FloatSmooth(this._followCam.manualViewSize, 2f, 0.16f);
                    if ((double)this._followCam.manualViewSize < 30.0)
                    {
                        Layer.Game.fade          = Lerp.Float(Layer.Game.fade, 0.0f, 0.08f);
                        Layer.Background.fade    = Lerp.Float(Layer.Game.fade, 0.0f, 0.08f);
                        this._unlockScreen.alpha = Lerp.Float(this._unlockScreen.alpha, 1f, 0.08f);
                        if ((double)this._followCam.manualViewSize < 3.0 && (double)this._unlockScreen.alpha == 1.0 && (double)Layer.Game.fade == 0.0)
                        {
                            flag = true;
                        }
                    }
                }
                this._flipState = true;
                if (this._launchedChallenge)
                {
                    Layer.Background.fade = 0.0f;
                    Layer.Game.fade       = 0.0f;
                }
                if (!flag)
                {
                    return;
                }
                this._flipState = false;
                HUD.CloseAllCorners();
                this._state = this._desiredState;
                if (this._state == ArcadeState.ViewChallenge)
                {
                    if (this._afterChallenge)
                    {
                        Music.Play("Arcade");
                        this._afterChallenge = false;
                    }
                    this._hud.MakeActive();
                    Level.Add((Thing)this._hud);
                    this._duck.active = false;
                }
                else if (this._state == ArcadeState.LaunchChallenge)
                {
                    ArcadeLevel.currentArcade = this;
                    foreach (Thing thing in this.things[typeof(ChallengeConfetti)])
                    {
                        Level.Remove(thing);
                    }
                    Music.Stop();
                    Level.current = (Level) new ChallengeLevel(this._hud.selected.challenge.fileName);
                    if (!this.launchSpecialChallenge)
                    {
                        this._desiredState        = ArcadeState.ViewChallenge;
                        this._hud.launchChallenge = false;
                        this._launchedChallenge   = false;
                        this._afterChallenge      = true;
                    }
                    else
                    {
                        this._desiredState          = ArcadeState.ViewSpecialChallenge;
                        this._hud.launchChallenge   = false;
                        this._launchedChallenge     = false;
                        this._afterChallenge        = true;
                        this.launchSpecialChallenge = false;
                    }
                }
                else
                {
                    if (this._state == ArcadeState.UnlockMachine)
                    {
                        return;
                    }
                    if (this._state == ArcadeState.Normal)
                    {
                        this._unlockMachines.Clear();
                        foreach (ArcadeMachine challenge in this._challenges)
                        {
                            if (challenge.CheckUnlocked())
                            {
                                this._unlockMachines.Add(challenge);
                            }
                        }
                        if (this._unlockMachines.Count > 0)
                        {
                            this._desiredState = ArcadeState.UnlockMachine;
                        }
                        else
                        {
                            if (!this.basementWasUnlocked && Unlocks.IsUnlocked("BASEMENTKEY", Profiles.active[0]))
                            {
                                this.spawnKey            = true;
                                this.basementWasUnlocked = true;
                            }
                            this._duck.active = true;
                        }
                    }
                    else if (this._state == ArcadeState.ViewSpecialChallenge)
                    {
                        this._duck.active = false;
                        if (this._afterChallenge)
                        {
                            Music.Play("Arcade");
                            this._afterChallenge = false;
                            HUD.AddCornerCounter(HUDCorner.TopLeft, "@TICKET@ ", new FieldBinding((object)Profiles.active[0], "ticketCount"), animateCount: true);
                            Chancy.afterChallenge     = true;
                            Chancy.afterChallengeWait = 1f;
                        }
                        else
                        {
                            HUD.AddCornerControl(HUDCorner.BottomLeft, "ACCEPT@SELECT@");
                            HUD.AddCornerControl(HUDCorner.BottomRight, "@QUACK@CANCEL");
                            HUD.AddCornerCounter(HUDCorner.TopLeft, "@TICKET@ ", new FieldBinding((object)Profiles.active[0], "ticketCount"), animateCount: true);
                        }
                        this._duck.active = false;
                    }
                    else if (this._state == ArcadeState.ViewProfileSelector)
                    {
                        this._duck.active = false;
                        ArcadeHatConsole arcadeHatConsole = (ArcadeHatConsole)Level.First <ArcadeHatConsole>();
                        if (arcadeHatConsole == null)
                        {
                            return;
                        }
                        HUD.CloseAllCorners();
                        arcadeHatConsole.Open();
                    }
                    else if (this._state == ArcadeState.ViewChallengeList)
                    {
                        this._duck.active = false;
                        HUD.AddCornerControl(HUDCorner.BottomLeft, "ACCEPT@SELECT@");
                        HUD.AddCornerControl(HUDCorner.BottomRight, "@QUACK@BACK");
                    }
                    else
                    {
                        if (this._state != ArcadeState.UnlockScreen)
                        {
                            return;
                        }
                        this.basementWasUnlocked = Unlocks.IsUnlocked("BASEMENTKEY", Profiles.active[0]);
                        this._unlockScreen.MakeActive();
                        this._duck.active = false;
                    }
                }
            }
            else if (this._state == ArcadeState.Normal || this._state == ArcadeState.UnlockMachine)
            {
                Layer.Game.fade       = Lerp.Float(Layer.Game.fade, 1f, 0.08f);
                Layer.Background.fade = Lerp.Float(Layer.Game.fade, 1f, 0.08f);
                this._hud.alpha       = Lerp.Float(this._hud.alpha, 0.0f, 0.08f);
                if (this._state == ArcadeState.Normal)
                {
                    object obj = (object)null;
                    foreach (ArcadeMachine challenge in this._challenges)
                    {
                        double length = (double)(this._duck.position - challenge.position).length;
                        if (challenge.hover)
                        {
                            obj = (object)challenge;
                            if (Input.Pressed("SHOOT"))
                            {
                                this._hud.activeChallengeGroup = challenge.data;
                                this._desiredState             = ArcadeState.ViewChallenge;
                                this._followCam.manualViewSize = this._followCam.viewSize;
                                this._followCam.Clear();
                                this._followCam.Add((Thing)challenge);
                                HUD.CloseAllCorners();
                                this._hoverMachine = (ArcadeMachine)null;
                                this._hoverThing   = (object)null;
                                return;
                            }
                        }
                        if (this._prizeTable.hover)
                        {
                            obj = (object)this._prizeTable;
                            if (Input.Pressed("SHOOT"))
                            {
                                this._desiredState             = ArcadeState.UnlockScreen;
                                this._followCam.manualViewSize = this._followCam.viewSize;
                                this._followCam.Clear();
                                this._followCam.Add((Thing)this._prizeTable);
                                HUD.CloseAllCorners();
                                this._hoverMachine = (ArcadeMachine)null;
                                this._hoverThing   = (object)null;
                                return;
                            }
                        }
                    }
                    if (Chancy.hover && Input.Pressed("SHOOT"))
                    {
                        this._desiredState = ArcadeState.ViewSpecialChallenge;
                        HUD.CloseAllCorners();
                        this._hoverMachine        = (ArcadeMachine)null;
                        this._hoverThing          = (object)null;
                        Chancy.hover              = false;
                        Chancy.lookingAtChallenge = true;
                        Chancy.OpenChallengeView();
                    }
                    else
                    {
                        ArcadeHatConsole arcadeHatConsole = (ArcadeHatConsole)Level.First <ArcadeHatConsole>();
                        if (arcadeHatConsole != null && Input.Pressed("SHOOT") && arcadeHatConsole.hover)
                        {
                            this._desiredState = ArcadeState.ViewProfileSelector;
                            HUD.CloseAllCorners();
                            this._hoverMachine = (ArcadeMachine)null;
                            this._hoverThing   = (object)null;
                        }
                        else
                        {
                            Chancy.hover = false;
                            if (!Chancy.atCounter)
                            {
                                if ((double)(this._duck.position - Chancy.standingPosition).length < 22.0)
                                {
                                    obj          = (object)Chancy.context;
                                    Chancy.hover = true;
                                }
                                if ((double)Chancy.standingPosition.x < (double)Layer.Game.camera.left - 16.0 || (double)Chancy.standingPosition.x > (double)Layer.Game.camera.right + 16.0 || ((double)Chancy.standingPosition.y < (double)Layer.Game.camera.top - 16.0 || (double)Chancy.standingPosition.y > (double)Layer.Game.camera.bottom + 16.0))
                                {
                                    Chancy.atCounter       = true;
                                    Chancy.activeChallenge = (ChallengeData)null;
                                }
                            }
                            else if (this._prizeTable.hoverChancyChallenge)
                            {
                                obj = (object)this._arcade;
                                if (Input.Pressed("SHOOT"))
                                {
                                    this._desiredState = ArcadeState.ViewChallengeList;
                                    HUD.CloseAllCorners();
                                    Chancy.OpenChallengeList();
                                    this._hoverMachine   = (ArcadeMachine)null;
                                    this._hoverThing     = (object)null;
                                    Chancy.hover         = false;
                                    Chancy.lookingAtList = true;
                                    return;
                                }
                            }
                            if (this._hoverThing == obj)
                            {
                                return;
                            }
                            HUD.CloseAllCorners();
                            this._hoverThing   = obj;
                            this._hoverMachine = !(this._hoverThing is ArcadeMachine) ? (ArcadeMachine)null : obj as ArcadeMachine;
                            if (this._hoverMachine != null)
                            {
                                HUD.AddCornerControl(HUDCorner.BottomLeft, "PLAY@SHOOT@");
                                string text = this._hoverMachine.data.name + " ";
                                foreach (string challenge1 in this._hoverMachine.data.challenges)
                                {
                                    ChallengeData challenge2 = Challenges.GetChallenge(challenge1);
                                    if (challenge2 != null)
                                    {
                                        ChallengeSaveData saveData = Challenges.GetSaveData(challenge2.levelID, this._duck.profile);
                                        if (saveData.trophy == TrophyType.Baseline)
                                        {
                                            text += "@BASELINE@";
                                        }
                                        else if (saveData.trophy == TrophyType.Bronze)
                                        {
                                            text += "@BRONZE@";
                                        }
                                        else if (saveData.trophy == TrophyType.Silver)
                                        {
                                            text += "@SILVER@";
                                        }
                                        else if (saveData.trophy == TrophyType.Gold)
                                        {
                                            text += "@GOLD@";
                                        }
                                        else if (saveData.trophy == TrophyType.Platinum)
                                        {
                                            text += "@PLATINUM@";
                                        }
                                        else if (saveData.trophy == TrophyType.Developer)
                                        {
                                            text += "@DEVELOPER@";
                                        }
                                    }
                                }
                                HUD.AddCornerMessage(HUDCorner.TopLeft, text);
                            }
                            else if (this._prizeTable.hover)
                            {
                                if (this._prizeTable.hoverChancyChallenge)
                                {
                                    HUD.AddCornerControl(HUDCorner.BottomRight, "@SHOOT@VIEW CHALLENGES");
                                }
                                else
                                {
                                    HUD.AddCornerControl(HUDCorner.BottomRight, "@SHOOT@SPEND TICKETS");
                                    HUD.AddCornerCounter(HUDCorner.BottomLeft, "@TICKET@ ", new FieldBinding((object)Profiles.active[0], "ticketCount"), animateCount: true);
                                }
                            }
                            else
                            {
                                switch (obj)
                                {
                                case ArcadeMode _:
                                    if (!this._prizeTable.hoverChancyChallenge)
                                    {
                                        break;
                                    }
                                    HUD.AddCornerControl(HUDCorner.BottomRight, "@SHOOT@VIEW CHALLENGES");
                                    break;

                                case Chancy _:
                                    HUD.AddCornerControl(HUDCorner.BottomLeft, "CHANCY@SHOOT@");
                                    break;
                                }
                            }
                        }
                    }
                }
                else
                {
                    if (this._state != ArcadeState.UnlockMachine)
                    {
                        return;
                    }
                    this._unlockMachineWait   -= 0.02f;
                    Layer.Lighting2.targetFade = Lerp.Float(Layer.Lighting2.targetFade, 0.5f, 0.01f);
                    if ((double)this._unlockMachineWait >= 0.0)
                    {
                        return;
                    }
                    if (this._unlockingMachine)
                    {
                        this._unlockingMachine = false;
                        this._followCam.Clear();
                        this._followCam.Add((Thing)this._unlockMachines[0]);
                        this._unlockMachineWait = 1f;
                    }
                    else if (this._unlockMachines.Count > 0)
                    {
                        this._unlockMachines[0].unlocked = true;
                        this._unlockMachines.RemoveAt(0);
                        this._unlockingMachine = this._unlockMachines.Count > 0;
                        SFX.Play("lightTurnOn", pitch: Rando.Float(-0.1f, 0.1f));
                        this._unlockMachineWait    = 1f;
                        Layer.Lighting2.targetFade = 1f;
                    }
                    else
                    {
                        this._desiredState = ArcadeState.Normal;
                    }
                }
            }
            else if (this._state == ArcadeState.ViewChallenge)
            {
                Graphics.fade         = Lerp.Float(Graphics.fade, 1f, 0.05f);
                Layer.Game.fade       = Lerp.Float(Layer.Game.fade, 0.0f, 0.05f);
                Layer.Background.fade = Lerp.Float(Layer.Game.fade, 0.0f, 0.05f);
                this._hud.alpha       = Lerp.Float(this._hud.alpha, 1f, 0.05f);
                if (!this._hud.quitOut)
                {
                    return;
                }
                this._hud.quitOut  = false;
                this._desiredState = ArcadeState.Normal;
                if (Chancy.activeChallenge != null)
                {
                    return;
                }
                List <ChallengeData> chancyChallenges = Challenges.GetEligibleIncompleteChancyChallenges(Profiles.active[0]);
                if (chancyChallenges.Count <= 0)
                {
                    return;
                }
                Vec2          position      = this._duck.position;
                ArcadeMachine arcadeMachine = Level.Nearest <ArcadeMachine>(this._duck.x, this._duck.y);
                if (arcadeMachine != null)
                {
                    position = arcadeMachine.position;
                }
                chancyChallenges.OrderBy <ChallengeData, int>((Func <ChallengeData, int>)(v => v.GetRequirementValue()));
                Chancy.AddProposition(chancyChallenges[chancyChallenges.Count - 1], position);
            }
            else if (this._state == ArcadeState.UnlockScreen)
            {
                if (!this._unlockScreen.quitOut)
                {
                    return;
                }
                this._unlockScreen.quitOut = false;
                this._desiredState         = ArcadeState.Normal;
            }
            else if (this._state == ArcadeState.ViewSpecialChallenge)
            {
                if (!this.launchSpecialChallenge)
                {
                    Graphics.fade = Lerp.Float(Graphics.fade, 1f, 0.05f);
                    if (Input.Pressed("QUACK"))
                    {
                        if (this.returnToChallengeList)
                        {
                            this._desiredState   = ArcadeState.ViewChallengeList;
                            Chancy.hover         = false;
                            Chancy.lookingAtList = true;
                        }
                        else
                        {
                            this._desiredState = ArcadeState.Normal;
                        }
                        Chancy.lookingAtChallenge = false;
                        HUD.CloseAllCorners();
                        SFX.Play("consoleCancel");
                    }
                    else
                    {
                        if (!Input.Pressed("SELECT"))
                        {
                            return;
                        }
                        this.launchSpecialChallenge = true;
                        SFX.Play("consoleSelect");
                    }
                }
                else
                {
                    Graphics.fade = Lerp.Float(Graphics.fade, 0.0f, 0.05f);
                    if ((double)Graphics.fade >= 0.00999999977648258)
                    {
                        return;
                    }
                    this._hud.launchChallenge = true;
                    this._hud.selected        = new ChallengeCard(0.0f, 0.0f, Chancy.activeChallenge);
                    HUD.CloseAllCorners();
                }
            }
            else if (this._state == ArcadeState.ViewChallengeList)
            {
                Graphics.fade = Lerp.Float(Graphics.fade, 1f, 0.05f);
                if (Input.Pressed("QUACK"))
                {
                    this._desiredState        = ArcadeState.Normal;
                    Chancy.lookingAtChallenge = false;
                    Chancy.lookingAtList      = false;
                    HUD.CloseAllCorners();
                    SFX.Play("consoleCancel");
                }
                else
                {
                    if (!Input.Pressed("SELECT"))
                    {
                        return;
                    }
                    Chancy.AddProposition(Chancy.selectedChallenge, Chancy.standingPosition);
                    this.returnToChallengeList = true;
                    this._desiredState         = ArcadeState.ViewSpecialChallenge;
                    HUD.CloseAllCorners();
                    this._hoverMachine        = (ArcadeMachine)null;
                    this._hoverThing          = (object)null;
                    Chancy.hover              = false;
                    Chancy.lookingAtChallenge = true;
                    Chancy.lookingAtList      = false;
                    Chancy.OpenChallengeView();
                }
            }
            else
            {
                if (this._state != ArcadeState.ViewProfileSelector)
                {
                    return;
                }
                Graphics.fade = Lerp.Float(Graphics.fade, 1f, 0.05f);
                ArcadeHatConsole arcadeHatConsole = (ArcadeHatConsole)Level.First <ArcadeHatConsole>();
                if (arcadeHatConsole == null || arcadeHatConsole.IsOpen())
                {
                    return;
                }
                foreach (ArcadeMachine challenge in this._challenges)
                {
                    challenge.unlocked = challenge.CheckUnlocked(false);
                }
                this._unlockMachines.Clear();
                this.UpdateDefault();
                this._desiredState = ArcadeState.Normal;
            }
        }
示例#28
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();
 }
示例#29
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();
        }
示例#30
0
 public override void Update()
 {
     HUD.CloseCorner(HUDCorner.TopLeft);
     this._dialog.DoUpdate();
     if (this._dialog.opened)
     {
         return;
     }
     Editor.lockInput = (ContextMenu)null;
     if (this._dialog.result != null && this._dialog.result != "")
     {
         string        result        = this._dialog.result;
         LevelPlaylist levelPlaylist = new LevelPlaylist();
         levelPlaylist.levels.AddRange((IEnumerable <string>)Editor.activatedLevels);
         XDocument doc = new XDocument();
         doc.Add((object)levelPlaylist.Serialize());
         DuckFile.SaveXDocument(doc, DuckFile.levelDirectory + result + ".play");
         this.SetCurrentFolder(this._rootDirectory);
         this._dialog.result = (string)null;
     }
     else
     {
         if (this._selectedLevel == null)
         {
             this._exiting = true;
         }
         if (Editor.activatedLevels.Count > 0)
         {
             if (!this.showPlaylistOption)
             {
                 this.showPlaylistOption = true;
                 HUD.AddCornerControl(HUDCorner.BottomLeft, "@RAGDOLL@NEW PLAYLIST");
             }
         }
         else if (this.showPlaylistOption)
         {
             this.showPlaylistOption = false;
             HUD.CloseCorner(HUDCorner.BottomLeft);
         }
         if (this._deleteFile.value)
         {
             foreach (string str in this._selectedLevel.levelsInside)
             {
                 Editor.activatedLevels.Remove(str);
             }
             Editor.activatedLevels.Remove(this._selectedLevel.path);
             if (this._selectedLevel.itemType == LSItemType.Folder)
             {
                 DuckFile.DeleteFolder(DuckFile.levelDirectory + this._selectedLevel.path);
             }
             else if (this._selectedLevel.itemType == LSItemType.Playlist)
             {
                 DuckFile.Delete(DuckFile.levelDirectory + this._selectedLevel.path);
             }
             else
             {
                 DuckFile.Delete(DuckFile.levelDirectory + this._selectedLevel.path + ".lev");
             }
             Thread.Sleep(100);
             this.SetCurrentFolder(this._currentDirectory);
             this._deleteFile.value = false;
         }
         if (this._exiting)
         {
             HUD.CloseAllCorners();
             Graphics.fade = Lerp.Float(Graphics.fade, 0.0f, 0.04f);
             if ((double)Graphics.fade >= 0.00999999977648258)
             {
                 return;
             }
             this.isClosed = true;
         }
         else
         {
             Graphics.fade = Lerp.Float(Graphics.fade, 1f, 0.04f);
             if (Input.Pressed("UP"))
             {
                 if (this._selectedItem > 0)
                 {
                     --this._selectedItem;
                 }
                 if (this._selectedItem < this._topIndex)
                 {
                     this._topIndex = this._selectedItem;
                 }
             }
             else if (Input.Pressed("DOWN"))
             {
                 if (this._selectedItem < this._items.Count <LSItem>() - 1)
                 {
                     ++this._selectedItem;
                 }
                 if (this._selectedItem >= this._topIndex + this._maxItems)
                 {
                     this._topIndex = this._selectedItem + 1 - this._maxItems;
                 }
             }
             else if (Input.Pressed("LEFT"))
             {
                 this._selectedItem -= this._maxItems - 1;
                 if (this._selectedItem < 0)
                 {
                     this._selectedItem = 0;
                 }
                 if (this._selectedItem < this._topIndex)
                 {
                     this._topIndex = this._selectedItem;
                 }
             }
             else if (Input.Pressed("RIGHT"))
             {
                 this._selectedItem += this._maxItems - 1;
                 if (this._selectedItem > this._items.Count <LSItem>() - 1)
                 {
                     this._selectedItem = this._items.Count <LSItem>() - 1;
                 }
                 if (this._selectedItem >= this._topIndex + this._maxItems)
                 {
                     this._topIndex = this._selectedItem + 1 - this._maxItems;
                 }
             }
             else if (Input.Pressed("SHOOT"))
             {
                 if (this._selectedLevel.itemType != LSItemType.UpFolder)
                 {
                     if (this._selectedLevel.itemType == LSItemType.Folder || this._selectedLevel.itemType == LSItemType.Playlist || this._selectedLevel.itemType == LSItemType.Workshop)
                     {
                         if (!this._selectedLevel.enabled)
                         {
                             this._selectedLevel.enabled          = true;
                             this._selectedLevel.partiallyEnabled = false;
                             Editor.activatedLevels.AddRange((IEnumerable <string>) this._selectedLevel.levelsInside);
                         }
                         else
                         {
                             this._selectedLevel.enabled          = false;
                             this._selectedLevel.partiallyEnabled = false;
                             foreach (string str in this._selectedLevel.levelsInside)
                             {
                                 Editor.activatedLevels.Remove(str);
                             }
                         }
                     }
                     else if (Editor.activatedLevels.Contains(this._selectedLevel.path))
                     {
                         Editor.activatedLevels.Remove(this._selectedLevel.path);
                     }
                     else
                     {
                         Editor.activatedLevels.Add(this._selectedLevel.path);
                     }
                 }
             }
             else if (Input.Pressed("SELECT"))
             {
                 if (this._selectedLevel.itemType == LSItemType.Workshop)
                 {
                     this.SetCurrentFolder(this._selectedLevel.path);
                 }
                 else if (this._selectedLevel.itemType == LSItemType.Folder || this._selectedLevel.itemType == LSItemType.Playlist)
                 {
                     this.SetCurrentFolder(this._rootDirectory + this._selectedLevel.path);
                 }
                 else if (this._selectedLevel.itemType == LSItemType.UpFolder)
                 {
                     this.FolderUp();
                 }
             }
             else if (Input.Pressed("QUACK"))
             {
                 if (this._currentDirectory != this._rootDirectory)
                 {
                     this.FolderUp();
                 }
             }
             else if (Input.Pressed("START"))
             {
                 this._exiting = true;
             }
             else if (Input.Pressed("RAGDOLL"))
             {
                 this._dialog.Open("New Playlist...");
                 Editor.lockInput = (ContextMenu)this._dialog;
             }
             else if (Input.Pressed("GRAB") && MonoMain.pauseMenu != this._confirmMenu && (this._selectedLevel.itemType != LSItemType.UpFolder && this._selectedLevel.itemType != LSItemType.Workshop))
             {
                 LevelSelect._skipCompanionOpening = true;
                 MonoMain.pauseMenu = (UIComponent)this._confirmMenu;
                 this._confirmMenu.Open();
                 SFX.Play("pause", 0.6f);
             }
             this.PositionItems();
             if (this._selectedLevel != this._lastSelection)
             {
                 if (this._lastSelection == null || this._selectedLevel.itemType != this._lastSelection.itemType)
                 {
                     HUD.CloseCorner(HUDCorner.BottomRight);
                     if (this._selectedLevel.itemType == LSItemType.UpFolder)
                     {
                         HUD.AddCornerControl(HUDCorner.BottomRight, "@SELECT@Return");
                     }
                     else if (this._selectedLevel.itemType == LSItemType.Folder || this._selectedLevel.itemType == LSItemType.Playlist || this._selectedLevel.itemType == LSItemType.Workshop)
                     {
                         HUD.AddCornerControl(HUDCorner.BottomRight, "@SHOOT@Toggle");
                         HUD.AddCornerControl(HUDCorner.BottomRight, "@SELECT@Open");
                     }
                     else
                     {
                         HUD.AddCornerControl(HUDCorner.BottomRight, "@SHOOT@Toggle");
                     }
                 }
                 this._lastSelection = this._selectedLevel;
             }
             if (this._selectedLevel != this._previewItem)
             {
                 if (this._selectedLevel.itemType == LSItemType.Level)
                 {
                     this._preview       = Content.GeneratePreview(this._selectedLevel.path);
                     this._previewSprite = this._preview == null ? (Sprite)null : new Sprite(this._preview, 0.0f, 0.0f);
                 }
                 else
                 {
                     this._previewSprite = (Sprite)null;
                 }
                 this._previewItem = this._selectedLevel;
             }
             foreach (Thing thing in this._items)
             {
                 thing.Update();
             }
         }
     }
 }