示例#1
0
 public void Pulse(int type, WireTileset wire)
 {
     this.Spawn();
     SFX.Play("click");
 }
 public override void Update()
 {
     base.Update();
     this.offDir = (sbyte)1;
     if ((double)this._hitPoints <= 0.0)
     {
         if (this.graphic != this._toreUp)
         {
             float     num1  = this._fluidLevel * 0.5f;
             float     num2  = this._fluidLevel * 0.5f;
             FluidData fluid = this._fluid;
             fluid.amount = num1 / 20f;
             for (int index = 0; index < 20; ++index)
             {
                 Level.Add((Thing) new Fluid(this.x + Rando.Float(-4f, 4f), this.y + Rando.Float(-4f, 4f), new Vec2(Rando.Float(-4f, 4f), Rando.Float(-4f, 0.0f)), fluid));
             }
             fluid.amount = num2;
             Level.Add((Thing) new Fluid(this.x, this.y - 8f, new Vec2(0.0f, -1f), fluid));
             Level.Add((Thing)SmallSmoke.New(this.x, this.y));
             SFX.Play("bulletHitWater");
             SFX.Play("crateDestroy");
         }
         this.graphic            = (Sprite)this._toreUp;
         this._onFire            = false;
         this.burnt              = 0.0f;
         this._weight            = 0.1f;
         this._collisionSize.y   = 8f;
         this._collisionOffset.y = -3f;
     }
     this.burnSpeed = 0.0015f;
     if (this._onFire && (double)this.burnt < 0.899999976158142)
     {
         if ((double)this.burnt > 0.300000011920929)
         {
             this.graphic = this._melting;
         }
         this.yscale             = (float)(0.5 + (1.0 - (double)this.burnt) * 0.5);
         this.centery            = (float)(8.0 - (double)this.burnt * 7.0);
         this._collisionOffset.y = (float)((double)this.burnt * 7.0 - 8.0);
         this._collisionSize.y   = (float)(16.0 - (double)this.burnt * 7.0);
     }
     if (!this._bottomHoles && (double)this.burnt > 0.600000023841858)
     {
         this._bottomHoles = true;
         this._holes.Add(new FluidStream(0.0f, 0.0f, new Vec2(-1f, -1f), 1f, new Vec2(-7f, 8f))
         {
             holeThickness = 2f
         });
         this._holes.Add(new FluidStream(0.0f, 0.0f, new Vec2(1f, -1f), 1f, new Vec2(7f, 8f))
         {
             holeThickness = 2f
         });
     }
     if (this._owner != null)
     {
         this.hSpeed = this.owner.hSpeed;
         this.vSpeed = this.owner.vSpeed;
     }
     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.008f * hole.holeThickness;
                 FluidData fluid = this._fluid;
                 fluid.amount = num2;
                 hole.Feed(fluid);
                 this._fluidLevel -= num2;
                 this._lossAccum  += num2;
                 while ((double)this._lossAccum > 0.0500000007450581)
                 {
                     this._lossAccum -= 0.05f;
                     if (this.sequence != null && this.sequence.isValid && ChallengeLevel.running)
                     {
                         ++ChallengeLevel.goodiesGot;
                         SFX.Play("tinyTick");
                     }
                 }
             }
         }
     }
     this.weight = this._fluidLevel * 10f;
     ++this._alternate;
     if (this._alternate <= 4)
     {
         return;
     }
     this._alternate = 0;
 }
 public override void Selected(ContextMenu item)
 {
     SFX.Play("highClick", 0.3f);
     if (item.text == "@NEWICONTINY@New File...")
     {
         this._dialog.Open("Save File As...");
         Editor.lockInput = (ContextMenu)this._dialog;
     }
     else if (item.data.EndsWith(this.TypeExtension()) && this._type != ContextFileType.All)
     {
         if (!this._selectLevels)
         {
             if (!this._save)
             {
                 this.Close();
                 string str = this._currentDirectory + "/" + item.data;
                 if (this._loadLevel)
                 {
                     (Level.current as Editor).LoadLevel(str);
                 }
                 else if (this._type == ContextFileType.ArcadeStyle)
                 {
                     this.result = Editor.TextureToString((Texture2D)Content.Load <Tex2D>(str));
                 }
                 else
                 {
                     this.result = str.Replace(this._rootFolder, "");
                 }
             }
             else
             {
                 this._overwriteDialog.Open("OVERWRITE " + item.data + "?");
                 Editor.lockInput             = (ContextMenu)this._overwriteDialog;
                 this._doOverwriteDialog      = true;
                 this._overwriteDialog.result = false;
                 this._overwriteName          = item.data;
                 Editor.tookInput             = true;
             }
         }
         else
         {
             if (!(item is ContextCheckBox contextCheckBox))
             {
                 return;
             }
             contextCheckBox.isChecked = !contextCheckBox.isChecked;
             if (!contextCheckBox.isChecked)
             {
                 Editor.activatedLevels.Remove(contextCheckBox.path);
             }
             else
             {
                 Editor.activatedLevels.Add(contextCheckBox.path);
             }
         }
     }
     else
     {
         this.ClearItems();
         this.SetDirectory(this._currentDirectory + "/" + item.data);
     }
 }
示例#4
0
 protected override void PlayFireSound() => SFX.Play("dartGunFire", 0.7f, Rando.Float(0.2f) - 0.1f);
示例#5
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();
             }
         }
     }
 }
 public override void Update()
 {
     if (this.open)
     {
         if (this._captureTarget == null)
         {
             this._captureTarget = !this._resizable ? new RenderTarget2D(152, 152) : new RenderTarget2D(1280, 720);
         }
         MonoMain.autoPauseFade = false;
         if (Input.Down("LEFT"))
         {
             --this._capturePosition.x;
         }
         if (Input.Down("RIGHT"))
         {
             ++this._capturePosition.x;
         }
         if (Input.Down("UP"))
         {
             --this._capturePosition.y;
         }
         if (Input.Down("DOWN"))
         {
             ++this._capturePosition.y;
         }
         float num = (float)(DuckGame.Graphics.width / 320);
         if (this._resizable)
         {
             this._captureSize += this._captureSize * ((float)-((double)InputProfile.DefaultPlayer1.leftTrigger - (double)InputProfile.DefaultPlayer1.rightTrigger) * 0.1f);
             if ((double)this._captureSize.x > 1280.0)
             {
                 this._captureSize.x = 1280f;
             }
             if ((double)this._captureSize.y > 720.0)
             {
                 this._captureSize.y = 720f;
             }
             Vec2 vec2 = this._capturePosition * num;
             if ((double)vec2.x < 0.0)
             {
                 vec2.x = 0.0f;
             }
             if ((double)vec2.y < 0.0)
             {
                 vec2.y = 0.0f;
             }
             this._capturePosition = vec2 / num;
         }
         DuckGame.Graphics.SetRenderTarget(this._captureTarget);
         Camera camera = new Camera(this._capturePosition.x * num, this._capturePosition.y * num, (float)(int)this._captureSize.x * num, (float)(int)this._captureSize.y * num);
         DuckGame.Graphics.Clear(Color.Black);
         Viewport viewport = DuckGame.Graphics.viewport;
         DuckGame.Graphics.viewport = new Viewport(0, 0, (int)((double)this._captureSize.x * (double)num), (int)((double)this._captureSize.y * (double)num));
         DuckGame.Graphics.screen.Begin(SpriteSortMode.BackToFront, BlendState.AlphaBlend, SamplerState.PointClamp, DepthStencilState.DepthRead, RasterizerState.CullNone, (MTEffect)null, camera.getMatrix());
         DuckGame.Graphics.Draw((Tex2D)MonoMain.screenCapture, 0.0f, 0.0f);
         DuckGame.Graphics.screen.End();
         DuckGame.Graphics.viewport = viewport;
         DuckGame.Graphics.SetRenderTarget((RenderTarget2D)null);
         if (Input.Pressed("SELECT"))
         {
             SFX.Play("cameraFlash");
             Editor.previewCapture = (Texture2D)(Tex2D)this._captureTarget;
             this._captureTarget   = (RenderTarget2D)null;
             new UIMenuActionOpenMenu((UIComponent)this, (UIComponent)this._closeMenu).Activate();
         }
         else if (Input.Pressed("QUACK"))
         {
             SFX.Play("consoleCancel");
             new UIMenuActionOpenMenu((UIComponent)this, (UIComponent)this._closeMenu).Activate();
         }
     }
     base.Update();
 }
示例#7
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;
     }
 }
        public override void Update()
        {
            ChallengeLevel._timer.Update();
            if (this._fading)
            {
                DuckGame.Graphics.fade = Lerp.Float(DuckGame.Graphics.fade, 0.0f, 0.05f);
                if ((double)DuckGame.Graphics.fade >= 0.00999999977648258)
                {
                    return;
                }
                if (this._validityTest)
                {
                    ArcadeTestDialogue.success = this._challenge.wonTrophies.Count > 0 && this._challenge.wonTrophies[0].type == TrophyType.Developer;
                    Level.current          = (Level)ArcadeTestDialogue.currentEditor;
                    DuckGame.Graphics.fade = 1f;
                }
                else
                {
                    if (this.things[typeof(EditorTestLevel)].Count <Thing>() > 0)
                    {
                        Level.current = (Level)(this.things[typeof(EditorTestLevel)].First <Thing>() as EditorTestLevel).editor;
                        Music.Stop();
                    }
                    else
                    {
                        Level.current = Arcade.currentArcade == null ? (Level)ArcadeLevel.currentArcade : (Level)Arcade.currentArcade;
                    }
                    this._fading = false;
                }
            }
            else
            {
                if ((double)this._restartMessageWait > 0.0)
                {
                    this._restartMessageWait -= 0.008f;
                }
                else
                {
                    HUD.CloseCorner(HUDCorner.TopLeft);
                }
                if (this._doRestart)
                {
                    ChallengeLevel.running = false;
                    this._waitForRestart  -= 0.04f;
                    if ((double)this._waitForRestart <= 0.0)
                    {
                        this._restarting = true;
                    }
                }
                this._waitFade -= 0.04f;
                if (!this._didFade && (double)this._waitFade <= 0.0 && (double)DuckGame.Graphics.fade < 1.0)
                {
                    DuckGame.Graphics.fade = Lerp.Float(DuckGame.Graphics.fade, 1f, 0.04f);
                }
                else if (this._restarting)
                {
                    ChallengeLevel.running         = false;
                    this.transitionSpeedMultiplier = 2f;
                    EditorTestLevel editorTestLevel = (EditorTestLevel)null;
                    if (this.things[typeof(EditorTestLevel)].Count <Thing>() > 0)
                    {
                        editorTestLevel = this.things[typeof(EditorTestLevel)].First <Thing>() as EditorTestLevel;
                    }
                    Level.current = !(this._level != "") ? (Level) new ChallengeLevel(this._levelData, this._validityTest) : (Level) new ChallengeLevel(this._level);
                    Level.current.transitionSpeedMultiplier    = 2f;
                    ((ChallengeLevel)Level.current)._waitSpawn = 0.0f;
                    if (editorTestLevel == null)
                    {
                        return;
                    }
                    Level.current.AddThing((Thing)editorTestLevel);
                }
                else
                {
                    if ((double)this._waitFade > 0.0)
                    {
                        return;
                    }
                    this._didFade = true;
                    if (this._finished)
                    {
                        ChallengeLevel.running = false;
                        this.PauseLogic();
                        if ((double)this._finishWait > 0.0)
                        {
                            this._finishWait -= 0.01f;
                        }
                        else
                        {
                            if (!this._playedEndMusic)
                            {
                                this._playedEndMusic          = true;
                                Level.current.simulatePhysics = false;
                                ArcadeFrame arcadeFrame = (ArcadeFrame)null;
                                if (this._win)
                                {
                                    if (ArcadeLevel.currentArcade != null)
                                    {
                                        arcadeFrame = ArcadeLevel.currentArcade.GetFrame();
                                        if (arcadeFrame != null)
                                        {
                                            Vec2  renderTargetSize = arcadeFrame.GetRenderTargetSize();
                                            float renderTargetZoom = arcadeFrame.GetRenderTargetZoom();
                                            if (this._captureTarget == null)
                                            {
                                                this._captureTarget = new RenderTarget2D((int)((double)renderTargetSize.x * 6.0), (int)((double)renderTargetSize.y * 6.0));
                                            }
                                            int    num    = DuckGame.Graphics.width / 320;
                                            Camera camera = new Camera(0.0f, 0.0f, (float)this._captureTarget.width * renderTargetZoom, (float)this._captureTarget.height * renderTargetZoom);
                                            if (ChallengeLevel._duck != null)
                                            {
                                                Layer.HUD.visible = false;
                                                MonoMain.RenderGame(MonoMain.screenCapture);
                                                Layer.HUD.visible = true;
                                                Matrix result;
                                                Matrix.CreateOrthographicOffCenter(0.0f, (float)MonoMain.screenCapture.width, (float)MonoMain.screenCapture.height, 0.0f, 0.0f, -1f, out result);
                                                result.M41 += -0.5f * result.M11;
                                                result.M42 += -0.5f * result.M22;
                                                Matrix matrix = Level.current.camera.getMatrix();
                                                Vec3   vec3   = (Vec3)DuckGame.Graphics.viewport.Project((Vector3) new Vec3(ChallengeLevel._duck.cameraPosition.x, ChallengeLevel._duck.cameraPosition.y, 0.0f), (Microsoft.Xna.Framework.Matrix)result, (Microsoft.Xna.Framework.Matrix)matrix, (Microsoft.Xna.Framework.Matrix)Matrix.Identity);
                                                DuckGame.Graphics.SetRenderTarget(this._captureTarget);
                                                camera.center = new Vec2(vec3.x, vec3.y);
                                                if ((double)camera.bottom > (double)MonoMain.screenCapture.height)
                                                {
                                                    camera.centerY = (float)MonoMain.screenCapture.height - camera.height / 2f;
                                                }
                                                if ((double)camera.top < 0.0)
                                                {
                                                    camera.centerY = camera.height / 2f;
                                                }
                                                if ((double)camera.right > (double)MonoMain.screenCapture.width)
                                                {
                                                    camera.centerX = (float)MonoMain.screenCapture.width - camera.width / 2f;
                                                }
                                                if ((double)camera.left < 0.0)
                                                {
                                                    camera.centerX = camera.width / 2f;
                                                }
                                                DuckGame.Graphics.Clear(Color.Black);
                                                DuckGame.Graphics.screen.Begin(SpriteSortMode.BackToFront, BlendState.AlphaBlend, SamplerState.PointClamp, DepthStencilState.DepthRead, RasterizerState.CullNone, (MTEffect)null, camera.getMatrix());
                                                DuckGame.Graphics.Draw((Tex2D)MonoMain.screenCapture, 0.0f, 0.0f);
                                                DuckGame.Graphics.screen.End();
                                                DuckGame.Graphics.SetRenderTarget((RenderTarget2D)null);
                                            }
                                        }
                                    }
                                    if (this._challenge.wonTrophies.Count > 0 && this._challenge.wonTrophies[0].type == TrophyType.Developer)
                                    {
                                        SFX.Play("developerWin");
                                    }
                                    else
                                    {
                                        SFX.Play("challengeWin");
                                    }
                                    this._showEndTextWait = 1f;
                                }
                                else
                                {
                                    SFX.Play("challengeLose");
                                    this._showEndTextWait = 1f;
                                }
                                if (this._challenge.wonTrophies.Count > 0)
                                {
                                    this._trophyGroup = new UIComponent(Layer.HUD.camera.width / 2f, Layer.HUD.camera.height / 2f, 0.0f, 0.0f);
                                    this._trophyMenu  = new UIMenu("@LWING@" + this._challenge.challenge.name + "@RWING@", Layer.HUD.camera.width / 2f, Layer.HUD.camera.height / 2f, 210f, conString: "@DPAD@MOVE  @SELECT@SELECT");
                                    UIDivider uiDivider1 = new UIDivider(false, 0.0f, 6f);
                                    UIDivider uiDivider2 = new UIDivider(true, 0.0f);
                                    SpriteMap spriteMap  = new SpriteMap("challengeTrophy", 70, 65);
                                    if (this._challenge.wonTrophies.Count > 0)
                                    {
                                        if (this._challenge.wonTrophies[0].type == TrophyType.Bronze)
                                        {
                                            spriteMap.frame = 1;
                                            uiDivider2.leftSection.Add((UIComponent) new UIText("BRONZE", Colors.Bronze, UIAlign.Top), true);
                                        }
                                        else if (this._challenge.wonTrophies[0].type == TrophyType.Silver)
                                        {
                                            spriteMap.frame = 2;
                                            uiDivider2.leftSection.Add((UIComponent) new UIText("SILVER", Colors.Silver, UIAlign.Top), true);
                                        }
                                        else if (this._challenge.wonTrophies[0].type == TrophyType.Gold)
                                        {
                                            spriteMap.frame = 3;
                                            uiDivider2.leftSection.Add((UIComponent) new UIText("GOLD", Colors.Gold, UIAlign.Top), true);
                                        }
                                        else if (this._challenge.wonTrophies[0].type == TrophyType.Platinum)
                                        {
                                            spriteMap.frame = 4;
                                            uiDivider2.leftSection.Add((UIComponent) new UIText("PLATINUM", Colors.Platinum, UIAlign.Top), true);
                                        }
                                        else if (this._challenge.wonTrophies[0].type == TrophyType.Developer)
                                        {
                                            spriteMap.frame = 5;
                                            uiDivider2.leftSection.Add((UIComponent) new UIText("UR THE BEST", Colors.Developer, UIAlign.Top), true);
                                        }
                                    }
                                    uiDivider2.leftSection.Add((UIComponent) new UIText("               ", Color.White, UIAlign.Left), true);
                                    bool flag = false;
                                    ChallengeSaveData saveData = Challenges.GetSaveData(this.id, ChallengeLevel._duck.profile);
                                    int bestTime = saveData.bestTime;
                                    if (saveData.bestTime == 0 || (int)(ChallengeLevel.timer.elapsed.TotalSeconds * 1000.0) < saveData.bestTime)
                                    {
                                        saveData.bestTime = (int)(ChallengeLevel.timer.elapsed.TotalSeconds * 1000.0);
                                    }
                                    if (this._challenge.wonTrophies[0].type > saveData.trophy)
                                    {
                                        saveData.trophy = this._challenge.wonTrophies[0].type;
                                        if (saveData.trophy > TrophyType.Silver)
                                        {
                                            flag = true;
                                        }
                                    }
                                    int targets1 = saveData.targets;
                                    if (ChallengeLevel.targetsShot > saveData.targets)
                                    {
                                        saveData.targets = ChallengeLevel.targetsShot;
                                    }
                                    int targets2 = saveData.targets;
                                    if (ChallengeLevel.goodiesGot > saveData.goodies)
                                    {
                                        saveData.goodies = ChallengeLevel.goodiesGot;
                                    }
                                    if (this._challenge.challenge.hasTimeRequirements)
                                    {
                                        uiDivider2.leftSection.Add((UIComponent) new UIText("TIME", Color.White, UIAlign.Left), true);
                                        uiDivider2.leftSection.Add((UIComponent) new UIText(MonoMain.TimeString(ChallengeLevel.timer.elapsed, small: true), Color.Lime, UIAlign.Right), true);
                                        uiDivider2.leftSection.Add((UIComponent) new UIText("               ", Color.White, UIAlign.Left), true);
                                        if (targets1 != 0)
                                        {
                                            if ((double)bestTime < ChallengeLevel.timer.elapsed.TotalSeconds * 1000.0)
                                            {
                                                TimeSpan span = TimeSpan.FromMilliseconds(ChallengeLevel.timer.elapsed.TotalSeconds * 1000.0 - (double)bestTime);
                                                uiDivider2.leftSection.Add((UIComponent) new UIText("DIFFERENCE", Color.White, UIAlign.Left), true);
                                                uiDivider2.leftSection.Add((UIComponent) new UIText("+" + MonoMain.TimeString(span, small: true), Color.Red, UIAlign.Right), true);
                                            }
                                            else
                                            {
                                                TimeSpan span = TimeSpan.FromMilliseconds((double)bestTime - ChallengeLevel.timer.elapsed.TotalSeconds * 1000.0);
                                                uiDivider2.leftSection.Add((UIComponent) new UIText("DIFFERENCE", Color.White, UIAlign.Left), true);
                                                uiDivider2.leftSection.Add((UIComponent) new UIText("-" + MonoMain.TimeString(span, small: true), Color.Lime, UIAlign.Right), true);
                                                flag = true;
                                            }
                                        }
                                        else
                                        {
                                            uiDivider2.leftSection.Add((UIComponent) new UIText("               ", Color.White, UIAlign.Left), true);
                                            uiDivider2.leftSection.Add((UIComponent) new UIText("               ", Color.White, UIAlign.Left), true);
                                        }
                                    }
                                    if (saveData.trophy < TrophyType.Gold)
                                    {
                                        flag = false;
                                    }
                                    if (this._challenge.challenge.countTargets)
                                    {
                                        if (this._challenge.challenge.prefix != "" && this._challenge.challenge.prefix != null)
                                        {
                                            uiDivider2.leftSection.Add((UIComponent) new UIText(this._challenge.challenge.prefix, Color.White, UIAlign.Left), true);
                                        }
                                        else
                                        {
                                            uiDivider2.leftSection.Add((UIComponent) new UIText("TARGETS", Color.White, UIAlign.Left), true);
                                        }
                                        string textVal = Convert.ToString(ChallengeLevel.targetsShot);
                                        Color  c       = Color.Lime;
                                        if (targets1 != 0)
                                        {
                                            if (targets1 < ChallengeLevel.targetsShot)
                                            {
                                                int num = ChallengeLevel.targetsShot - targets1;
                                                c       = Color.Lime;
                                                textVal = textVal + " (+" + Convert.ToString(num) + ")";
                                                flag    = true;
                                            }
                                            else if (targets1 > ChallengeLevel.targetsShot)
                                            {
                                                int num = targets1 - ChallengeLevel.targetsShot;
                                                c       = Color.Red;
                                                textVal = textVal + " (-" + Convert.ToString(num) + ")";
                                            }
                                            else
                                            {
                                                c = Color.White;
                                            }
                                        }
                                        uiDivider2.leftSection.Add((UIComponent) new UIText(textVal, c, UIAlign.Right), true);
                                        uiDivider2.leftSection.Add((UIComponent) new UIText("               ", Color.White, UIAlign.Left), true);
                                    }
                                    if (this._challenge.challenge.countGoodies)
                                    {
                                        if (this._challenge.challenge.prefix != "" && this._challenge.challenge.prefix != null)
                                        {
                                            uiDivider2.leftSection.Add((UIComponent) new UIText(this._challenge.challenge.prefix, Color.White, UIAlign.Left), true);
                                        }
                                        else
                                        {
                                            uiDivider2.leftSection.Add((UIComponent) new UIText("NUMBER", Color.White, UIAlign.Left), true);
                                        }
                                        string textVal = Convert.ToString(ChallengeLevel.goodiesGot);
                                        Color  c       = Color.Lime;
                                        if (targets2 != 0)
                                        {
                                            if (targets2 < ChallengeLevel.goodiesGot)
                                            {
                                                int num = ChallengeLevel.goodiesGot - targets2;
                                                c       = Color.Lime;
                                                textVal = textVal + " (+" + Convert.ToString(num) + ")";
                                                flag    = true;
                                            }
                                            else if (targets2 > ChallengeLevel.goodiesGot)
                                            {
                                                int num = targets2 - ChallengeLevel.goodiesGot;
                                                c       = Color.Red;
                                                textVal = textVal + " (-" + Convert.ToString(num) + ")";
                                            }
                                            else
                                            {
                                                c = Color.White;
                                            }
                                        }
                                        uiDivider2.leftSection.Add((UIComponent) new UIText(textVal, c, UIAlign.Right), true);
                                        uiDivider2.leftSection.Add((UIComponent) new UIText("               ", Color.White, UIAlign.Left), true);
                                    }
                                    uiDivider2.rightSection.Add((UIComponent) new UIImage((Sprite)spriteMap, UIAlign.Right), true);
                                    uiDivider1.leftSection.Add((UIComponent)uiDivider2, true);
                                    uiDivider1.rightSection.vertical     = false;
                                    uiDivider1.rightSection.borderSize.y = 2f;
                                    if (this._validityTest)
                                    {
                                        if (this._challenge.wonTrophies.Count > 0 && this._challenge.wonTrophies[0].type == TrophyType.Developer)
                                        {
                                            uiDivider1.rightSection.Add((UIComponent) new UIMenuItem("CONTINUE   ", (UIMenuAction) new UIMenuActionCloseMenuSetBoolean(this._trophyGroup, this._quit), UIAlign.Left), true);
                                        }
                                        else
                                        {
                                            uiDivider1.rightSection.Add((UIComponent) new UIMenuItem("RETRY", (UIMenuAction) new UIMenuActionCloseMenuSetBoolean(this._trophyGroup, this._restart), UIAlign.Left), true);
                                        }
                                    }
                                    else
                                    {
                                        uiDivider1.rightSection.Add((UIComponent) new UIMenuItem("CONTINUE   ", (UIMenuAction) new UIMenuActionCloseMenuSetBoolean(this._trophyGroup, this._quit), UIAlign.Left), true);
                                        uiDivider1.rightSection.Add((UIComponent) new UIMenuItem("RETRY", (UIMenuAction) new UIMenuActionCloseMenuSetBoolean(this._trophyGroup, this._restart), UIAlign.Left), true);
                                    }
                                    this._trophyMenu.Add((UIComponent)uiDivider1, true);
                                    this._trophyMenu.Close();
                                    this._trophyGroup.Add((UIComponent)this._trophyMenu, false);
                                    this._trophyGroup.Close();
                                    Level.Add((Thing)this._trophyGroup);
                                    if (arcadeFrame != null && flag && saveData != null)
                                    {
                                        saveData.frameID     = arcadeFrame._identifier;
                                        saveData.frameImage  = Editor.TextureToString((Texture2D)(Tex2D)this._captureTarget);
                                        arcadeFrame.saveData = saveData;
                                    }
                                    Challenges.Save(this.id);
                                    Profiles.Save(ChallengeLevel._duck.profile);
                                }
                                else
                                {
                                    this._trophyGroup = new UIComponent(Layer.HUD.camera.width / 2f, Layer.HUD.camera.height / 2f, 0.0f, 0.0f);
                                    this._trophyMenu  = new UIMenu("@LWING@" + this._challenge.challenge.name + "@RWING@", Layer.HUD.camera.width / 2f, Layer.HUD.camera.height / 2f, 210f, conString: "@DPAD@MOVE  @SELECT@SELECT");
                                    UIDivider uiDivider1 = new UIDivider(false, 0.0f, 6f);
                                    UIDivider uiDivider2 = new UIDivider(true, 0.0f);
                                    uiDivider2.leftSection.Add((UIComponent) new UIText("FAILED", Color.Red, UIAlign.Top), true);
                                    uiDivider2.leftSection.Add((UIComponent) new UIText("               ", Color.White, UIAlign.Left), true);
                                    uiDivider2.leftSection.Add((UIComponent) new UIText("               ", Color.White, UIAlign.Left), true);
                                    uiDivider2.leftSection.Add((UIComponent) new UIText("               ", Color.Lime, UIAlign.Right), true);
                                    uiDivider2.leftSection.Add((UIComponent) new UIText("               ", Color.White, UIAlign.Left), true);
                                    uiDivider2.leftSection.Add((UIComponent) new UIText("               ", Color.White, UIAlign.Left), true);
                                    uiDivider2.leftSection.Add((UIComponent) new UIText("               ", Color.White, UIAlign.Left), true);
                                    uiDivider2.rightSection.Add((UIComponent) new UIImage((Sprite) new SpriteMap("challengeTrophy", 70, 65)
                                    {
                                        frame = 0
                                    }, UIAlign.Right), true);
                                    uiDivider1.leftSection.Add((UIComponent)uiDivider2, true);
                                    uiDivider1.rightSection.vertical     = false;
                                    uiDivider1.rightSection.borderSize.y = 2f;
                                    uiDivider1.rightSection.Add((UIComponent) new UIMenuItem("CONTINUE   ", (UIMenuAction) new UIMenuActionCloseMenuSetBoolean(this._trophyGroup, this._quit), UIAlign.Left), true);
                                    uiDivider1.rightSection.Add((UIComponent) new UIMenuItem("RETRY", (UIMenuAction) new UIMenuActionCloseMenuSetBoolean(this._trophyGroup, this._restart), UIAlign.Left), true);
                                    this._trophyMenu.Add((UIComponent)uiDivider1, true);
                                    this._trophyMenu.Close();
                                    this._trophyGroup.Add((UIComponent)this._trophyMenu, false);
                                    this._trophyGroup.Add((UIComponent)Options.optionsMenu, false);
                                    Options.openOnClose = this._trophyMenu;
                                    this._trophyGroup.Close();
                                    Level.Add((Thing)this._trophyGroup);
                                }
                            }
                            if ((double)this._showEndTextWait > 0.0)
                            {
                                this._showEndTextWait -= 0.01f;
                            }
                            else
                            {
                                this._fontFade = 1f;
                                if ((double)this._showResultsWait > 0.0)
                                {
                                    this._showResultsWait -= 0.01f;
                                }
                                else if (!this._showedEndMenu)
                                {
                                    this._trophyGroup.Open();
                                    this._trophyMenu.Open();
                                    MonoMain.pauseMenu = this._trophyGroup;
                                    SFX.Play("pause", 0.6f, -0.2f);
                                    this._showedEndMenu = true;
                                }
                                if (this._restart.value)
                                {
                                    this._restarting = true;
                                    SFX.Play("resume", 0.6f);
                                }
                                else
                                {
                                    if (!this._quit.value)
                                    {
                                        return;
                                    }
                                    this._fading = true;
                                    SFX.Play("resume", 0.6f);
                                }
                            }
                        }
                    }
                    else
                    {
                        this._waitSpawn -= 0.06f;
                        if ((double)this._waitSpawn > 0.0)
                        {
                            return;
                        }
                        if (this._pendingSpawns != null && this._pendingSpawns.Count > 0)
                        {
                            this._waitSpawn = 0.5f;
                            Duck pendingSpawn = this._pendingSpawns[0];
                            this.AddThing((Thing)pendingSpawn);
                            this._pendingSpawns.RemoveAt(0);
                            Vec3 color = pendingSpawn.profile.persona.color;
                            Level.Add((Thing) new SpawnLine(pendingSpawn.x, pendingSpawn.y, 0, 0.0f, new Color((int)color.x, (int)color.z, (int)color.z), 32f));
                            Level.Add((Thing) new SpawnLine(pendingSpawn.x, pendingSpawn.y, 0, -4f, new Color((int)color.x, (int)color.y, (int)color.z), 4f));
                            Level.Add((Thing) new SpawnLine(pendingSpawn.x, pendingSpawn.y, 0, 4f, new Color((int)color.x, (int)color.y, (int)color.z), 4f));
                            SFX.Play("pullPin", 0.7f);
                            ChallengeLevel._duck          = pendingSpawn;
                            this._challenge               = this.things[typeof(ChallengeMode)].First <Thing>() as ChallengeMode;
                            ChallengeLevel.random         = this._challenge.random.value;
                            this._challenge.duck          = pendingSpawn;
                            ChallengeLevel._timer.maxTime = TimeSpan.FromSeconds((double)this._challenge.challenge.trophies[0].timeRequirement);
                            HUD.AddCornerTimer(HUDCorner.BottomRight, "", (Timer)ChallengeLevel._timer);
                            if (this._challenge.challenge.countTargets)
                            {
                                int targets = this._challenge.challenge.trophies[0].targets;
                                HUD.AddCornerCounter(HUDCorner.BottomLeft, "@RETICULE@", new FieldBinding((object)this, "targetsShot"), targets > 0 ? targets : 0);
                            }
                            if (this._challenge.challenge.countGoodies)
                            {
                                MultiMap <System.Type, ISequenceItem> multiMap = new MultiMap <System.Type, ISequenceItem>();
                                foreach (ISequenceItem element in Level.current.things[typeof(ISequenceItem)])
                                {
                                    System.Type  type     = element.GetType();
                                    SequenceItem sequence = (element as Thing).sequence;
                                    if (sequence.isValid && sequence.type == SequenceItemType.Goody)
                                    {
                                        multiMap.Add(type, element);
                                    }
                                }
                                System.Type key = (System.Type)null;
                                int         num = 0;
                                foreach (KeyValuePair <System.Type, List <ISequenceItem> > keyValuePair in (MultiMap <System.Type, ISequenceItem, List <ISequenceItem> >)multiMap)
                                {
                                    if (keyValuePair.Value.Count > num)
                                    {
                                        key = keyValuePair.Key;
                                        num = keyValuePair.Value.Count;
                                    }
                                }
                                if (key != (System.Type)null)
                                {
                                    ISequenceItem sequenceItem = multiMap[key][0];
                                    string        text         = "@STARGOODY@";
                                    switch (sequenceItem)
                                    {
                                    case LapGoody _:
                                    case InvisiGoody _:
                                        text = "@LAPGOODY@";
                                        break;

                                    case SuitcaseGoody _:
                                        text = "@SUITCASEGOODY@";
                                        break;

                                    case Window _:
                                    case YellowBarrel _:
                                    case Door _:
                                        text = "@RETICULE@";
                                        break;
                                    }
                                    int goodies = this._challenge.challenge.trophies[0].goodies;
                                    HUD.AddCornerCounter(HUDCorner.BottomLeft, text, new FieldBinding((object)this, "goodiesGot"), goodies > 0 ? goodies : 0);
                                }
                            }
                            if (this._firstStart)
                            {
                                if (ChallengeLevel.random)
                                {
                                    IEnumerable <Thing> thing = this.things[typeof(ISequenceItem)];
                                    if (thing.Count <Thing>() > 0)
                                    {
                                        thing.ElementAt <Thing>(Rando.Int(thing.Count <Thing>() - 1)).sequence.BeginRandomSequence();
                                    }
                                }
                                else
                                {
                                    foreach (TargetDuck targetDuck in this.things[typeof(TargetDuck)])
                                    {
                                        if (targetDuck.sequence.order == 0)
                                        {
                                            targetDuck.sequence.Activate();
                                        }
                                    }
                                }
                                this._firstStart = false;
                            }
                            if (!Music.stopped)
                            {
                                return;
                            }
                            if ((string)this._challenge.music == "")
                            {
                                Music.Load("Challenging");
                            }
                            else if ((string)this._challenge.music == "donutmystery")
                            {
                                Music.Load("spacemystery");
                            }
                            else
                            {
                                Music.Load(Music.FindSong((string)this._challenge.music));
                            }
                        }
                        else if (!this._started)
                        {
                            this._waitAfterSpawn -= 0.06f;
                            if ((double)this._waitAfterSpawn > 0.0)
                            {
                                return;
                            }
                            ++this._waitAfterSpawnDings;
                            if (this._waitAfterSpawnDings > 2)
                            {
                                this._started          = true;
                                this.simulatePhysics   = true;
                                ChallengeLevel.running = true;
                                SFX.Play("ding");
                                ChallengeLevel._timer.Start();
                                if (Music.stopped)
                                {
                                    Music.PlayLoaded();
                                }
                            }
                            else
                            {
                                SFX.Play("preStartDing");
                            }
                            this._waitSpawn = 1.1f;
                        }
                        else
                        {
                            this._fontFade -= 0.1f;
                            if ((double)this._fontFade < 0.0)
                            {
                                this._fontFade = 0.0f;
                            }
                            this.PauseLogic();
                        }
                    }
                }
            }
        }
示例#9
0
 public override void Update()
 {
     if (this.owner == null)
     {
         this._walkFrames = 0;
         --this._framesInHand;
         if (this._framesInHand < -60)
         {
             this._bounceDuck = (Duck)null;
         }
         if (this._bounceDuck != null)
         {
             float length = (this._bounceDuck.position - this.position).length;
             if ((double)length < 16.0)
             {
                 this.hSpeed = this._bounceDuck.hSpeed;
             }
             if (this._bounceDuck.holdObject == null && (double)this.vSpeed < 1.0 && ((double)this._bounceDuck.top + 8.0 > (double)this.y && (double)length < 16.0))
             {
                 this._bounceDuck.GiveHoldable((Holdable)this);
                 this._framesInHand = 0;
             }
         }
     }
     else
     {
         if (this._framesInHand < 0)
         {
             this._framesInHand = 0;
         }
         if (!this.owner.action && (double)Math.Abs(this.owner.hSpeed) > 0.5 && this._framesInHand > 6)
         {
             this._bounceDuck = this.duck;
             float hSpeed = this.duck.hSpeed;
             this.duck.ThrowItem(false);
             this.vSpeed        = 2f;
             this.hSpeed        = hSpeed * 1.1f;
             this._framesInHand = 0;
         }
         else
         {
             if ((double)Math.Abs(this.owner.hSpeed) > 0.5 && this.duck.grounded)
             {
                 ++this._walkFrames;
             }
             else if (this.duck.grounded)
             {
                 --this._walkFrames;
             }
             if (this._walkFrames < 0)
             {
                 this._walkFrames = 0;
             }
             if (this._walkFrames > 20)
             {
                 SFX.Play("basketballWhistle");
                 this.duck.ThrowItem(false);
                 this._walkFrames = 0;
             }
             this._bounceDuck = (Duck)null;
             ++this._framesInHand;
         }
     }
     base.Update();
 }
示例#10
0
 public override void Update()
 {
     if (this.open)
     {
         if (this._doLobbySearch && this._lobbies.Count == 0)
         {
             this._lobbies.Clear();
             this._doLobbySearch = false;
             Steam.SearchForLobby((User)null);
         }
         if (!this._doLobbySearch && this._lobbies.Count == 0 && Steam.lobbySearchComplete)
         {
             int lobbiesFound          = Steam.lobbiesFound;
             List <WorkshopItem> items = new List <WorkshopItem>();
             for (int index = 0; index < lobbiesFound; ++index)
             {
                 Lobby searchLobbyAtIndex             = Steam.GetSearchLobbyAtIndex(index);
                 UIServerBrowser.LobbyData lobbyData1 = new UIServerBrowser.LobbyData();
                 lobbyData1.lobby = searchLobbyAtIndex;
                 string str1 = searchLobbyAtIndex.GetLobbyData("name");
                 if (str1 == null || str1 == "")
                 {
                     str1 = "DG Lobby";
                 }
                 lobbyData1.name         = str1;
                 lobbyData1.modHash      = searchLobbyAtIndex.GetLobbyData("modhash");
                 lobbyData1.requiredWins = searchLobbyAtIndex.GetLobbyData("requiredwins");
                 lobbyData1.restsEvery   = searchLobbyAtIndex.GetLobbyData("restsevery");
                 lobbyData1.wallMode     = searchLobbyAtIndex.GetLobbyData("wallmode");
                 lobbyData1.customLevels = searchLobbyAtIndex.GetLobbyData("customLevels");
                 lobbyData1.version      = searchLobbyAtIndex.GetLobbyData("version");
                 lobbyData1.started      = searchLobbyAtIndex.GetLobbyData("started");
                 lobbyData1.type         = searchLobbyAtIndex.GetLobbyData("type");
                 lobbyData1.numSlots     = searchLobbyAtIndex.GetLobbyData("numSlots");
                 string lobbyData2 = searchLobbyAtIndex.GetLobbyData("mods");
                 if (lobbyData2 != null && lobbyData2 != "")
                 {
                     string str2    = lobbyData2;
                     char[] chArray = new char[1] {
                         '|'
                     };
                     foreach (string str3 in str2.Split(chArray))
                     {
                         if (str3 == "LOCAL")
                         {
                             lobbyData1.hasLocalMods = true;
                         }
                         else
                         {
                             WorkshopItem workshopItem = WorkshopItem.GetItem(Convert.ToUInt64(str3));
                             items.Add(workshopItem);
                             lobbyData1.workshopItems.Add(workshopItem);
                         }
                     }
                 }
                 lobbyData1.maxPlayers = searchLobbyAtIndex.GetLobbyData("maxplayers");
                 this._lobbies.Add(lobbyData1);
             }
             if (items.Count > 0)
             {
                 Steam.RequestWorkshopInfo(items);
             }
             this._doLobbySearch = true;
         }
     }
     if (this._pressWait > 0)
     {
         --this._pressWait;
     }
     if (this._downloadModsMenu.open)
     {
         this._downloadModsMenu.DoUpdate();
         if (!UIMenu.globalUILock && (Input.Pressed("QUACK") || Keyboard.Pressed(Keys.Escape)))
         {
             this._downloadModsMenu.Close();
             this.Open();
             return;
         }
     }
     else if (this.open)
     {
         if (this._gamepadMode)
         {
             if (this._hoverIndex < 0)
             {
                 this._hoverIndex = 0;
             }
         }
         else
         {
             this._hoverIndex = -1;
             for (int index = 0; index < this._maxLobbiesToShow && this._scrollItemOffset + index < this._lobbies.Count; ++index)
             {
                 if (new Rectangle((float)(int)(this._box.x - this._box.halfWidth), (float)(int)(this._box.y - this._box.halfHeight + (float)(36 * index)), (float)((int)this._box.width - 14), 36f).Contains(Mouse.position))
                 {
                     this._hoverIndex = this._scrollItemOffset + index;
                     break;
                 }
             }
         }
         if (this._hoverIndex != -1)
         {
             if (Input.Pressed("SHOOT"))
             {
                 this.RefreshLobbySearch();
                 SFX.Play("rockHitGround", 0.8f);
             }
             if (this._lobbies.Count > 0)
             {
                 UIServerBrowser._selectedLobby = this._lobbies[this._hoverIndex];
                 if (Input.Pressed("SELECT") && this._pressWait == 0 && this._gamepadMode || !this._gamepadMode && Mouse.left == InputState.Pressed)
                 {
                     if (!UIServerBrowser._selectedLobby.canJoin)
                     {
                         SFX.Play("consoleError");
                     }
                     else
                     {
                         SFX.Play("consoleSelect");
                         if (UIServerBrowser._selectedLobby.workshopItems.Count == 0 || UIServerBrowser._selectedLobby.hasFirstMod && UIServerBrowser._selectedLobby.hasRestOfMods)
                         {
                             MonoMain.pauseMenu = (UIComponent)null;
                             MonoMain.closeMenuUpdate.Clear();
                             Level.current = (Level) new JoinServer(UIServerBrowser._selectedLobby.lobby.id);
                             return;
                         }
                         new UIMenuActionOpenMenu((UIComponent)this, (UIComponent)this._downloadModsMenu).Activate();
                     }
                 }
             }
         }
         else
         {
             UIServerBrowser._selectedLobby = (UIServerBrowser.LobbyData)null;
         }
         if (this._gamepadMode)
         {
             this._draggingScrollbar = false;
             if (Input.Pressed("DOWN"))
             {
                 ++this._hoverIndex;
             }
             else if (Input.Pressed("UP"))
             {
                 --this._hoverIndex;
             }
             if (Input.Pressed("STRAFE"))
             {
                 this._hoverIndex -= 10;
             }
             else if (Input.Pressed("RAGDOLL"))
             {
                 this._hoverIndex += 10;
             }
             if (this._hoverIndex < 0)
             {
                 this._hoverIndex = 0;
             }
             if ((double)(this._oldPos - Mouse.positionScreen).lengthSq > 200.0)
             {
                 this._gamepadMode = false;
             }
         }
         else
         {
             if (!this._draggingScrollbar)
             {
                 if (Mouse.left == InputState.Pressed && this.ScrollBarBox().Contains(Mouse.position))
                 {
                     this._draggingScrollbar = true;
                     this._oldPos            = Mouse.position;
                 }
                 if ((double)Mouse.scroll > 0.0)
                 {
                     this._scrollItemOffset += 5;
                     this._hoverIndex       += 5;
                 }
                 else if ((double)Mouse.scroll < 0.0)
                 {
                     this._scrollItemOffset -= 5;
                     this._hoverIndex       -= 5;
                     if (this._hoverIndex < 0)
                     {
                         this._hoverIndex = 0;
                     }
                 }
             }
             else if (Mouse.left != InputState.Down)
             {
                 this._draggingScrollbar = false;
             }
             else
             {
                 Vec2 vec2 = Mouse.position - this._oldPos;
                 this._oldPos          = Mouse.position;
                 this.scrollBarOffset += (int)vec2.y;
                 if (this.scrollBarOffset > this.scrollBarScrollableHeight)
                 {
                     this.scrollBarOffset = this.scrollBarScrollableHeight;
                 }
                 else if (this.scrollBarOffset < 0)
                 {
                     this.scrollBarOffset = 0;
                 }
                 this._scrollItemOffset = (int)((double)(this._lobbies.Count - this._maxLobbiesToShow) * (double)((float)this.scrollBarOffset / (float)this.scrollBarScrollableHeight));
             }
             if (Input.Pressed("ANY"))
             {
                 this._gamepadMode = true;
                 this._oldPos      = Mouse.positionScreen;
             }
         }
         if (this._scrollItemOffset < 0)
         {
             this._scrollItemOffset = 0;
         }
         else if (this._scrollItemOffset > Math.Max(0, this._lobbies.Count - this._maxLobbiesToShow))
         {
             this._scrollItemOffset = Math.Max(0, this._lobbies.Count - this._maxLobbiesToShow);
         }
         if (this._hoverIndex >= this._lobbies.Count)
         {
             this._hoverIndex = this._lobbies.Count - 1;
         }
         else if (this._hoverIndex >= this._scrollItemOffset + this._maxLobbiesToShow)
         {
             this._scrollItemOffset += this._hoverIndex - (this._scrollItemOffset + this._maxLobbiesToShow) + 1;
         }
         else if (this._hoverIndex >= 0 && this._hoverIndex < this._scrollItemOffset)
         {
             this._scrollItemOffset -= this._scrollItemOffset - this._hoverIndex;
         }
         this.scrollBarOffset = this._scrollItemOffset == 0 ? 0 : (int)Lerp.FloatSmooth(0.0f, (float)this.scrollBarScrollableHeight, (float)this._scrollItemOffset / (float)(this._lobbies.Count - this._maxLobbiesToShow));
         if (!Editor.hoverTextBox && !UIMenu.globalUILock && (Input.Pressed("QUACK") || Keyboard.Pressed(Keys.Escape)))
         {
             new UIMenuActionOpenMenu((UIComponent)this, (UIComponent)this._openOnClose).Activate();
             return;
         }
     }
     if (this._showingMenu)
     {
         HUD.CloseAllCorners();
         this._showingMenu = false;
     }
     base.Update();
 }
示例#11
0
 public override void Update()
 {
     if (this._pressWait > 0)
     {
         --this._pressWait;
     }
     if (this._editModMenu.open)
     {
         if (!UIMenu.globalUILock && (Input.Pressed("QUACK") || Keyboard.Pressed(Keys.Escape)))
         {
             this._editModMenu.Close();
             this.Open();
             return;
         }
     }
     else if (this.open)
     {
         if (this._transferItem != null && !this._needsUpdateNotes)
         {
             if (!this._transferring)
             {
                 if (this._transferItem.result == SteamResult.OK)
                 {
                     WorkshopItemData dat = new WorkshopItemData();
                     if (this._selectedMod.configuration.workshopID == 0UL)
                     {
                         this._selectedMod.configuration.SetWorkshopID(this._transferItem.id);
                         dat.name        = this._selectedMod.configuration.displayName;
                         dat.description = this._selectedMod.configuration.description;
                         dat.visibility  = RemoteStoragePublishedFileVisibility.Private;
                         dat.tags        = new List <string>();
                         dat.tags.Add("Mod");
                     }
                     else
                     {
                         dat.changeNotes = this._updateTextBox.text;
                     }
                     string pathString = this._selectedMod.configuration.directory + "/content/";
                     DuckFile.CreatePath(pathString);
                     string path1 = pathString + "screenshot.png";
                     if (!File.Exists(path1))
                     {
                         File.Delete(path1);
                         Tex2D  screenshot = this._selectedMod.screenshot;
                         Stream stream     = (Stream)DuckFile.Create(path1);
                         ((Texture2D)screenshot.nativeObject).SaveAsPng(stream, screenshot.width, screenshot.height);
                         stream.Dispose();
                     }
                     dat.previewPath = path1;
                     string str = DuckFile.workshopDirectory + (object)this._transferItem.id + "/content";
                     if (Directory.Exists(str))
                     {
                         Directory.Delete(str, true);
                     }
                     DuckFile.CreatePath(str);
                     UIModManagement.DirectoryCopy(this._selectedMod.configuration.directory, str + "/" + this._selectedMod.configuration.name, true);
                     if (Directory.Exists(str + this._selectedMod.configuration.name + "/build"))
                     {
                         Directory.Delete(str + this._selectedMod.configuration.name + "/build", true);
                     }
                     if (Directory.Exists(str + this._selectedMod.configuration.name + "/.vs"))
                     {
                         Directory.Delete(str + this._selectedMod.configuration.name + "/.vs", true);
                     }
                     if (File.Exists(str + this._selectedMod.configuration.name + "/" + this._selectedMod.configuration.name + "_compiled.dll"))
                     {
                         string path2 = str + this._selectedMod.configuration.name + "/" + this._selectedMod.configuration.name + "_compiled.dll";
                         File.SetAttributes(path2, FileAttributes.Normal);
                         File.Delete(path2);
                     }
                     if (File.Exists(str + this._selectedMod.configuration.name + "/" + this._selectedMod.configuration.name + "_compiled.hash"))
                     {
                         string path2 = str + this._selectedMod.configuration.name + "/" + this._selectedMod.configuration.name + "_compiled.hash";
                         File.SetAttributes(path2, FileAttributes.Normal);
                         File.Delete(path2);
                     }
                     dat.contentFolder = str;
                     this._transferItem.ApplyWorkshopData(dat);
                     if (this._transferItem.needsLegal)
                     {
                         Steam.ShowWorkshopLegalAgreement("312530");
                     }
                     this._transferring = true;
                     this._transferItem.ResetProcessing();
                 }
             }
             else if (this._transferItem.finishedProcessing)
             {
                 Steam.OverlayOpenURL("http://steamcommunity.com/sharedfiles/filedetails/?id=" + (object)this._transferItem.id);
                 Directory.Delete(DuckFile.workshopDirectory + (object)this._transferItem.id + "/", true);
                 this._transferItem.ResetProcessing();
                 this._transferItem = (WorkshopItem)null;
                 this._transferring = false;
             }
             base.Update();
             return;
         }
         if (this._gamepadMode)
         {
             if (this._hoverIndex < 0)
             {
                 this._hoverIndex = 0;
             }
         }
         else
         {
             this._hoverIndex = -1;
             for (int index = 0; index < this._maxModsToShow && this._scrollItemOffset + index < this._mods.Count; ++index)
             {
                 if (new Rectangle((float)(int)(this._box.x - this._box.halfWidth), (float)(int)(this._box.y - this._box.halfHeight + (float)(36 * index)), (float)((int)this._box.width - 14), 36f).Contains(Mouse.position))
                 {
                     this._hoverIndex = this._scrollItemOffset + index;
                     break;
                 }
             }
         }
         if (this._transferItem != null)
         {
             if (this._updateTextBox != null)
             {
                 Editor.hoverTextBox           = false;
                 this._updateTextBox.position  = new Vec2((float)((double)this._box.x - (double)this._box.halfWidth + 16.0), (float)((double)this._box.y - (double)this._box.halfHeight + 48.0));
                 this._updateTextBox.size      = new Vec2(this._box.width - 32f, this._box.height - 80f);
                 this._updateTextBox._maxLines = (int)((double)this._updateTextBox.size.y / (double)this._fancyFont.characterHeight);
                 this._updateTextBox.Update();
                 float stringWidth = DuckGame.Graphics.GetStringWidth(this._updateButtonText, scale: 2f);
                 float height      = DuckGame.Graphics.GetStringHeight(this._updateButtonText) * 2f;
                 this._updateButton = new Rectangle(this._box.x - stringWidth / 2f, (float)((double)this._box.y + (double)this._box.halfHeight - 24.0), stringWidth, height);
                 if (this._updateButton.Contains(Mouse.position) && Mouse.left == InputState.Pressed)
                 {
                     this._needsUpdateNotes = false;
                     this._updateTextBox.LoseFocus();
                 }
                 else if (Keyboard.Pressed(Keys.Escape))
                 {
                     this._needsUpdateNotes = false;
                     this._transferItem     = (WorkshopItem)null;
                     this._updateTextBox.LoseFocus();
                     new UIMenuActionOpenMenu((UIComponent)this, (UIComponent)this._editModMenu).Activate();
                     return;
                 }
             }
         }
         else if (this._hoverIndex != -1)
         {
             this._selectedMod = this._mods[this._hoverIndex];
             if (Input.Pressed("SHOOT"))
             {
                 if (this._selectedMod != null && this._selectedMod.configuration != null)
                 {
                     if (this._selectedMod.configuration.disabled)
                     {
                         this._selectedMod.configuration.Enable();
                     }
                     else
                     {
                         this._selectedMod.configuration.Disable();
                     }
                     this.modsChanged = true;
                     SFX.Play("rockHitGround", 0.8f);
                 }
             }
             else if (Input.Pressed("SELECT") && this._pressWait == 0 && this._gamepadMode || !this._gamepadMode && Mouse.left == InputState.Pressed)
             {
                 if (this._selectedMod != null)
                 {
                     this._editModMenu.title = this._selectedMod.configuration.loaded ? "|YELLOW|" + this._selectedMod.configuration.displayName : "|YELLOW|" + this._selectedMod.configuration.name;
                     this._editModMenu.Remove((UIComponent)this._deleteOrUnsubItem);
                     this._editModMenu.Remove((UIComponent)this._uploadItem);
                     this._editModMenu.Remove((UIComponent)this._visitItem);
                     if (!this._selectedMod.configuration.isWorkshop && this._selectedMod.configuration.loaded)
                     {
                         this._uploadItem.text = this._selectedMod.configuration.workshopID == 0UL ? "UPLOAD" : "UPDATE";
                         this._editModMenu.Insert((UIComponent)this._uploadItem, 1, true);
                     }
                     if (!this._selectedMod.configuration.isWorkshop && !this._selectedMod.configuration.loaded)
                     {
                         this._deleteOrUnsubItem.text = "DELETE";
                         this._editModMenu.Insert((UIComponent)this._deleteOrUnsubItem, 1, true);
                     }
                     else if (this._selectedMod.configuration.isWorkshop)
                     {
                         this._deleteOrUnsubItem.text = "UNSUBSCRIBE";
                         this._editModMenu.Insert((UIComponent)this._deleteOrUnsubItem, 1, true);
                     }
                     if (this._selectedMod.configuration.isWorkshop)
                     {
                         this._editModMenu.Insert((UIComponent)this._visitItem, 1, true);
                     }
                     this._disableOrEnableItem.text = this._selectedMod.configuration.disabled ? "ENABLE" : "DISABLE";
                     this._editModMenu.dirty        = true;
                     SFX.Play("rockHitGround", 0.8f);
                     new UIMenuActionOpenMenu((UIComponent)this, (UIComponent)this._editModMenu).Activate();
                     return;
                 }
                 Steam.OverlayOpenURL("http://steamcommunity.com/workshop/browse/?appid=312530&searchtext=&childpublishedfileid=0&browsesort=trend&section=readytouseitems&requiredtags%5B%5D=Mod");
             }
         }
         else
         {
             this._selectedMod = (Mod)null;
         }
         if (this._gamepadMode)
         {
             this._draggingScrollbar = false;
             if (Input.Pressed("DOWN"))
             {
                 ++this._hoverIndex;
             }
             else if (Input.Pressed("UP"))
             {
                 --this._hoverIndex;
             }
             if (Input.Pressed("STRAFE"))
             {
                 this._hoverIndex -= 10;
             }
             else if (Input.Pressed("RAGDOLL"))
             {
                 this._hoverIndex += 10;
             }
             if (this._hoverIndex < 0)
             {
                 this._hoverIndex = 0;
             }
             if ((double)(this._oldPos - Mouse.positionScreen).lengthSq > 200.0)
             {
                 this._gamepadMode = false;
             }
         }
         else
         {
             if (!this._draggingScrollbar)
             {
                 if (Mouse.left == InputState.Pressed && this.ScrollBarBox().Contains(Mouse.position))
                 {
                     this._draggingScrollbar = true;
                     this._oldPos            = Mouse.position;
                 }
                 if ((double)Mouse.scroll > 0.0)
                 {
                     this._scrollItemOffset += 5;
                     this._hoverIndex       += 5;
                 }
                 else if ((double)Mouse.scroll < 0.0)
                 {
                     this._scrollItemOffset -= 5;
                     this._hoverIndex       -= 5;
                     if (this._hoverIndex < 0)
                     {
                         this._hoverIndex = 0;
                     }
                 }
             }
             else if (Mouse.left != InputState.Down)
             {
                 this._draggingScrollbar = false;
             }
             else
             {
                 Vec2 vec2 = Mouse.position - this._oldPos;
                 this._oldPos          = Mouse.position;
                 this.scrollBarOffset += (int)vec2.y;
                 if (this.scrollBarOffset > this.scrollBarScrollableHeight)
                 {
                     this.scrollBarOffset = this.scrollBarScrollableHeight;
                 }
                 else if (this.scrollBarOffset < 0)
                 {
                     this.scrollBarOffset = 0;
                 }
                 this._scrollItemOffset = (int)((double)(this._mods.Count - this._maxModsToShow) * (double)((float)this.scrollBarOffset / (float)this.scrollBarScrollableHeight));
             }
             if (Input.Pressed("ANY"))
             {
                 this._gamepadMode = true;
                 this._oldPos      = Mouse.positionScreen;
             }
         }
         if (this._scrollItemOffset < 0)
         {
             this._scrollItemOffset = 0;
         }
         else if (this._scrollItemOffset > Math.Max(0, this._mods.Count - this._maxModsToShow))
         {
             this._scrollItemOffset = Math.Max(0, this._mods.Count - this._maxModsToShow);
         }
         if (this._hoverIndex >= this._mods.Count)
         {
             this._hoverIndex = this._mods.Count - 1;
         }
         else if (this._hoverIndex >= this._scrollItemOffset + this._maxModsToShow)
         {
             this._scrollItemOffset += this._hoverIndex - (this._scrollItemOffset + this._maxModsToShow) + 1;
         }
         else if (this._hoverIndex >= 0 && this._hoverIndex < this._scrollItemOffset)
         {
             this._scrollItemOffset -= this._scrollItemOffset - this._hoverIndex;
         }
         this.scrollBarOffset = this._scrollItemOffset == 0 ? 0 : (int)Lerp.FloatSmooth(0.0f, (float)this.scrollBarScrollableHeight, (float)this._scrollItemOffset / (float)(this._mods.Count - this._maxModsToShow));
         if (!Editor.hoverTextBox && !UIMenu.globalUILock && (Input.Pressed("QUACK") || Keyboard.Pressed(Keys.Escape)))
         {
             if (this.modsChanged)
             {
                 this.Close();
                 MonoMain.pauseMenu = DuckNetwork.OpenModsRestartWindow(this._openOnClose);
             }
             else
             {
                 new UIMenuActionOpenMenu((UIComponent)this, (UIComponent)this._openOnClose).Activate();
             }
             this.modsChanged = false;
             return;
         }
     }
     if (this._showingMenu)
     {
         HUD.CloseAllCorners();
         this._showingMenu = false;
     }
     base.Update();
 }
示例#12
0
        // Token: 0x0600230C RID: 8972
        public override void Update()
        {
            base.Update();
            float num = 1f;

            if (this.souped)
            {
                num = 1.3f;
            }
            if (this._swordSwing.finished)
            {
                this._swordSwing.speed = 0f;
            }
            if (this._hitWait > 0)
            {
                this._hitWait--;
            }
            if (this._gas < 0.01f)
            {
                this.ammo = 0;
            }
            this._framesExisting++;
            if (this._framesExisting > 100)
            {
                this._framesExisting = 100;
            }
            float pitch = this.souped ? 0.3f : 0f;

            this._sound.lerpVolume = ((this._started && !this._throttle) ? 0.6f : 0f);
            this._sound.pitch      = pitch;
            if (this._started)
            {
                this._warmUp += 0.001f;
                if (this._warmUp > 1f)
                {
                    this._warmUp = 1f;
                }
                if (!this._puffClick && this._idleWave > 0.9f)
                {
                    this._skipSmoke = !this._skipSmoke;
                    if (this._throttle || !this._skipSmoke)
                    {
                        Level.Add(SmallSmoke.New(base.x + (float)(this.offDir * 4), base.y + 5f, this._smokeFlipper ? -0.1f : 0.8f, 0.7f));
                        this._smokeFlipper = !this._smokeFlipper;
                        this._puffClick    = true;
                    }
                }
                else if (this._puffClick && this._idleWave < 0f)
                {
                    this._puffClick = false;
                }
                if (this._pullState < 0)
                {
                    float num2 = 1f + Maths.NormalizeSection(this._engineSpin, 1f, 2f) * 2f;
                    float num3 = this._idleWave;
                    if (num2 > 1f)
                    {
                        num3 = this._spinWave;
                    }
                    this.handOffset  = Lerp.Vec2Smooth(this.handOffset, new Vec2(0f, 2f + num3 * num2), 0.23f);
                    this._holdOffset = Lerp.Vec2Smooth(this._holdOffset, new Vec2(1f, 2f + num3 * num2), 0.23f);
                    float num4 = Maths.NormalizeSection(this._engineSpin, 1f, 2f) * 3f;
                    this._rotSway = this._idleWave.normalized * num4 * 0.03f;
                }
                else
                {
                    this._rotSway = 0f;
                }
                this._gas -= 3E-05f;
                if (this._throttle)
                {
                    this._gas -= 0.0002f;
                }
                if (this._gas < 0f)
                {
                    this._gas      = 0f;
                    this._started  = false;
                    this._throttle = false;
                }
                if (this._triggerHeld)
                {
                    if (this._releasedSincePull)
                    {
                        if (!this._throttle)
                        {
                            this._throttle = true;
                            SFX.Play("chainsawBladeRevUp", 0.5f, pitch, 0f, false);
                        }
                        this._engineSpin = Lerp.FloatSmooth(this._engineSpin, 4f, 0.1f, 1f);
                    }
                }
                else
                {
                    if (this._throttle)
                    {
                        this._throttle = false;
                        if (this._engineSpin > 1.7f)
                        {
                            SFX.Play("chainsawBladeRevDown", 0.5f, pitch, 0f, false);
                        }
                    }
                    this._engineSpin        = Lerp.FloatSmooth(this._engineSpin, 0f, 0.1f, 1f);
                    this._releasedSincePull = true;
                }
            }
            else
            {
                this._warmUp -= 0.001f;
                if (this._warmUp < 0f)
                {
                    this._warmUp = 0f;
                }
                this._releasedSincePull = false;
                this._throttle          = false;
            }
            this._bladeSound.lerpSpeed  = 0.1f;
            this._throttleWait          = Lerp.Float(this._throttleWait, this._throttle ? 1f : 0f, 0.07f);
            this._bladeSound.lerpVolume = ((this._throttleWait > 0.96f) ? 0.6f : 0f);
            if (this._struggling)
            {
                this._bladeSound.lerpVolume = 0f;
            }
            this._bladeSoundLow.lerpVolume = ((this._throttleWait > 0.96f && this._struggling) ? 0.6f : 0f);
            this._bladeSound.pitch         = pitch;
            this._bladeSoundLow.pitch      = pitch;
            if (this.owner == null)
            {
                this.collisionOffset = new Vec2(-8f, -6f);
                this.collisionSize   = new Vec2(13f, 11f);
            }
            else if (base.duck != null && (base.duck.sliding || base.duck.crouch))
            {
                this.collisionOffset = new Vec2(-8f, -6f);
                this.collisionSize   = new Vec2(6f, 11f);
            }
            else
            {
                this.collisionOffset = new Vec2(-8f, -6f);
                this.collisionSize   = new Vec2(10f, 11f);
            }
            if (this.owner != null)
            {
                this._resetDuck = false;
                if (this._pullState == -1)
                {
                    if (!this._started)
                    {
                        this.handOffset  = Lerp.Vec2Smooth(this.handOffset, new Vec2(0f, 2f), 0.25f);
                        this._holdOffset = Lerp.Vec2Smooth(this._holdOffset, new Vec2(1f, 2f), 0.23f);
                    }
                    this._upWait = 0f;
                }
                else if (this._pullState == 0)
                {
                    this._animRot    = Lerp.FloatSmooth(this._animRot, -0.4f, 0.15f, 1f);
                    this.handOffset  = Lerp.Vec2Smooth(this.handOffset, new Vec2(-2f, -2f), 0.25f);
                    this._holdOffset = Lerp.Vec2Smooth(this._holdOffset, new Vec2(-4f, 4f), 0.23f);
                    if (this._animRot <= -0.35f)
                    {
                        this._animRot   = -0.4f;
                        this._pullState = 1;
                        this.PullEngine();
                    }
                    this._upWait = 0f;
                }
                else if (this._pullState == 1)
                {
                    this._releasePull = false;
                    this._holdOffset  = Lerp.Vec2Smooth(this._holdOffset, new Vec2(2f, 3f), 0.23f);
                    this.handOffset   = Lerp.Vec2Smooth(this.handOffset, new Vec2(-4f, -2f), 0.23f);
                    this._animRot     = Lerp.FloatSmooth(this._animRot, -0.5f, 0.07f, 1f);
                    if (this._animRot < -0.45f)
                    {
                        this._animRot   = -0.5f;
                        this._pullState = 2;
                    }
                    this._upWait = 0f;
                }
                else if (this._pullState == 2)
                {
                    if (this._releasePull || !this._triggerHeld)
                    {
                        this._releasePull = true;
                        if (this._started)
                        {
                            this.handOffset  = Lerp.Vec2Smooth(this.handOffset, new Vec2(0f, 2f + this._idleWave.normalized), 0.23f);
                            this._holdOffset = Lerp.Vec2Smooth(this._holdOffset, new Vec2(1f, 2f + this._idleWave.normalized), 0.23f);
                            this._animRot    = Lerp.FloatSmooth(this._animRot, 0f, 0.1f, 1f);
                            if (this._animRot > -0.07f)
                            {
                                this._animRot   = 0f;
                                this._pullState = -1;
                            }
                        }
                        else
                        {
                            this._holdOffset = Lerp.Vec2Smooth(this._holdOffset, new Vec2(-4f, 4f), 0.24f);
                            this.handOffset  = Lerp.Vec2Smooth(this.handOffset, new Vec2(-2f, -2f), 0.24f);
                            this._animRot    = Lerp.FloatSmooth(this._animRot, -0.4f, 0.12f, 1f);
                            if (this._animRot > -0.44f)
                            {
                                this._releasePull = false;
                                this._animRot     = -0.4f;
                                this._pullState   = 3;
                                this._holdOffset  = new Vec2(-4f, 4f);
                                this.handOffset   = new Vec2(-2f, -2f);
                            }
                        }
                    }
                    this._upWait = 0f;
                }
                else if (this._pullState == 3)
                {
                    this._releasePull = false;
                    this._upWait     += 0.1f;
                    if (this._upWait > 6f)
                    {
                        this._pullState = -1;
                    }
                }
                this._bladeSpin += this._engineSpin;
                while (this._bladeSpin >= 1f)
                {
                    this._bladeSpin -= 1f;
                    int num5 = this._sprite.frame + 1;
                    if (num5 > 15)
                    {
                        num5 = 0;
                    }
                    this._sprite.frame = num5;
                }
                this._engineSpin        = Lerp.FloatSmooth(this._engineSpin, 0f, 0.1f, 1f);
                this._engineResistance  = Lerp.FloatSmooth(this._engineResistance, 1f, 0.01f, 1f);
                this._hold              = -0.4f;
                this.center             = new Vec2(8f, 7f);
                this._framesSinceThrown = 0;
            }
            else
            {
                this._rotSway = 0f;
                this._shing   = false;
                this._animRot = Lerp.FloatSmooth(this._animRot, 0f, 0.18f, 1f);
                if (this._framesSinceThrown == 1)
                {
                    this._throwSpin = base.angleDegrees;
                }
                this._hold        = 0f;
                base.angleDegrees = this._throwSpin;
                this.center       = new Vec2(8f, 7f);
                bool flag  = false;
                bool flag2 = false;
                if ((Math.Abs(this.hSpeed) + Math.Abs(this.vSpeed) > 2f || !base.grounded) && this.gravMultiplier > 0f)
                {
                    if (!base.grounded && Level.CheckRect <Block>(this.position + new Vec2(-8f, -6f), this.position + new Vec2(8f, -2f), null) != null)
                    {
                        flag2 = true;
                    }
                    if (!flag2 && !this._grounded && Level.CheckPoint <IPlatform>(this.position + new Vec2(0f, 8f), null, null) == null)
                    {
                        if (this.offDir > 0)
                        {
                            this._throwSpin += (Math.Abs(this.hSpeed) + Math.Abs(this.vSpeed)) * 1f + 5f;
                        }
                        else
                        {
                            this._throwSpin -= (Math.Abs(this.hSpeed) + Math.Abs(this.vSpeed)) * 1f + 5f;
                        }
                        flag = true;
                    }
                }
                if (!flag || flag2)
                {
                    this._throwSpin %= 360f;
                    if (this._throwSpin < 0f)
                    {
                        this._throwSpin += 360f;
                    }
                    if (flag2)
                    {
                        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 (Math.Abs(this._angle) > 1f)
            {
                this._flood += 0.005f;
                if (this._flood > 1f)
                {
                    this._flooded = true;
                    this._started = false;
                }
                this._gasDripFrames++;
                if (this._gas > 0f && this._flooded && this._gasDripFrames > 2)
                {
                    FluidData gas = Fluid.Gas;
                    gas.amount = 0.003f;
                    this._gas -= 0.005f;
                    if (this._gas < 0f)
                    {
                        this._gas = 0f;
                    }
                    Level.Add(new Fluid(base.x, base.y, Vec2.Zero, gas, null, 1f));
                    this._gasDripFrames = 0;
                }
                if (this._gas <= 0f)
                {
                    this._started = false;
                }
            }
            else
            {
                this._flood -= 0.008f;
                if (this._flood < 0f)
                {
                    this._flood = 0f;
                }
            }
            if (base.duck != null)
            {
                base.duck.frictionMult = 1f;
                if (this._skipSpark > 0)
                {
                    this._skipSpark++;
                    if (this._skipSpark > 2)
                    {
                        this._skipSpark = 0;
                    }
                }
                if (base.duck.sliding && this._throttle && this._skipSpark == 0)
                {
                    if (Level.CheckLine <Block>(this.barrelStartPos + new Vec2(0f, 8f), base.barrelPosition + new Vec2(0f, 8f), null) != null)
                    {
                        this._skipSpark = 1;
                        Vec2 value = this.position + base.barrelVector * 5f;
                        for (int i = 0; i < 2; i++)
                        {
                            Level.Add(Spark.New(value.x, value.y, new Vec2((float)this.offDir * Rando.Float(0f, 2f), Rando.Float(0.5f, 1.5f)), 0.02f));
                            value += base.barrelVector * 2f;
                            this._fireTrailWait -= 0.5f;
                            if (this.souped && this._fireTrailWait <= 0f)
                            {
                                this._fireTrailWait = 1f;
                                SmallFire smallFire = SmallFire.New(value.x, value.y, (float)this.offDir * Rando.Float(0f, 2f), Rando.Float(0.5f, 1.5f), false, null, true, null, false);
                                smallFire.waitToHurt = Rando.Float(1f, 2f);
                                smallFire.whoWait    = (this.owner as Duck);
                                Level.Add(smallFire);
                            }
                        }
                        if (this.offDir > 0 && this.owner.hSpeed < (float)(this.offDir * 6) * num)
                        {
                            this.owner.hSpeed = (float)(this.offDir * 6) * num;
                        }
                        else if (this.offDir < 0 && this.owner.hSpeed > (float)(this.offDir * 6) * num)
                        {
                            this.owner.hSpeed = (float)(this.offDir * 6) * num;
                        }
                    }
                    else if (this.offDir > 0 && this.owner.hSpeed < (float)(this.offDir * 3) * num)
                    {
                        this.owner.hSpeed = (float)(this.offDir * 3) * num;
                    }
                    else if (this.offDir < 0 && this.owner.hSpeed > (float)(this.offDir * 3) * num)
                    {
                        this.owner.hSpeed = (float)(this.offDir * 3) * num;
                    }
                }
                if (this._pullState == -1)
                {
                    if (!this._throttle)
                    {
                        this._animRot    = MathHelper.Lerp(this._animRot, 0.3f, 0.2f);
                        this.handOffset  = Lerp.Vec2Smooth(this.handOffset, new Vec2(-2f, 2f), 0.25f);
                        this._holdOffset = Lerp.Vec2Smooth(this._holdOffset, new Vec2(-3f, 4f), 0.23f);
                    }
                    else if (this._shing)
                    {
                        this._animRot    = MathHelper.Lerp(this._animRot, -1.8f, 0.4f);
                        this.handOffset  = Lerp.Vec2Smooth(this.handOffset, new Vec2(1f, 0f), 0.25f);
                        this._holdOffset = Lerp.Vec2Smooth(this._holdOffset, new Vec2(1f, 2f), 0.23f);
                        if (this._animRot < -1.5f)
                        {
                            this._shing = false;
                        }
                    }
                    else if (base.duck.crouch)
                    {
                        this._animRot    = MathHelper.Lerp(this._animRot, 0.4f, 0.2f);
                        this.handOffset  = Lerp.Vec2Smooth(this.handOffset, new Vec2(1f, 0f), 0.25f);
                        this._holdOffset = Lerp.Vec2Smooth(this._holdOffset, new Vec2(1f, 2f), 0.23f);
                    }
                    else if (base.duck.inputProfile.Down("UP"))
                    {
                        this._animRot    = MathHelper.Lerp(this._animRot, -0.9f, 0.2f);
                        this.handOffset  = Lerp.Vec2Smooth(this.handOffset, new Vec2(1f, 0f), 0.25f);
                        this._holdOffset = Lerp.Vec2Smooth(this._holdOffset, new Vec2(1f, 2f), 0.23f);
                    }
                    else
                    {
                        this._animRot    = MathHelper.Lerp(this._animRot, 0f, 0.2f);
                        this.handOffset  = Lerp.Vec2Smooth(this.handOffset, new Vec2(1f, 0f), 0.25f);
                        this._holdOffset = Lerp.Vec2Smooth(this._holdOffset, new Vec2(1f, 2f), 0.23f);
                    }
                }
            }
            else if (!this._resetDuck && base.prevOwner != null)
            {
                PhysicsObject physicsObject = base.prevOwner as PhysicsObject;
                if (physicsObject != null)
                {
                    physicsObject.frictionMult = 1f;
                }
                this._resetDuck = true;
            }
            if (this._skipDebris > 0)
            {
                this._skipDebris++;
            }
            if (this._skipDebris > 3)
            {
                this._skipDebris = 0;
            }
            this._struggling = false;
            if (this.owner != null && this._started && this._throttle && !this._shing)
            {
                (this.Offset(base.barrelOffset) - this.position).Normalize();
                this.Offset(base.barrelOffset);
                IEnumerable <IAmADuck> enumerable = Level.CheckLineAll <IAmADuck>(this.barrelStartPos, base.barrelPosition);
                Block block3 = Level.CheckLine <Block>(this.barrelStartPos, base.barrelPosition, null);
                if (this.owner != null)
                {
                    foreach (MaterialThing materialThing in Level.CheckLineAll <MaterialThing>(this.barrelStartPos, base.barrelPosition))
                    {
                        if (materialThing.Hurt((materialThing is Door) ? 1.8f : 0.5f))
                        {
                            if (base.duck != null && base.duck.sliding && materialThing is Door && (materialThing as Door)._jammed)
                            {
                                materialThing.Destroy(new DTImpale(this));
                            }
                            else
                            {
                                this._struggling = true;
                                if (base.duck != null)
                                {
                                    base.duck.frictionMult = 4f;
                                }
                                if (this._skipDebris == 0)
                                {
                                    this._skipDebris = 1;
                                    Vec2 value2 = Collision.LinePoint(this.barrelStartPos, base.barrelPosition, materialThing.rectangle);
                                    if (value2 != Vec2.Zero)
                                    {
                                        value2 += base.barrelVector * Rando.Float(0f, 3f);
                                        Vec2 vec = -base.barrelVector.Rotate(Rando.Float(-0.2f, 0.2f), Vec2.Zero);
                                        if (materialThing.physicsMaterial == PhysicsMaterial.Wood)
                                        {
                                            WoodDebris woodDebris = WoodDebris.New(value2.x, value2.y);
                                            woodDebris.hSpeed = vec.x * 3f;
                                            woodDebris.vSpeed = vec.y * 3f;
                                            Level.Add(woodDebris);
                                        }
                                        else if (materialThing.physicsMaterial == PhysicsMaterial.Metal)
                                        {
                                            Spark spark = Spark.New(value2.x, value2.y, Vec2.Zero, 0.02f);
                                            spark.hSpeed = vec.x * 3f;
                                            spark.vSpeed = vec.y * 3f;
                                            Level.Add(spark);
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
                bool flag3 = false;
                if (block3 != null && !(block3 is Door))
                {
                    this.Shing(block3);
                    if (block3 is Window)
                    {
                        block3.Destroy(new DTImpact(this));
                    }
                }
                else
                {
                    foreach (Thing thing in Level.current.things[typeof(Sword)])
                    {
                        Sword sword = (Sword)thing;
                        if (sword.owner != null && sword.crouchStance && !sword.jabStance && Collision.LineIntersect(this.barrelStartPos, base.barrelPosition, sword.barrelStartPos, sword.barrelPosition))
                        {
                            this.Shing(sword);
                            sword.Shing();
                            sword.owner.hSpeed     += (float)this.offDir * 3f;
                            sword.owner.vSpeed     -= 2f;
                            base.duck.hSpeed       += -(float)this.offDir * 3f;
                            base.duck.vSpeed       -= 2f;
                            sword.duck.crippleTimer = 1f;
                            base.duck.crippleTimer  = 1f;
                            flag3 = true;
                        }
                    }
                    if (!flag3)
                    {
                        Thing ignore = null;
                        if (base.duck != null)
                        {
                            ignore = base.duck.GetEquipment(typeof(Helmet));
                        }
                        QuadLaserBullet quadLaserBullet = Level.CheckLine <QuadLaserBullet>(this.position, base.barrelPosition, null);
                        if (quadLaserBullet != null)
                        {
                            this.Shing(quadLaserBullet);
                            Vec2  travel = quadLaserBullet.travel;
                            float length = travel.length;
                            float num6   = 1f;
                            if (this.offDir > 0 && travel.x < 0f)
                            {
                                num6 = 1.5f;
                            }
                            else if (this.offDir < 0 && travel.x > 0f)
                            {
                                num6 = 1.5f;
                            }
                            if (this.offDir > 0)
                            {
                                travel = new Vec2(length * num6, 0f);
                            }
                            else
                            {
                                travel = new Vec2(-length * num6, 0f);
                            }
                            quadLaserBullet.travel = travel;
                        }
                        else
                        {
                            Helmet helmet = Level.CheckLine <Helmet>(this.barrelStartPos, base.barrelPosition, ignore);
                            if (helmet != null && helmet.equippedDuck != null)
                            {
                                this.Shing(helmet);
                                helmet.owner.hSpeed     += (float)this.offDir * 3f;
                                helmet.owner.vSpeed     -= 2f;
                                helmet.duck.crippleTimer = 1f;
                                helmet.Hurt(0.53f);
                                flag3 = true;
                            }
                            else
                            {
                                if (base.duck != null)
                                {
                                    ignore = base.duck.GetEquipment(typeof(ChestPlate));
                                }
                                ChestPlate chestPlate = Level.CheckLine <ChestPlate>(this.barrelStartPos, base.barrelPosition, ignore);
                                if (chestPlate != null && chestPlate.equippedDuck != null)
                                {
                                    this.Shing(chestPlate);
                                    chestPlate.owner.hSpeed     += (float)this.offDir * 3f;
                                    chestPlate.owner.vSpeed     -= 2f;
                                    chestPlate.duck.crippleTimer = 1f;
                                    chestPlate.Hurt(0.53f);
                                    flag3 = true;
                                }
                            }
                        }
                    }
                }
                if (!flag3)
                {
                    foreach (Thing thing2 in Level.current.things[typeof(Chainsaw)])
                    {
                        Chainsaw chainsaw = (Chainsaw)thing2;
                        if (chainsaw != this && chainsaw.owner != null && Collision.LineIntersect(this.barrelStartPos, base.barrelPosition, chainsaw.barrelStartPos, chainsaw.barrelPosition))
                        {
                            this.Shing(chainsaw);
                            chainsaw.Shing(this);
                            chainsaw.owner.hSpeed     += (float)this.offDir * 2f;
                            chainsaw.owner.vSpeed     -= 1.5f;
                            base.duck.hSpeed          += -(float)this.offDir * 2f;
                            base.duck.vSpeed          -= 1.5f;
                            chainsaw.duck.crippleTimer = 1f;
                            base.duck.crippleTimer     = 1f;
                            flag3 = true;
                            if (Recorder.currentRecording != null)
                            {
                                Recorder.currentRecording.LogBonus();
                            }
                        }
                    }
                }
                if (!flag3)
                {
                    foreach (IAmADuck amADuck in enumerable)
                    {
                        if (amADuck != base.duck)
                        {
                            MaterialThing materialThing2 = amADuck as MaterialThing;
                            if (materialThing2 != null)
                            {
                                materialThing2.velocity += new Vec2((float)this.offDir * 0.8f, -0.8f);
                                materialThing2.Destroy(new DTImpale(this));
                                if (base.duck != null)
                                {
                                    base.duck._timeSinceChainKill = 0;
                                }
                            }
                        }
                    }
                }
            }
        }
示例#13
0
 // Token: 0x06002308 RID: 8968
 public override bool Hit(Bullet bullet, Vec2 hitPos)
 {
     SFX.Play("ting", 1f, 0f, 0f, false);
     return(base.Hit(bullet, hitPos));
 }
示例#14
0
        public override void Update()
        {
            if (!this.pin)
            {
                this.collisionOffset = new Vec2(-6f, -2f);
                this.collisionSize   = new Vec2(12f, 3f);
            }
            base.Update();
            if (!this.pin && (double)Math.Abs(this.prevAngle - this.angle) > 0.100000001490116)
            {
                Vec2  vec2_1 = new Vec2(14f, 3f);
                Vec2  vec2_2 = new Vec2(-7f, -2f);
                Vec2  vec2_3 = new Vec2(4f, 14f);
                Vec2  vec2_4 = new Vec2(-2f, -7f);
                float num    = (float)Math.Abs(Math.Sin((double)this.angle));
                this.collisionSize   = vec2_1 * (1f - num) + vec2_3 * num;
                this.collisionOffset = vec2_2 * (1f - num) + vec2_4 * num;
                this.prevAngle       = this.angle;
            }
            this.UpdatePinState();
            if (this._sprite.imageIndex == 2)
            {
                this._mineFlash.alpha = Lerp.Float(this._mineFlash.alpha, 0.4f, 0.08f);
            }
            else
            {
                this._mineFlash.alpha = Lerp.Float(this._mineFlash.alpha, 0.0f, 0.08f);
            }
            if (this._armed)
            {
                this._sprite.speed = 2f;
            }
            if (this._thrown && this.owner == null)
            {
                this._thrown = false;
                if ((double)Math.Abs(this.hSpeed) + (double)Math.Abs(this.vSpeed) > 0.400000005960464)
                {
                    this.angleDegrees = 180f;
                }
            }
            if (this._armed)
            {
                ++this._framesSinceArm;
            }
            if (!this._pin && this._grounded && (!this._armed || this._framesSinceArm > 4))
            {
                this.canPickUp = false;
                float addWeight = this.addWeight;
                IEnumerable <PhysicsObject> physicsObjects = Level.CheckLineAll <PhysicsObject>(new Vec2(this.x - 6f, this.y - 3f), new Vec2(this.x + 6f, this.y - 3f));
                List <Duck> duckList1 = new List <Duck>();
                Duck        duck      = (Duck)null;
                bool        flag      = false;
                foreach (Thing previousThing in this.previousThings)
                {
                    if (previousThing.isServerForObject)
                    {
                        flag = true;
                    }
                }
                this.previousThings.Clear();
                foreach (PhysicsObject physicsObject in physicsObjects)
                {
                    if (physicsObject != this && physicsObject.owner == null && (!(physicsObject is Holdable) || (physicsObject as Holdable).canPickUp && (physicsObject as Holdable).hoverSpawner == null) && (double)Math.Abs(physicsObject.bottom - this.bottom) <= 6.0)
                    {
                        this.previousThings.Add(physicsObject);
                        switch (physicsObject)
                        {
                        case Duck _:
                        case TrappedDuck _:
                        case RagdollPart _:
                            addWeight += 5f;
                            Duck key1 = physicsObject as Duck;
                            if (physicsObject is TrappedDuck)
                            {
                                key1 = (physicsObject as TrappedDuck).captureDuck;
                            }
                            else if (physicsObject is RagdollPart && (physicsObject as RagdollPart).doll != null)
                            {
                                key1 = (physicsObject as RagdollPart).doll.captureDuck;
                            }
                            if (key1 != null)
                            {
                                duck = key1;
                                if (!this._ducksOnMine.ContainsKey(key1))
                                {
                                    this._ducksOnMine[key1] = 0.0f;
                                }
                                Dictionary <Duck, float> ducksOnMine;
                                Duck key2;
                                (ducksOnMine = this._ducksOnMine)[key2 = key1] = ducksOnMine[key2] + Maths.IncFrameTimer();
                                duckList1.Add(key1);
                                continue;
                            }
                            continue;

                        default:
                            addWeight += physicsObject.weight;
                            continue;
                        }
                    }
                }
                List <Duck> duckList2 = new List <Duck>();
                foreach (KeyValuePair <Duck, float> keyValuePair in this._ducksOnMine)
                {
                    if (!duckList1.Contains(keyValuePair.Key))
                    {
                        duckList2.Add(keyValuePair.Key);
                    }
                    else
                    {
                        keyValuePair.Key.profile.stats.timeSpentOnMines += Maths.IncFrameTimer();
                    }
                }
                foreach (Duck key in duckList2)
                {
                    this._ducksOnMine.Remove(key);
                }
                if ((double)addWeight < (double)this._holdingWeight && flag)
                {
                    Thing.Fondle((Thing)this, DuckNetwork.localConnection);
                    if (!this._armed)
                    {
                        this.Arm();
                    }
                    else
                    {
                        this._timer = -1f;
                    }
                }
                if (this._armed && (double)addWeight > (double)this._holdingWeight)
                {
                    if (!this._clicked && duck != null)
                    {
                        ++duck.profile.stats.minesSteppedOn;
                    }
                    this._clicked = true;
                    if (Network.isActive)
                    {
                        this._netDoubleBeep.Play();
                    }
                    else
                    {
                        SFX.Play("doubleBeep");
                    }
                }
                this._holdingWeight = addWeight;
            }
            if ((double)this._timer < 0.0 && this.isServerForObject)
            {
                this._timer = 1f;
                this.BlowUp();
            }
            this.addWeight = 0.0f;
        }
 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 UpdateParts()
 {
     if (!this.doubleUpdating && Input.Down("JUMP"))
     {
         this.doubleUpdating = true;
         this.UpdateParts();
         this.doubleUpdating = false;
     }
     if (!this.down && (double)this.yOffset > -1.0)
     {
         if ((double)this._initialWait < 1.0)
         {
             this._initialWait += 0.06f;
         }
         else if ((double)this._insertCoin < 1.0)
         {
             if (!this._chinged)
             {
                 SFX.Play("ching", pitch: Rando.Float(0.4f, 0.6f));
                 this._chinged = true;
             }
             this._insertCoinInc += 0.008f;
             this._insertCoin    += this._insertCoinInc;
         }
         else
         {
             this._insertCoin = 1f;
             if ((double)this._afterInsertWait < 1.0)
             {
                 this._afterInsertWait += 0.2f;
             }
             else
             {
                 if ((double)this._gachaWait >= 0.200000002980232 && !this.played)
                 {
                     this.played = true;
                     SFX.Play("gachaSound", pitch: Rando.Float(-0.1f, 0.1f));
                 }
                 if (!this._coined && (double)this._gachaWait > 0.200000002980232)
                 {
                     SFX.Play("gachaCoin", pitch: Rando.Float(0.4f, 0.6f));
                     this._coined = true;
                 }
                 this._gachaWait += 0.04f;
                 if ((double)this._gachaWait >= 1.0)
                 {
                     this._gachaWait  = 1f;
                     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);
                     }
                     float num = 8f;
                     this._toyVelocity.y += 0.2f;
                     Vec2 toyPosition1 = this._toyPosition;
                     if ((double)toyPosition1.length > (double)num)
                     {
                         Vec2 toyPosition2 = this._toyPosition;
                         this._toyPosition = toyPosition1.normalized * num;
                         Vec2 vec2 = this._toyPosition - toyPosition2;
                         this._toyVelocity += vec2;
                         if ((double)vec2.length > 1.0)
                         {
                             SFX.Play("gachaBounce", pitch: (0.7f + Rando.Float(0.2f)));
                         }
                         this._toyAngleLerp = Maths.PointDirection(Vec2.Zero, this._toyPosition);
                     }
                     Vec2 leftStick = InputProfile.active.leftStick;
                     if (InputProfile.active.lastActiveDevice is Keyboard)
                     {
                         if (InputProfile.active.Down("LEFT"))
                         {
                             leftStick.x = -1f;
                         }
                         if (InputProfile.active.Down("RIGHT"))
                         {
                             leftStick.x = 1f;
                         }
                         if (InputProfile.active.Down("UP"))
                         {
                             leftStick.y = 1f;
                         }
                         if (InputProfile.active.Down("DOWN"))
                         {
                             leftStick.y = -1f;
                         }
                     }
                     this._toyVelocity  += (this._lastStick - leftStick) * new Vec2(2f, -2f);
                     this._lastStick     = leftStick;
                     this._toyVelocity.x = Math.Max(Math.Min(this._toyVelocity.x, 3f), -3f);
                     this._toyVelocity.y = Math.Max(Math.Min(this._toyVelocity.y, 3f), -3f);
                     this._toyPosition  += this._toyVelocity;
                     if (!this.opened)
                     {
                         this._toyAngle  = Lerp.FloatSmooth(this._toyAngle, this._toyAngleLerp, 0.1f);
                         this._eggOffset = Lerp.Vec2Smooth(this._eggOffset, leftStick * 8f, 0.3f);
                     }
                     else
                     {
                         this._toyAngle    = Lerp.FloatSmooth(this._toyAngle, -90f, 0.1f);
                         this._eggOffset   = Lerp.Vec2Smooth(this._eggOffset, Vec2.Zero, 0.3f);
                         this._toyPosition = Lerp.Vec2Smooth(this._toyPosition, Vec2.Zero, 0.3f);
                     }
                     this._openWait += 0.029f;
                     if ((double)this._openWait >= 1.0)
                     {
                         if (!this.didOpenToyCorner)
                         {
                             HUD.AddCornerControl(HUDCorner.BottomRight, "@SELECT@OPEN TOY");
                             this.didOpenToyCorner = true;
                         }
                         if (Input.Pressed("SELECT") && !this.opened)
                         {
                             this.opened = true;
                             SFX.Play("gachaOpen", pitch: Rando.Float(0.1f, 0.3f));
                             this._gachaEgg.frame += 2;
                         }
                         if (this.opened)
                         {
                             this._swapWait += 0.06f;
                             if ((double)this._swapWait >= 1.0)
                             {
                                 if (!this._swapped)
                                 {
                                     SFX.Play("harp");
                                     HUD.CloseAllCorners();
                                     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 ? -250f : 0.0f, 0.4f);
     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.down && this._swapped && Input.Pressed("SELECT"))
     {
         this.played           = false;
         this._gachaWait       = 0.0f;
         this._openWait        = 0.0f;
         this.finished         = false;
         this.opened           = false;
         this._swapWait        = 0.0f;
         this._swapped         = false;
         this._starGrow        = 0.0f;
         this._insertCoin      = 0.0f;
         this._insertCoinInc   = 0.0f;
         this._afterInsertWait = 0.0f;
         this._chinged         = false;
         this.gachaY           = 0.0f;
         this.gachaSpeed       = 0.0f;
         this.doubleUpdating   = false;
         ++this._prizesGiven;
         this._eggOffset       = Vec2.Zero;
         this._toyPosition     = Vec2.Zero;
         this._toyVelocity     = Vec2.Zero;
         this._lastStick       = Vec2.Zero;
         this._toyAngle        = 0.0f;
         this._toyAngleLerp    = 0.0f;
         this._coined          = false;
         this._initialWait     = 0.0f;
         this.didOpenToyCorner = false;
         HUD.CloseAllCorners();
         SFX.Play("resume", 0.6f);
         if (this.prizes.Count > 4)
         {
             this.prizes.RemoveAt(0);
             this.LoadNextPrize();
         }
         else
         {
             this.down     = true;
             this._swapped = true;
         }
     }
     base.UpdateParts();
 }
示例#17
0
 public override void Update()
 {
     if (this.owner is Duck owner)
     {
         if (this.isServerForObject)
         {
             this.handPitch = owner.inputProfile.leftTrigger;
             this.notePitch = !owner.inputProfile.Down("SHOOT") ? 0.0f : this.handPitch + 0.01f;
         }
         if ((double)this.notePitch != (double)this.prevNotePitch)
         {
             if ((double)this.notePitch != 0.0)
             {
                 int num = (int)Math.Round((double)this.notePitch * 12.0);
                 if (num < 0)
                 {
                     num = 0;
                 }
                 if (num > 12)
                 {
                     num = 12;
                 }
                 if (this.noteSound == null)
                 {
                     this.hitPitch  = this.notePitch;
                     this.noteSound = SFX.Play("sax" + Change.ToString((object)num));
                     Level.Add((Thing) new MusicNote(this.barrelPosition.x, this.barrelPosition.y, this.barrelVector));
                 }
                 else
                 {
                     this.noteSound.Pitch = Maths.Clamp((float)(((double)this.notePitch - (double)this.hitPitch) * 0.100000001490116), -1f, 1f);
                 }
             }
             else if (this.noteSound != null)
             {
                 this.noteSound.Stop();
                 this.noteSound = (Sound)null;
             }
         }
         if (this._raised)
         {
             this.handAngle       = 0.0f;
             this.handOffset      = new Vec2(0.0f, 0.0f);
             this._holdOffset     = new Vec2(0.0f, 2f);
             this.collisionOffset = new Vec2(-4f, -7f);
             this.collisionSize   = new Vec2(8f, 16f);
             this.OnReleaseAction();
         }
         else
         {
             this.handOffset      = new Vec2((float)(5.0 + (1.0 - (double)this.handPitch) * 2.0), (float)((1.0 - (double)this.handPitch) * 4.0 - 2.0));
             this.handAngle       = (float)((1.0 - (double)this.handPitch) * 0.400000005960464) * (float)this.offDir;
             this._holdOffset     = new Vec2((float)(4.0 + (double)this.handPitch * 2.0), this.handPitch * 2f);
             this.collisionOffset = new Vec2(-1f, -7f);
             this.collisionSize   = new Vec2(2f, 16f);
         }
     }
     else
     {
         this.collisionOffset = new Vec2(-4f, -7f);
         this.collisionSize   = new Vec2(8f, 16f);
     }
     this.prevNotePitch = this.notePitch;
     base.Update();
 }
示例#18
0
        public override void Update()
        {
            this._waveMult = Lerp.Float(this._waveMult, 0.0f, 0.1f);
            if (this.isServerForObject)
            {
                this._magnetActive = this.action;
            }
            else if (this._magnetActive)
            {
                this._waveMult = 1f;
            }
            if ((double)this._beamSound.Volume > 0.00999999977648258 && this._beamSound.State != SoundState.Playing)
            {
                this._beamSound.Play();
            }
            else if ((double)this._beamSound.Volume < 0.00999999977648258 && this._beamSound.State == SoundState.Playing)
            {
                this._beamSound.Stop();
            }
            this._beamSound.Volume = Maths.LerpTowards(this._beamSound.Volume, this._magnetActive ? 0.1f : 0.0f, 0.1f);
            Vec2 p1_1 = this.Offset(this.barrelOffset);

            if (this._magnetActive && this.duck != null && this.duck.holdObject == this)
            {
                foreach (MagnaLine line in this._lines)
                {
                    line.Update();
                    line.show = true;
                    float num = this._ammoType.range;
                    if (this._hasRay)
                    {
                        num = (this.barrelPosition - this._rayHit).length;
                    }
                    line.dist = num;
                }
                if (this._grabbed == null && this._stuck == null)
                {
                    Holdable holdable1   = (Holdable)null;
                    float    val1        = 0.0f;
                    Vec2     normalized1 = this.barrelVector.Rotate(Maths.DegToRad(90f), Vec2.Zero).normalized;
                    for (int index = 0; index < 3; ++index)
                    {
                        Vec2 p1_2 = p1_1;
                        if (index == 0)
                        {
                            p1_2 += normalized1 * 8f;
                        }
                        else if (index == 2)
                        {
                            p1_2 -= normalized1 * 8f;
                        }
                        foreach (Holdable holdable2 in Level.CheckLineAll <Holdable>(p1_2, p1_2 + this.barrelVector * this._ammoType.range))
                        {
                            if (holdable2 != this && holdable2 != this.owner && (holdable2.owner != this.owner && holdable2.physicsMaterial == PhysicsMaterial.Metal) && (holdable2.duck == null || !(holdable2.duck.holdObject is MagnetGun)))
                            {
                                float length = (holdable2.position - p1_1).length;
                                if (holdable1 == null || (double)length < (double)val1)
                                {
                                    val1      = length;
                                    holdable1 = holdable2;
                                }
                            }
                        }
                    }
                    this._hasRay = false;
                    if (holdable1 != null && Level.CheckLine <Block>(p1_1, holdable1.position) == null)
                    {
                        float num = (float)((1.0 - (double)Math.Min(val1, this._ammoType.range) / (double)this._ammoType.range) * 0.800000011920929);
                        if (holdable1.owner is Duck duck && !(duck.holdObject is MagnetGun) && (double)num > 0.300000011920929)
                        {
                            if (!(holdable1 is Equipment) || holdable1.equippedDuck == null)
                            {
                                duck.ThrowItem(false);
                                duck = (Duck)null;
                            }
                            else if (holdable1 is TinfoilHat)
                            {
                                duck.Unequip(holdable1 as Equipment);
                                duck = (Duck)null;
                            }
                        }
                        Vec2 normalized2 = (p1_1 - holdable1.position).normalized;
                        // TODO if (duck != null && holdable1 is Equipment)
                        if (false)
                        {
                            if (duck.ragdoll != null)
                            {
                                duck.ragdoll.makeActive = true;
                                return;
                            }
                            if (!(holdable1.owner.realObject is Duck) && Network.isActive)
                            {
                                return;
                            }
                            holdable1.owner.realObject.hSpeed += normalized2.x * num;
                            holdable1.owner.realObject.vSpeed += (float)((double)normalized2.y * (double)num * 4.0);
                            if ((holdable1.owner.realObject as PhysicsObject).grounded && (double)holdable1.owner.realObject.vSpeed > 0.0)
                            {
                                holdable1.owner.realObject.vSpeed = 0.0f;
                            }
                        }
                        else
                        {
                            this.Fondle((Thing)holdable1);
                            holdable1.hSpeed += normalized2.x * num;
                            holdable1.vSpeed += (float)((double)normalized2.y * (double)num * 4.0);
                            if (holdable1.grounded && (double)holdable1.vSpeed > 0.0)
                            {
                                holdable1.vSpeed = 0.0f;
                            }
                        }
                        this._hasRay = true;
                        this._rayHit = holdable1.position;
                        if (this.isServerForObject && (double)val1 < 20.0)
                        {
                            if (holdable1 is Equipment && holdable1.duck != null)
                            {
                                this._grabbed = holdable1.owner.realObject;
                                holdable1.duck.immobilized = true;
                                holdable1.duck.gripped     = true;
                                holdable1.duck.ThrowItem();
                                if (!(holdable1.owner.realObject is Duck))
                                {
                                    holdable1.owner.realObject.owner = this.owner;
                                    Thing.SuperFondle(holdable1.owner.realObject, DuckNetwork.localConnection);
                                }
                            }
                            else
                            {
                                this._grabbed   = (Thing)holdable1;
                                holdable1.owner = this.owner;
                                if (holdable1 is Grenade)
                                {
                                    (holdable1 as Grenade).OnPressAction();
                                }
                            }
                            this.attachIndex += 1;
                        }
                    }
                    else if (this.isServerForObject && this._stuck == null && ((double)Math.Abs(this.angle) < 0.0500000007450581 || (double)Math.Abs(this.angle) > 1.5))
                    {
                        Vec2 position = this.owner.position;
                        if (this.duck.sliding)
                        {
                            position.y += 4f;
                        }
                        Vec2  hitPos;
                        Block block = Level.CheckRay <Block>(position, position + this.barrelVector * this._ammoType.range, out hitPos);
                        this._hasRay = true;
                        this._rayHit = hitPos;
                        if (block != null && block.physicsMaterial == PhysicsMaterial.Metal)
                        {
                            float num    = (float)((1.0 - (double)Math.Min((block.position - position).length, this._ammoType.range) / (double)this._ammoType.range) * 0.800000011920929);
                            Vec2  vec2   = hitPos - this.duck.position;
                            float length = vec2.length;
                            vec2.Normalize();
                            this.owner.hSpeed += vec2.x * num;
                            this.owner.vSpeed += vec2.y * num;
                            if ((double)length < 20.0)
                            {
                                this._stuck       = block;
                                this._stickPos    = hitPos;
                                this._stickNormal = -this.barrelVector;
                                this.attachIndex += 1;
                            }
                        }
                    }
                }
            }
            else
            {
                if (this.isServerForObject)
                {
                    if (this._grabbed != null)
                    {
                        this._grabbed.angle = 0.0f;
                        if (this._grabbed is Holdable grabbed)
                        {
                            grabbed.owner = (Thing)null;
                            grabbed.ReturnToWorld();
                            this.ReturnItemToWorld((Thing)grabbed);
                        }
                        if (this._grabbed is Duck grabbed2)
                        {
                            grabbed2.immobilized  = false;
                            grabbed2.gripped      = false;
                            grabbed2.crippleTimer = 1f;
                        }
                        this._grabbed.visible       = true;
                        this._grabbed.enablePhysics = true;
                        this._grabbed.hSpeed        = this.barrelVector.x * 5f;
                        this._grabbed.vSpeed        = this.barrelVector.y * 5f;
                        this._grabbed       = (Thing)null;
                        this._collisionSize = new Vec2(14f, this._collisionSize.y);
                    }
                    if (this._stuck != null)
                    {
                        this._stuck = (Block)null;
                        if (this.owner != null && !this._raised)
                        {
                            this.duck._groundValid = 6;
                        }
                    }
                }
                foreach (MagnaLine line in this._lines)
                {
                    line.show = false;
                }
            }
            if (Network.isActive)
            {
                if (this._grabbed != null)
                {
                    if (this._grabbed is TrappedDuck && this._grabbed.connection != this.connection)
                    {
                        this._grabbed = (Thing)(this._grabbed as TrappedDuck)._duckOwner;
                        if (this._grabbed != null)
                        {
                            Duck grabbed2 = this._grabbed as Duck;
                            grabbed2.immobilized = true;
                            grabbed2.gripped     = true;
                            grabbed2.ThrowItem();
                            grabbed2._trapped = (TrappedDuck)null;
                        }
                    }
                    if (this._grabbed is Duck grabbed)
                    {
                        grabbed.isGrabbedByMagnet = true;
                        if (this.isServerForObject)
                        {
                            this.Fondle((Thing)grabbed);
                            this.Fondle((Thing)grabbed.holdObject);
                            foreach (Thing t in grabbed._equipment)
                            {
                                this.Fondle(t);
                            }
                            this.Fondle((Thing)grabbed._ragdollInstance);
                            this.Fondle((Thing)grabbed._trappedInstance);
                            this.Fondle((Thing)grabbed._cookedInstance);
                        }
                    }
                }
                if (this._grabbed == null && this._prevGrabDuck != null && this._prevGrabDuck is Duck)
                {
                    (this._prevGrabDuck as Duck).isGrabbedByMagnet = false;
                }
                this._prevGrabDuck = this._grabbed;
            }
            if (this._grabbed != null && this.owner != null)
            {
                if (this.isServerForObject)
                {
                    this.Fondle(this._grabbed);
                }
                this._grabbed.hSpeed        = this.owner.hSpeed;
                this._grabbed.vSpeed        = this.owner.vSpeed;
                this._grabbed.angle         = this.angle;
                this._grabbed.visible       = false;
                this._grabbed.offDir        = this.offDir;
                this._grabbed.enablePhysics = false;
                this._collisionSize         = new Vec2(16f + this._grabbed.width, this._collisionSize.y);
                if (this._grabbed is Duck grabbed)
                {
                    grabbed.grounded = true;
                    grabbed.sliding  = false;
                    grabbed.crouch   = false;
                }
                else
                {
                    this._grabbed.owner = (Thing)this;
                }
            }
            if (this.localAttachIndex < this.attachIndex)
            {
                for (int index = 0; index < 2; ++index)
                {
                    Level.Add((Thing)SmallSmoke.New(p1_1.x + Rando.Float(-1f, 1f), p1_1.y + Rando.Float(-1f, 1f)));
                }
                SFX.Play("grappleHook");
                for (int index = 0; index < 6; ++index)
                {
                    Level.Add((Thing)Spark.New(p1_1.x - this.barrelVector.x * 2f + Rando.Float(-1f, 1f), p1_1.y - this.barrelVector.y * 2f + Rando.Float(-1f, 1f), this.barrelVector + new Vec2(Rando.Float(-1f, 1f), Rando.Float(-1f, 1f))));
                }
                this.localAttachIndex = this.attachIndex;
            }
            if (this.isServerForObject)
            {
                if (this._magnetActive && this._raised && (this.duck != null && !this.duck.grounded) && this._grabbed == null)
                {
                    this._keepRaised = true;
                }
                else
                {
                    this._keepRaised = false;
                }
                if (this._stuck != null && this.duck != null)
                {
                    if ((double)this._stickPos.y < (double)this.owner.position.y - 8.0)
                    {
                        this.owner.position = this._stickPos + this._stickNormal * 12f;
                        this._raised        = true;
                        this._keepRaised    = true;
                    }
                    else
                    {
                        this.owner.position = this._stickPos + this._stickNormal * 16f;
                        this._raised        = false;
                        this._keepRaised    = false;
                    }
                    this.owner.hSpeed  = this.owner.vSpeed = 0.0f;
                    this.duck.moveLock = true;
                }
                else if (this._stuck == null && this.duck != null)
                {
                    this.duck.moveLock = false;
                }
                if (this.owner == null && this.prevOwner != null)
                {
                    if (this.prevOwner is Duck prevOwner)
                    {
                        prevOwner.moveLock = false;
                    }
                    this._prevOwner = (Thing)null;
                }
            }
            base.Update();
        }
示例#19
0
 public override void PostDrawLayer(Layer layer)
 {
     if (NetworkDebugger._instances.Count == 0)
     {
         return;
     }
     if (layer == Layer.Console)
     {
         if (NetworkDebugger._interfaces[0].pin || (double)Mouse.xConsole < (double)Layer.Console.width / 2.0 && (double)Mouse.yConsole < (double)Layer.Console.height / 2.0)
         {
             DevConsoleCore core = DevConsole.core;
             DevConsole.core = NetworkDebugger._instances[0].consoleCore;
             NetworkDebugger._interfaces[0].Draw(NetworkDebugger._instances[0].network);
             DevConsole.core = core;
         }
         else
         {
             NetworkDebugger._interfaces[0].visible = false;
         }
         if (NetworkDebugger._interfaces[1].pin || (double)Mouse.xConsole > (double)Layer.Console.width / 2.0 && (double)Mouse.yConsole < (double)Layer.Console.height / 2.0)
         {
             if (NetworkDebugger._instances.Count > 1)
             {
                 DevConsoleCore core = DevConsole.core;
                 DevConsole.core = NetworkDebugger._instances[1].consoleCore;
                 NetworkDebugger._interfaces[1].Draw(NetworkDebugger._instances[1].network);
                 DevConsole.core = core;
             }
         }
         else
         {
             NetworkDebugger._interfaces[1].visible = false;
         }
         if (NetworkDebugger._interfaces[2].pin || (double)Mouse.xConsole <(double)Layer.Console.width / 2.0 && (double)Mouse.yConsole> (double) Layer.Console.height / 2.0)
         {
             if (NetworkDebugger._instances.Count > 2)
             {
                 DevConsoleCore core = DevConsole.core;
                 DevConsole.core = NetworkDebugger._instances[2].consoleCore;
                 NetworkDebugger._interfaces[2].Draw(NetworkDebugger._instances[2].network);
                 DevConsole.core = core;
             }
         }
         else
         {
             NetworkDebugger._interfaces[2].visible = false;
         }
         if (NetworkDebugger._interfaces[3].pin || (double)Mouse.xConsole > (double)Layer.Console.width / 2.0 && (double)Mouse.yConsole > (double)Layer.Console.height / 2.0)
         {
             if (NetworkDebugger._instances.Count > 3)
             {
                 DevConsoleCore core = DevConsole.core;
                 DevConsole.core = NetworkDebugger._instances[3].consoleCore;
                 NetworkDebugger._interfaces[3].Draw(NetworkDebugger._instances[3].network);
                 DevConsole.core = core;
             }
         }
         else
         {
             NetworkDebugger._interfaces[3].visible = false;
         }
         if (this._connectionArrow == null)
         {
             this._connectionArrow = new SpriteMap("connectionArrow", 56, 13);
             this._connectionArrow.CenterOrigin();
             this._connectionX = new Sprite("connectionX");
             this._connectionX.CenterOrigin();
         }
         for (int i = 0; i < 4; ++i)
         {
             if (NetworkDebugger._instances.Count > i && NetworkDebugger._instances[i].active)
             {
                 for (int j = 0; j < 4; ++j)
                 {
                     if (i != j && NetworkDebugger._instances.Count > j && NetworkDebugger._instances[j].active)
                     {
                         NetworkConnection networkConnection1 = NetworkDebugger._instances[i].network.core.connections.FirstOrDefault <NetworkConnection>((Func <NetworkConnection, bool>)(x => x.identifier == NetworkDebugger.GetID(j)));
                         NetworkConnection networkConnection2 = NetworkDebugger._instances[j].network.core.connections.FirstOrDefault <NetworkConnection>((Func <NetworkConnection, bool>)(x => x.identifier == NetworkDebugger.GetID(i)));
                         Vec2  vec2_1 = NetworkDebugger._interfaces[i].position + new Vec2((float)(DuckGame.Graphics.width / 4 - 10), (float)(DuckGame.Graphics.height / 4 - 10));
                         Vec2  vec2_2 = NetworkDebugger._interfaces[j].position + new Vec2((float)(DuckGame.Graphics.width / 4 - 10), (float)(DuckGame.Graphics.height / 4 - 10));
                         Vec2  p2     = vec2_2 - vec2_1;
                         Vec2  vec2_3 = p2.normalized.Rotate(Maths.DegToRad(90f), Vec2.Zero);
                         float num1   = -Maths.PointDirection(Vec2.Zero, p2);
                         float num2   = 0.0f;
                         if (networkConnection1 != null)
                         {
                             float num3 = 0.0f;
                             float num4 = 0.0f;
                             if (networkConnection2 != null)
                             {
                                 num3 = NetworkDebugger.GetReceived(networkConnection1.identifier, networkConnection2.identifier);
                                 num4 = NetworkDebugger.GetSent(networkConnection1.identifier, networkConnection2.identifier);
                                 num2 = 6f;
                             }
                             this._connectionArrow.frame        = networkConnection1.status != ConnectionStatus.Connected ? 0 : 3;
                             this._connectionArrow.angleDegrees = num1;
                             this._connectionArrow.alpha        = 1f;
                             this._connectionArrow.depth        = new Depth(0.92f);
                             Vec2 vec2_4 = (vec2_1 + vec2_2) / 2f + vec2_3 * num2;
                             DuckGame.Graphics.Draw((Sprite)this._connectionArrow, vec2_4.x, vec2_4.y);
                             if (networkConnection1.status != ConnectionStatus.Disconnecting)
                             {
                                 this._connectionX.depth = new Depth(0.98f);
                                 Vec2 vec2_5 = vec2_4 - p2.normalized * 22f;
                                 if ((double)(Mouse.positionConsole - vec2_5).length < 8.0)
                                 {
                                     this._connectionX.alpha = 1f;
                                     if (this.lefpres)
                                     {
                                         networkConnection1.Disconnect();
                                         SFX.Play("quack");
                                     }
                                 }
                                 else
                                 {
                                     this._connectionX.alpha = 0.4f;
                                 }
                                 DuckGame.Graphics.Draw(this._connectionX, vec2_5.x, vec2_5.y);
                             }
                             if ((double)num4 > 0.0)
                             {
                                 ++this._connectionArrow.frame;
                                 this._connectionArrow.alpha = num4;
                                 this._connectionArrow.depth = new Depth(0.95f);
                                 DuckGame.Graphics.Draw((Sprite)this._connectionArrow, vec2_4.x, vec2_4.y);
                                 --this._connectionArrow.frame;
                             }
                             if ((double)num3 > 0.0)
                             {
                                 this._connectionArrow.frame += 2;
                                 this._connectionArrow.alpha  = num3;
                                 this._connectionArrow.depth  = new Depth(0.95f);
                                 DuckGame.Graphics.Draw((Sprite)this._connectionArrow, vec2_4.x, vec2_4.y);
                                 this._connectionArrow.frame -= 2;
                             }
                         }
                     }
                 }
             }
         }
     }
     base.PostDrawLayer(layer);
 }
示例#20
0
 public override void Update()
 {
     if (this.owner is Duck owner)
     {
         if (this.isServerForObject)
         {
             if (owner.inputProfile.Pressed("SHOOT"))
             {
                 this.currentPitch = 2;
             }
             if (owner.inputProfile.Pressed("STRAFE"))
             {
                 this.currentPitch = 0;
             }
             if (owner.inputProfile.Pressed("RAGDOLL"))
             {
                 this.currentPitch = 1;
             }
             if ((double)owner.inputProfile.leftTrigger > 0.5 && !this.leftPressed)
             {
                 this.currentPitch = 2;
                 this.leftPressed  = true;
             }
             if ((double)owner.inputProfile.rightTrigger > 0.5 && !this.rightPressed)
             {
                 this.currentPitch = 3;
                 this.rightPressed = true;
             }
             if (owner.inputProfile.Released("STRAFE") && this.currentPitch == 0)
             {
                 this.currentPitch = -1;
             }
             if (owner.inputProfile.Released("SHOOT") && this.currentPitch == 2)
             {
                 this.currentPitch = -1;
             }
             if (owner.inputProfile.Released("RAGDOLL") && this.currentPitch == 1)
             {
                 this.currentPitch = -1;
             }
             if ((double)owner.inputProfile.leftTrigger <= 0.5)
             {
                 if (this.currentPitch == 2 && this.leftPressed)
                 {
                     this.currentPitch = -1;
                 }
                 this.leftPressed = false;
             }
             if ((double)owner.inputProfile.rightTrigger <= 0.5)
             {
                 if (this.currentPitch == 3 && this.rightPressed)
                 {
                     this.currentPitch = -1;
                 }
                 this.rightPressed = false;
             }
             this.notePitch = this.currentPitch < 0 || this._raised ? 0.0f : (float)((double)this.currentPitch / 3.0 + 0.00999999977648258);
         }
         if ((double)this.notePitch != (double)this.prevNotePitch)
         {
             if ((double)this.notePitch != 0.0)
             {
                 if (this.noteSound != null)
                 {
                     this.noteSound.Stop();
                     this.noteSound = (Sound)null;
                 }
                 int num = (int)Math.Round((double)this.notePitch * 3.0);
                 if (num < 0)
                 {
                     num = 0;
                 }
                 if (num > 12)
                 {
                     num = 12;
                 }
                 if (this.noteSound == null)
                 {
                     this.hitPitch  = this.notePitch;
                     this.noteSound = SFX.Play("trumpet0" + Change.ToString((object)(num + 1)), 0.8f);
                     Level.Add((Thing) new MusicNote(this.barrelPosition.x, this.barrelPosition.y, this.barrelVector));
                 }
                 else
                 {
                     this.noteSound.Pitch = Maths.Clamp((float)(((double)this.notePitch - (double)this.hitPitch) * 0.00999999977648258), -1f, 1f);
                 }
             }
             else if (this.noteSound != null)
             {
                 this.noteSound.Stop();
                 this.noteSound = (Sound)null;
             }
         }
         if (this._raised)
         {
             this.collisionOffset = new Vec2(4f, -4f);
             this.collisionSize   = new Vec2(8f, 8f);
             this._holdOffset     = new Vec2(0.0f, 0.0f);
             this.handOffset      = new Vec2(0.0f, 0.0f);
             this.OnReleaseAction();
         }
         else
         {
             this.collisionOffset = new Vec2(-6f, -4f);
             this.collisionSize   = new Vec2(8f, 8f);
             this._holdOffset     = new Vec2(10f, -2f);
             this.handOffset      = new Vec2(5f, -2f);
         }
     }
     else
     {
         this.leftPressed     = false;
         this.rightPressed    = false;
         this.currentPitch    = -1;
         this.collisionOffset = new Vec2(-6f, -4f);
         this.collisionSize   = new Vec2(8f, 8f);
         this._holdOffset     = new Vec2(6f, 2f);
     }
     this.prevNotePitch = this.notePitch;
     base.Update();
 }
示例#21
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;
            }
        }
        public void ButtonPressed(ToolbarButton button)
        {
            SFX.Play("highClick", 0.3f);
            ContextMenu contextMenu1 = (ContextMenu)null;
            Vec2        vec2         = new Vec2(2f, 21f);

            if (button == this._newButton)
            {
                this.Closed();
                this._newMenu       = new ContextMenu((IContextListener)this, hasToproot: true, topRoot: button.position);
                this._newMenu.x     = this.position.x - vec2.x;
                this._newMenu.y     = this.position.y + vec2.y;
                this._newMenu.root  = true;
                this._newMenu.depth = this.depth + 10;
                this.Selected();
                this._newMenu.AddItem(new ContextMenu((IContextListener)this)
                {
                    itemSize =
                    {
                        x = 60f
                    },
                    text = "NEW"
                });
                this._newMenu.AddItem(new ContextMenu((IContextListener)this)
                {
                    itemSize =
                    {
                        x = 60f
                    },
                    text = "NEW ONLINE"
                });
                ContextMenu contextMenu2 = new ContextMenu((IContextListener)this);
                contextMenu2.itemSize.x = 60f;
                contextMenu2.text       = "ARCADE";
                contextMenu2.AddItem(new ContextMenu((IContextListener)this)
                {
                    itemSize =
                    {
                        x = 60f
                    },
                    text = "NEW ARCADE"
                });
                contextMenu2.AddItem(new ContextMenu((IContextListener)this)
                {
                    itemSize =
                    {
                        x = 60f
                    },
                    text = "NEW CHALLENGE"
                });
                contextMenu2.AddItem(new ContextMenu((IContextListener)this)
                {
                    itemSize =
                    {
                        x = 60f
                    },
                    text = "NEW ARCADE MACHINE"
                });
                this._newMenu.AddItem(contextMenu2);
                this._newMenu.AddItem(new ContextMenu((IContextListener)this)
                {
                    itemSize =
                    {
                        x = 60f
                    },
                    text = "CANCEL"
                });
                Level.Add((Thing)this._newMenu);
                this._newMenu.opened = true;
                contextMenu1         = this._newMenu;
            }
            if (button == this._saveButton)
            {
                this.Closed();
                this._saveMenu       = new ContextMenu((IContextListener)this, hasToproot: true, topRoot: button.position);
                this._saveMenu.x     = this.position.x - vec2.x;
                this._saveMenu.y     = this.position.y + vec2.y;
                this._saveMenu.root  = true;
                this._saveMenu.depth = this.depth + 10;
                this.Selected();
                this._saveMenu.AddItem(new ContextMenu((IContextListener)this)
                {
                    itemSize =
                    {
                        x = 60f
                    },
                    text = "SAVE"
                });
                this._saveMenu.AddItem(new ContextMenu((IContextListener)this)
                {
                    itemSize =
                    {
                        x = 60f
                    },
                    text = "SAVE AS"
                });
                Level.Add((Thing)this._saveMenu);
                this._saveMenu.opened = true;
                contextMenu1          = this._saveMenu;
            }
            if (button == this._gridButton)
            {
                this.Closed();
                this._gridMenu       = new ContextMenu((IContextListener)this, hasToproot: true, topRoot: button.position);
                this._gridMenu.x     = this.position.x - vec2.x;
                this._gridMenu.y     = this.position.y + vec2.y;
                this._gridMenu.root  = true;
                this._gridMenu.depth = this.depth + 10;
                this.Selected();
                this._gridMenu.AddItem(new ContextMenu((IContextListener)this)
                {
                    itemSize =
                    {
                        x = 60f
                    },
                    text = "8x8"
                });
                this._gridMenu.AddItem(new ContextMenu((IContextListener)this)
                {
                    itemSize =
                    {
                        x = 60f
                    },
                    text = "16x16"
                });
                this._gridMenu.AddItem(new ContextMenu((IContextListener)this)
                {
                    itemSize =
                    {
                        x = 60f
                    },
                    text = "32x32"
                });
                Level.Add((Thing)this._gridMenu);
                this._gridMenu.opened = true;
                contextMenu1          = this._gridMenu;
            }
            if (button == this._loadButton)
            {
                Editor current = Level.current as Editor;
                current.Load();
                current.CloseMenu();
            }
            if (button == this._steamButton)
            {
                Editor current = Level.current as Editor;
                current.SteamUpload();
                current.CloseMenu();
            }
            if (button == this._playButton)
            {
                (Level.current as Editor).Play();
            }
            if (button == this._quitButton)
            {
                this.Closed();
                this._quitMenu       = new ContextMenu((IContextListener)this, hasToproot: true, topRoot: button.position);
                this._quitMenu.x     = this.position.x - vec2.x;
                this._quitMenu.y     = this.position.y + vec2.y;
                this._quitMenu.root  = true;
                this._quitMenu.depth = this.depth + 10;
                this.Selected();
                this._quitMenu.AddItem(new ContextMenu((IContextListener)this)
                {
                    itemSize =
                    {
                        x = 60f
                    },
                    text = "QUIT"
                });
                this._quitMenu.AddItem(new ContextMenu((IContextListener)this)
                {
                    itemSize =
                    {
                        x = 60f
                    },
                    text = "CANCEL"
                });
                Level.Add((Thing)this._quitMenu);
                this._quitMenu.opened = true;
                contextMenu1          = this._quitMenu;
            }
            if (contextMenu1 == null || (double)contextMenu1.y + (double)contextMenu1.menuSize.y <= (double)Layer.HUD.camera.height - 4.0)
            {
                return;
            }
            float y = contextMenu1.y;

            contextMenu1.y = Layer.HUD.camera.height - 4f - contextMenu1.menuSize.y;
            contextMenu1._toprootPosition.y += contextMenu1.y - y;
            if (this.owner is ContextMenu owner)
            {
                owner._openedOffset = 0.0f;
                owner.y             = contextMenu1.y - 16f - owner.menuSize.y;
                owner.PositionItems();
            }
            contextMenu1.PositionItems();
        }
示例#23
0
 public override void Update()
 {
     this.impacting.Clear();
     if (this._up && this._popup && this.holdObject is Gun)
     {
         Gun   holdObject = this.holdObject as Gun;
         float num        = 300f;
         if (holdObject.ammoType != null)
         {
             num = holdObject.ammoType.range;
         }
         Vec2 vec2 = this.holdObject.position + new Vec2((float)this.offDir * num, 0.0f);
         foreach (Duck duck in Level.current.things[typeof(Duck)].Where <Thing>((Func <Thing, bool>)(d => !(d is TargetDuck))))
         {
             if ((Collision.Line(this.holdObject.position + new Vec2(0.0f, -5f), vec2 + new Vec2(0.0f, -5f), duck.rectangle) || Collision.Line(this.holdObject.position + new Vec2(0.0f, 5f), vec2 + new Vec2(0.0f, 5f), duck.rectangle)) && Level.CheckLine <Block>(this.holdObject.position, duck.position) == null)
             {
                 this._waitFire -= 0.03f;
                 break;
             }
         }
         bool flag = false;
         if ((double)this._autoFireWait > 0.0)
         {
             this._autoFireWait -= Maths.IncFrameTimer();
             if ((double)this._autoFireWait <= 0.0)
             {
                 flag = true;
             }
         }
         if ((double)this._waitFire <= 0.0 || flag)
         {
             holdObject.PressAction();
             this._waitFire = 1f;
         }
         if ((double)this._waitFire < 1.0)
         {
             this._waitFire += 0.01f;
         }
     }
     this.UpdateCollision();
     this.UpdateSkeleton();
     if ((double)this._hitPoints <= 0.0)
     {
         this.Destroy((DestroyType) new DTCrush((PhysicsObject)null));
     }
     if (!this._up)
     {
         this._timeCount = 0.0f;
         if (this._popup)
         {
             this._upSpeed += 0.1f;
         }
         if (this._stance != TargetStance.Fly)
         {
             this.yscale += this._upSpeed;
             if ((double)this.yscale < 1.0)
             {
                 return;
             }
             this.yscale   = 1f;
             this._upSpeed = 0.0f;
             this._up      = true;
             SFX.Play("grappleHook", 0.7f, Rando.Float(-0.2f, 0.2f));
             Level.Add((Thing)SmallSmoke.New(this.x - 4f, this.y));
             Level.Add((Thing)SmallSmoke.New(this.x + 4f, this.y));
             this.SpawnHoldObject();
             if (this.helmet)
             {
                 Helmet helmet = new Helmet(this.x, this.y);
                 Level.Add((Thing)helmet);
                 this.Equip((Equipment)helmet);
             }
             if (!this.chestPlate)
             {
                 return;
             }
             ChestPlate chestPlate = new ChestPlate(this.x, this.y);
             Level.Add((Thing)chestPlate);
             this.Equip((Equipment)chestPlate);
         }
         else
         {
             this.xscale += this._upSpeed;
             if ((double)this.xscale < 1.0)
             {
                 return;
             }
             this.xscale   = 1f;
             this._upSpeed = 0.0f;
             this._up      = true;
             SFX.Play("grappleHook", 0.7f, Rando.Float(-0.2f, 0.2f));
             Level.Add((Thing)SmallSmoke.New(this.x - 4f, this.y));
             Level.Add((Thing)SmallSmoke.New(this.x + 4f, this.y));
             if (this.helmet)
             {
                 Helmet helmet = new Helmet(this.x, this.y);
                 Level.Add((Thing)helmet);
                 this.Equip((Equipment)helmet);
             }
             if (!this.chestPlate)
             {
                 return;
             }
             ChestPlate chestPlate = new ChestPlate(this.x, this.y);
             Level.Add((Thing)chestPlate);
             this.Equip((Equipment)chestPlate);
         }
     }
     else
     {
         this._timeCount += Maths.IncFrameTimer();
         if (this._popup && (double)this.time.value != 0.0 && (double)this._timeCount >= (double)this.time.value)
         {
             SFX.Play("grappleHook", 0.2f, Rando.Float(-0.2f, 0.2f));
             this.PopDown();
         }
         else
         {
             if (!this._popup)
             {
                 this._upSpeed += 0.1f;
             }
             if (this._stance != TargetStance.Fly)
             {
                 this.yscale -= this._upSpeed;
                 if ((double)this.yscale >= 0.0)
                 {
                     return;
                 }
                 this.yscale   = 0.0f;
                 this._upSpeed = 0.0f;
                 this._up      = false;
                 SFX.Play("grappleHook", 0.2f, Rando.Float(-0.2f, 0.2f));
                 Level.Add((Thing)SmallSmoke.New(this.x - 4f, this.y));
                 Level.Add((Thing)SmallSmoke.New(this.x + 4f, this.y));
                 this._hitPoints = this._maxHealth = 0.1f;
             }
             else
             {
                 this.xscale -= this._upSpeed;
                 if ((double)this.xscale >= 0.0)
                 {
                     return;
                 }
                 this.xscale   = 0.0f;
                 this._upSpeed = 0.0f;
                 this._up      = false;
                 SFX.Play("grappleHook", 0.2f, Rando.Float(-0.2f, 0.2f));
                 Level.Add((Thing)SmallSmoke.New(this.x - 4f, this.y));
                 Level.Add((Thing)SmallSmoke.New(this.x + 4f, this.y));
                 this._hitPoints = this._maxHealth = 0.1f;
             }
         }
     }
 }
示例#24
0
 public static void Initialize()
 {
     MonoMain.loadMessage = "Loading SFX";
     SFX.SearchDir("Content/Audio/SFX");
 }
示例#25
0
        // Token: 0x060015CD RID: 5581
        public override void Update()         //When used
        {
            Duck duck = this.owner as Duck;

            if (duck != null)
            {
                if (base.isServerForObject)
                {
                    this.handPitch = 1f - Mouse.x / Layer.HUD.camera.width * 2f;
                    if (this.handPitch < 0f)                     //Prevents hand and pitch going too far
                    {
                        float currentpitch = this.handPitch;
                        float neededpitch  = 0f - this.handPitch;
                        this.handPitch = currentpitch + neededpitch;
                    }
                    if (duck.inputProfile.Down("SHOOT"))
                    {
                        this.notePitch = this.handPitch + 0.01f;
                    }
                    else
                    {
                        this.notePitch = 0f;
                    }
                }
                if (this.notePitch != this.prevNotePitch)
                {
                    if (this.notePitch != 0f)
                    {
                        int num = (int)Math.Round((double)(this.notePitch * 12f));
                        if (num < 0)
                        {
                            num = 0;
                        }
                        if (num > 12)
                        {
                            num = 12;
                        }
                        if (this.noteSound == null)
                        {
                            this.hitPitch = this.notePitch;
                            Sound sound = SFX.Play("trombone" + Change.ToString(num), 1f, 0f, 0f, false);
                            this.noteSound = sound;
                            Level.Add(new MusicNote(base.barrelPosition.x, base.barrelPosition.y, base.barrelVector));
                        }
                        else
                        {
                            this.noteSound.Pitch = Maths.Clamp(this.notePitch - this.hitPitch, -1f, 1f);
                        }
                    }
                    else if (this.noteSound != null)
                    {
                        this.noteSound.Stop();
                        this.noteSound = null;
                    }
                }
                if (this._raised)
                {
                    this.handAngle       = 0f;
                    this.handOffset      = new Vec2(0f, 0f);
                    this._holdOffset     = new Vec2(0f, 2f);
                    this.collisionOffset = new Vec2(-4f, -7f);
                    this.collisionSize   = new Vec2(8f, 16f);
                }
                else                 //Hand pitch
                {
                    this.handOffset      = new Vec2(6f + (1f - this.handPitch) * 4f, -4f + (1f - this.handPitch) * 4f);
                    this.handAngle       = (1f - this.handPitch) * 0.4f * (float)this.offDir;
                    this._holdOffset     = new Vec2(5f + this.handPitch * 2f, -9f + this.handPitch * 2f);
                    this.collisionOffset = new Vec2(-4f, -7f);
                    this.collisionSize   = new Vec2(2f, 16f);
                    this._slideVal       = 1f - this.handPitch;
                }
            }
            else
            {
                this.collisionOffset = new Vec2(-4f, -5f);
                this.collisionSize   = new Vec2(8f, 11f);
            }
            this.prevNotePitch = this.notePitch;
            base.Update();
        }
示例#26
0
 public override void Update()
 {
     if (this._desiredTransition != this._transition)
     {
         this._fade = Lerp.Float(this._fade, 0.0f, 0.06f);
         if ((double)this._fade <= 0.0)
         {
             this._transition = this._desiredTransition;
             if (this._transition == DoorTransition.Profile)
             {
                 Graphics.fade = 0.0f;
                 Level.current = (Level) new LockerRoom(this._profile);
             }
             else if (this._transition == DoorTransition.Exit)
             {
                 Graphics.fade = 0.0f;
                 Level.current = (Level) new TitleScreen();
             }
             else if (this._transition == DoorTransition.Album)
             {
                 Graphics.fade = 0.0f;
                 Level.current = (Level) new Album();
             }
         }
     }
     else
     {
         this._fade = Lerp.Float(this._fade, 1f, 0.06f);
         if (this._selectorPosition == this._desiredSelectorPosition)
         {
             if (InputProfile.active.Down("LEFT"))
             {
                 this.SelectUp();
             }
             if (InputProfile.active.Down("RIGHT"))
             {
                 this.SelectDown();
             }
             if (InputProfile.active.Pressed("SELECT") && this._profile != null)
             {
                 this._desiredTransition = DoorTransition.Profile;
                 HUD.CloseAllCorners();
             }
         }
         if (InputProfile.active.Pressed("QUACK"))
         {
             this._desiredTransition = DoorTransition.Exit;
             HUD.CloseAllCorners();
         }
         if (InputProfile.active.Pressed("GRAB"))
         {
             this._desiredTransition = DoorTransition.Album;
             HUD.CloseAllCorners();
         }
         if ((double)this._slideTo != 0.0 && (double)this._slide != (double)this._slideTo)
         {
             this._slide = Lerp.Float(this._slide, this._slideTo, 0.05f);
         }
         else if ((double)this._slideTo != 0.0 && (double)this._slide == (double)this._slideTo)
         {
             this._slide   = 0.0f;
             this._slideTo = 0.0f;
             SFX.Play("textLetter", 0.7f);
             this._selectorPosition = this._desiredSelectorPosition;
             if (this._profiles.Count > 0)
             {
                 this._profile = this._profiles[this._selectorPosition];
             }
         }
     }
     base.Update();
 }
 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();
 }
示例#28
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);
 }
        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  = 40f;
            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("RIGHT"))
                {
                    duck.leaving     = true;
                    this._leaveLeft  = false;
                    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()
 {
     if (!UIMenu.globalUILock && this._isMenu && !this._close)
     {
         bool flag = false;
         if (this._vertical)
         {
             if (!this._animating && Input.Pressed("UP"))
             {
                 --this._selection;
                 flag = true;
             }
             if (!this._animating && Input.Pressed("DOWN"))
             {
                 ++this._selection;
                 flag = true;
             }
         }
         else
         {
             if (!this._animating && Input.Pressed("LEFT"))
             {
                 --this._selection;
                 flag = true;
             }
             if (!this._animating && Input.Pressed("RIGHT"))
             {
                 ++this._selection;
                 flag = true;
             }
         }
         if (this._backButton != null && !this._animating && Input.Pressed("QUACK"))
         {
             this._backButton.Activate("SELECT");
         }
         List <UIComponent> list = this._components.Where <UIComponent>((Func <UIComponent, bool>)(val => val is UIMenuItem)).ToList <UIComponent>();
         if (this._selection >= list.Count)
         {
             this._selection = 0;
         }
         else if (this._selection < 0)
         {
             this._selection = list.Count - 1;
         }
         if (flag)
         {
             SFX.Play("textLetter", 0.7f);
         }
         this._hoverControlString = (string)null;
         for (int index = 0; index < list.Count; ++index)
         {
             UIMenuItem uiMenuItem = list[index] as UIMenuItem;
             uiMenuItem.selected = index == this._selection;
             if (index == this._selection)
             {
                 this._hoverControlString = uiMenuItem.controlString;
                 if (uiMenuItem.isEnabled)
                 {
                     if (!this._animating && (Input.Pressed("SELECT") || Input.Pressed("SHOOT") || Input.Pressed("START")))
                     {
                         uiMenuItem.Activate("SELECT");
                         SFX.Play("rockHitGround", 0.7f);
                     }
                     else if (!this._animating && Input.Pressed("GRAB"))
                     {
                         uiMenuItem.Activate("GRAB");
                     }
                     else if (!this._animating && Input.Pressed("LEFT"))
                     {
                         uiMenuItem.Activate("LEFT");
                     }
                     else if (!this._animating && Input.Pressed("RIGHT"))
                     {
                         uiMenuItem.Activate("RIGHT");
                     }
                 }
             }
         }
     }
     base.Update();
 }