public static void Update() { if (Vote._voteButton != "") { foreach (Profile who in Profiles.all.Where <Profile>((Func <Profile, bool>)(x => x.team != null))) { if (who.inputProfile != null && who.inputProfile.Pressed(Vote._voteButton)) { Vote.RegisterVote(who, VoteType.Skip); } } } if (!Vote._votes.Exists((Predicate <RegisteredVote>)(x => x.open && (double)x.slide < 0.899999976158142))) { foreach (RegisteredVote vote in Vote._votes) { if (vote.doClose) { vote.open = false; } } } foreach (RegisteredVote vote in Vote._votes) { vote.slide = Lerp.FloatSmooth(vote.slide, vote.open ? 1f : -0.1f, 0.1f, 1.1f); vote.wobble = Lerp.Float(vote.wobble, 0.0f, 0.05f); vote.wobbleInc += 0.5f; } Vote._votes.RemoveAll((Predicate <RegisteredVote>)(x => !x.open && (double)x.slide < 0.00999999977648258)); }
public override void Update() { if (!this._skip && Vote.Passed(VoteType.Skip)) { this._skip = true; } if (this._skip) { this._fadeOut = true; } DuckGame.Graphics.fade = Lerp.Float(DuckGame.Graphics.fade, this._fadeOut ? 0.0f : 1f, 0.02f); if ((double)DuckGame.Graphics.fade < 0.00999999977648258 && this._skip) { HighlightLevel.didSkip = true; Vote.CloseVoting(); Level.current = !Main.isDemo ? (Level) new RockScoreboard(RockScoreboard.returnLevel, ScoreBoardMode.ShowWinner, true) : (Level) new HighlightLevel(true); } if (!this._showHighlight && (double)DuckGame.Graphics.fade > 0.949999988079071) { this._waitToShow -= 0.02f; if ((double)this._waitToShow <= 0.0) { this._waitToShow = 0.0f; this._fadeOut = true; } } if ((double)DuckGame.Graphics.fade < 0.00999999977648258 && !this._showHighlight && this._fadeOut) { this._fadeOut = false; this._showHighlight = true; } if (this._showHighlight && (double)DuckGame.Graphics.fade > 0.949999988079071) { this._keepPaused -= 0.03f; } if (!this._highlights[this._currentHighlight].finished) { return; } this._endWait -= 0.03f; if ((double)this._endWait > 0.0) { return; } this._fadeOut = true; if ((double)DuckGame.Graphics.fade >= 0.00999999977648258) { return; } int highlight = this._currentHighlight - 1; if (this._currentHighlight == 0) { Level.current = (Level) new HighlightLevel(true); } else { Level.current = (Level) new HighlightPlayback(highlight); } }
public override void Update() { base.Update(); this._shakeInc += 0.8f; this._shakeMult = Lerp.Float(this._shakeMult, 0.0f, 0.05f); if (this._alternate == 0) { foreach (FluidStream hole in this._holes) { hole.onFire = this.onFire; hole.hSpeed = this.hSpeed; hole.vSpeed = this.vSpeed; hole.DoUpdate(); hole.position = this.Offset(hole.offset); hole.sprayAngle = this.OffsetLocal(hole.startSprayAngle); float num1 = (float) (1.0 - ((double) hole.offset.y - (double) this.topLocal) / ((double) this.bottomLocal - (double) this.topLocal)); if ((double) hole.x > (double) this.left - 2.0 && (double) hole.x < (double) this.right + 2.0 && (double) num1 < (double) this._fluidLevel) { float num2 = Maths.Clamp(this._fluidLevel - num1, 0.1f, 1f) * 0.0012f * hole.holeThickness; FluidData fluid = this._fluid; fluid.amount = num2; hole.Feed(fluid); this._fluidLevel -= num2; } } } this.weight = this._fluidLevel * 10f; ++this._alternate; if (this._alternate <= 4) return; this._alternate = 0; }
public override void Update() { if (this._mode != null) { this._mode.DoUpdate(); } if (this._level == "RANDOM") { if (this.wait < 4) { ++this.wait; } if (this.wait == 4) { ++this.wait; foreach (AutoBlock autoBlock in this.things[typeof(AutoBlock)]) { autoBlock.PlaceBlock(); } foreach (AutoPlatform autoPlatform in this.things[typeof(AutoPlatform)]) { autoPlatform.PlaceBlock(); autoPlatform.UpdateNubbers(); } foreach (BlockGroup blockGroup in this.things[typeof(BlockGroup)]) { foreach (Block block in blockGroup.blocks) { if (block is AutoBlock) { (block as AutoBlock).PlaceBlock(); } } } } } if (this._showInfo && !GameMode.started) { this._infoSlide = Lerp.Float(this._infoSlide, 1f, 0.06f); if ((double)this._infoSlide > 0.949999988079071) { this._infoWait += Maths.IncFrameTimer(); if ((double)this._infoWait > 2.5) { this._showInfo = false; } } } else { this._infoSlide = Lerp.Float(this._infoSlide, 0.0f, 0.1f); } base.Update(); }
public override void Update() { bool hover = this.hover; Duck duck = Level.Nearest <Duck>(this.x, this.y); this.hover = duck != null && (double)(duck.position - (this.position + new Vec2(8f, 0.0f))).length < 16.0; if (!hover && this.hover) { HUD.AddCornerControl(HUDCorner.BottomRight, "@SHOOT@PROFILE"); } else if (hover && !this.hover) { HUD.CloseAllCorners(); } this._consoleFade = Lerp.Float(this._consoleFade, this.hover ? 1f : 0.0f, 0.1f); base.Update(); }
public override void Update() { if (this._fade) { Graphics.fade = Lerp.Float(Graphics.fade, 0.0f, 0.02f); if ((double)Graphics.fade > 0.0) { return; } Main.isDemo = this._demo; Level.current = (Level) new TitleScreen(); } else { Graphics.fade = Lerp.Float(Graphics.fade, 1f, 0.02f); this._wave += 0.1f; if (Input.Pressed("UP")) { this._buy = true; SFX.Play("textLetter", 0.9f); } if (Input.Pressed("DOWN")) { this._buy = false; SFX.Play("textLetter", 0.9f); } if (!Input.Pressed("SELECT")) { return; } if (this._buy) { this._fade = true; this._demo = false; } else { this._fade = true; this._demo = true; } SFX.Play("rockHitGround", 0.9f); } }
public override void Draw() { base.Draw(); if (this._ruined) { return; } this._frame.depth = this.depth + 1; Graphics.Draw(this._frame, this.x, this.y); this._channels.alpha = Lerp.Float(this._channels.alpha, this.owner != null ? 1f : 0.0f, 0.1f); this._channels.depth = this.depth + 4; this._channels.frame = this.channel ? 1 : 0; Graphics.Draw((Sprite)this._channels, this.x - 4f, this.y - 4f); if (this.owner != null) { Vec2 p1 = Vec2.Zero; bool flag = false; foreach (Vec2 p2 in this.trail) { if (!flag) { flag = true; } else { Graphics.DrawTexturedLine(this._rainbow.texture, p1, p2, Color.White, depth: (new Depth(0.1f))); } p1 = p2; } } if (this._switchFrames > 0) { this._tvNoise.alpha = 1f; } else { this._tvNoise.alpha = 0.2f; } this._tvNoise.depth = this.depth + 8; Graphics.Draw((Sprite)this._tvNoise, this.x - 4f, this.y - 4f); }
public override void Apply() { if (DuckGame.Graphics.device.Textures[0] != null) { Tex2D texture = (Tex2D)(DuckGame.Graphics.device.Textures[0] as Texture2D); this.SetValue("width", texture.frameWidth / (float)texture.width); this.SetValue("height", texture.frameHeight / (float)texture.height); this.SetValue("frameWidth", texture.frameWidth); this.SetValue("amount", this.amount); this.SetValue("yoff", this.yoffset); this.SetValue("xpos", this._thing.x); this.SetValue("ypos", this._thing.y); } DuckGame.Graphics.device.Textures[1] = (Texture)(Texture2D)this._goldTexture; DuckGame.Graphics.device.SamplerStates[1] = SamplerState.PointWrap; foreach (EffectPass pass in this._effect.effect.CurrentTechnique.Passes) { pass.Apply(); } if (this.lockframes > 0) { --this.lockframes; } else { if ((double)Rando.Float(1f) > 0.850000023841858) { this.lockframes = Rando.Int(2, 12); } if ((double)Rando.Float(1f) > 0.200000002980232) { this.amount = Lerp.Float(this.amount, 0.0f, 0.05f); } if ((double)Rando.Float(1f) <= 0.980000019073486) { return; } this.amount += 0.3f; } }
public override void Draw() { this._move = Lerp.Float(this._move, 0.0f, 0.04f); if ((double)this._move <= 0.00999999977648258) { this._move += 1.570796f; } if ((double)this._length > (double)this.dist) { this.show = false; } this._alphaFade = Lerp.Float(this._alphaFade, this.show ? 1f : 0.0f, 0.1f); this._length = this._startLength * (float)Math.Sin((double)this._move); this.alpha = (float)(1.0 - (double)this._length / (double)this._startLength) * this._alphaFade; if ((double)this.alpha < 0.00999999977648258) { return; } this.position = this._attach.barrelPosition + this._attach.barrelVector * this._length; Vec2 vec2 = this._attach.barrelVector.Rotate(Maths.DegToRad(90f), Vec2.Zero); Graphics.DrawLine(this.position + vec2 * 7f, this.position - vec2 * 7f, Color.Blue * this.alpha, (float)(1.0 + (1.0 - (double)this._length / (double)this._startLength) * 4.0), new Depth(0.9f)); }
public override void Update() { if (this._playSwipe) { this._transitionWait += 0.02f; if ((double)this._transitionWait > 1.0) { this._doTransition = true; } if ((double)this._slideOutWait < 1.0) { this._duckLerp = Lerp.FloatSmooth(this._duckLerp, 1f, 0.1f, 1.1f); this._channelLerp = Lerp.FloatSmooth(this._channelLerp, 1f, 0.1f, 1.1f); this._fiveLerp = Lerp.FloatSmooth(this._fiveLerp, 1f, 0.1f, 1.1f); this._slideOutWait += 0.012f; } else { this._duckLerp = Lerp.FloatSmooth(this._duckLerp, 0.0f, 0.1f, 1.1f); this._channelLerp = Lerp.FloatSmooth(this._channelLerp, 0.0f, 0.1f, 1.1f); this._fiveLerp = Lerp.FloatSmooth(this._fiveLerp, 0.0f, 0.1f, 1.1f); if ((double)this._duckLerp < 0.00999999977648258) { this._playSwipe = false; } } for (int index = 0; index < this._swipeLines.Count; ++index) { this._swipeLines[index] = Lerp.Float(this._swipeLines[index], 1f, this._swipeSpeeds[index]); } } else { this._doTransition = false; } }
public override void 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); }
// Token: 0x06000CCA RID: 3274 public override void Update() { base.Update(); if (this._swordSwing.finished) { this._swordSwing.speed = 0f; } if (this._hitWait > 0) { this._hitWait--; } this._framesExisting++; if (this._framesExisting > 100) { this._framesExisting = 100; } if (Math.Abs(this.hSpeed) + Math.Abs(this.vSpeed) > 4f && this._framesExisting > 10) { this._wasLifted = true; } if (this.owner != null) { this._hold = -0.4f; this._wasLifted = true; this.center = new Vec2(4f, 21f); this._framesSinceThrown = 0; } else { if (this._framesSinceThrown == 1) { this._throwSpin = Maths.RadToDeg(this.angle) - 90f; this._hold = 0f; this._swing = 0f; } if (this._wasLifted) { base.angleDegrees = 90f + this._throwSpin; this.center = new Vec2(4f, 11f); } this._volatile = false; bool spinning = false; bool againstWall = false; if (Math.Abs(this.hSpeed) + Math.Abs(this.vSpeed) > 2f || !base.grounded) { if (!base.grounded && Level.CheckRect <Block>(this.position + new Vec2(-6f, -6f), this.position + new Vec2(6f, -2f), null) != null) { againstWall = true; if (this.vSpeed > 4f) { this._volatile = true; } } if (!againstWall && !this._grounded && Level.CheckPoint <IPlatform>(this.position + new Vec2(0f, 8f), null, null) == null) { if (this.hSpeed > 0f) { this._throwSpin += (Math.Abs(this.hSpeed) + Math.Abs(this.vSpeed)) * 2f + 4f; } else { this._throwSpin -= (Math.Abs(this.hSpeed) + Math.Abs(this.vSpeed)) * 2f + 4f; } spinning = true; } } if (this._framesExisting > 15 && Math.Abs(this.hSpeed) + Math.Abs(this.vSpeed) > 3f) { this._volatile = true; } if (!spinning || againstWall) { this._throwSpin %= 360f; if (againstWall) { if (Math.Abs(this._throwSpin - 90f) < Math.Abs(this._throwSpin + 90f)) { this._throwSpin = Lerp.Float(this._throwSpin, 90f, 16f); } else { this._throwSpin = Lerp.Float(-90f, 0f, 16f); } } else if (this._throwSpin > 90f && this._throwSpin < 270f) { this._throwSpin = Lerp.Float(this._throwSpin, 180f, 14f); } else { if (this._throwSpin > 180f) { this._throwSpin -= 360f; } else if (this._throwSpin < -180f) { this._throwSpin += 360f; } this._throwSpin = Lerp.Float(this._throwSpin, 0f, 14f); } } if (this._volatile && this._hitWait == 0) { (this.Offset(base.barrelOffset) - this.position).Normalize(); this.Offset(base.barrelOffset); bool rebound = false; foreach (Thing thing in Level.current.things[typeof(Sword)]) { Sword s = (Sword)thing; if (s != this && s.owner != null && s._crouchStance && !s._jabStance && !s._jabStance && ((this.hSpeed > 0f && s.x > base.x - 4f) || (this.hSpeed < 0f && s.x < base.x + 4f)) && Collision.LineIntersect(this.barrelStartPos, base.barrelPosition, s.barrelStartPos, s.barrelPosition)) { this.Shing(); s.Shing(); s.owner.hSpeed += (float)this.offDir * 1f; s.owner.vSpeed -= 1f; rebound = true; this._hitWait = 4; this.hSpeed = -this.hSpeed * 0.6f; } } int waitFrames = 12; if (!rebound) { foreach (Thing thing2 in Level.current.things[typeof(Chainsaw)]) { Chainsaw s2 = (Chainsaw)thing2; if (s2.owner != null && s2.throttle && Collision.LineIntersect(this.barrelStartPos, base.barrelPosition, s2.barrelStartPos, s2.barrelPosition)) { this.Shing(); s2.Shing(this); s2.owner.hSpeed += (float)this.offDir * 1f; s2.owner.vSpeed -= 1f; rebound = true; this.hSpeed = -this.hSpeed * 0.6f; this._hitWait = 4; if (Recorder.currentRecording != null) { Recorder.currentRecording.LogBonus(); } } } if (!rebound) { Helmet helmetHit = Level.CheckLine <Helmet>(this.barrelStartPos, base.barrelPosition, null); if (helmetHit != null && helmetHit.equippedDuck != null && (helmetHit.owner != base.prevOwner || (int)this._framesSinceThrown > waitFrames)) { this.hSpeed = -this.hSpeed * 0.6f; this.Shing(); rebound = true; this._hitWait = 4; } else { ChestPlate chestHit = Level.CheckLine <ChestPlate>(this.barrelStartPos, base.barrelPosition, null); if (chestHit != null && chestHit.equippedDuck != null && (chestHit.owner != base.prevOwner || (int)this._framesSinceThrown > waitFrames)) { this.hSpeed = -this.hSpeed * 0.6f; this.Shing(); rebound = true; this._hitWait = 4; } } } } if (!rebound && base.isServerForObject) { foreach (IAmADuck d in Level.CheckLineAll <IAmADuck>(this.barrelStartPos, base.barrelPosition)) { if (d != base.duck) { MaterialThing realThing = d as MaterialThing; if (realThing != null && (realThing != base.prevOwner || (int)this._framesSinceThrown > waitFrames)) { realThing.Destroy(new DTImpale(this)); if (Recorder.currentRecording != null) { Recorder.currentRecording.LogBonus(); } } } } } } } if (this.owner == null) { this._swinging = false; this._jabStance = false; this._crouchStance = false; this._pullBack = false; this._swung = false; this._shing = false; this._swing = 0f; this._swingPress = false; this._slamStance = false; this._unslam = 0; } if (base.isServerForObject) { if (this._unslam > 1) { this._unslam--; this._slamStance = true; } else if (this._unslam == 1) { this._unslam = 0; this._slamStance = false; } if (this._pullBack) { if (base.duck != null) { if (this._jabStance) { this._pullBack = false; this._swinging = true; } else { this._swinging = true; this._pullBack = false; } } } else if (this._swinging) { if (this._jabStance) { this._addOffsetX = MathHelper.Lerp(this._addOffsetX, 3f, 0.4f); if (this._addOffsetX > 2f && !this.action) { this._swinging = false; } } else if (base.raised) { this._swing = MathHelper.Lerp(this._swing, -2.8f, 0.2f); if (this._swing < -2.4f && !this.action) { this._swinging = false; this._swing = 1.8f; } } else { this._swing = MathHelper.Lerp(this._swing, 2.1f, 0.4f); if (this._swing > 1.8f && !this.action) { this._swinging = false; this._swing = 1.8f; } } } else { if (!this._swinging && (!this._swingPress || this._shing || (this._jabStance && this._addOffsetX < 1f) || (!this._jabStance && this._swing < 1.6f))) { if (this._jabStance) { this._swing = MathHelper.Lerp(this._swing, 1.75f, 0.4f); if (this._swing > 1.55f) { this._swing = 1.55f; this._shing = false; this._swung = false; } this._addOffsetX = MathHelper.Lerp(this._addOffsetX, -12f, 0.45f); if (this._addOffsetX < -12f) { this._addOffsetX = -12f; } this._addOffsetY = MathHelper.Lerp(this._addOffsetY, -4f, 0.35f); if (this._addOffsetX < -3f) { this._addOffsetY = -3f; } } else if (this._slamStance) { this._swing = MathHelper.Lerp(this._swing, 3.14f, 0.8f); if (this._swing > 3.1f && this._unslam == 0) { this._swing = 3.14f; this._shing = false; this._swung = true; } this._addOffsetX = MathHelper.Lerp(this._addOffsetX, -5f, 0.45f); if (this._addOffsetX < -4.6f) { this._addOffsetX = -5f; } this._addOffsetY = MathHelper.Lerp(this._addOffsetY, -6f, 0.35f); if (this._addOffsetX < -5.5f) { this._addOffsetY = -6f; } } else { this._swing = MathHelper.Lerp(this._swing, -0.22f, 0.36f); this._addOffsetX = MathHelper.Lerp(this._addOffsetX, 1f, 0.2f); if (this._addOffsetX > 0f) { this._addOffsetX = 0f; } this._addOffsetY = MathHelper.Lerp(this._addOffsetY, 1f, 0.2f); if (this._addOffsetY > 0f) { this._addOffsetY = 0f; } } } if ((this._swing < 0f || this._jabStance) && this._swing < 0f) { this._swing = 0f; this._shing = false; this._swung = false; } } } if (base.duck != null) { this.collisionOffset = new Vec2(-4f, 0f); this.collisionSize = new Vec2(4f, 4f); if (this._crouchStance && !this._jabStance) { this.collisionOffset = new Vec2(-2f, -19f); this.collisionSize = new Vec2(4f, 16f); this.thickness = 3f; } this._swingPress = false; if (!this._pullBack && !this._swinging) { this._crouchStance = false; this._jabStance = false; if (base.duck.crouch) { if (!this._pullBack && !this._swinging && base.duck.inputProfile.Down((this.offDir > 0) ? "LEFT" : "RIGHT")) { this._jabStance = true; } this._crouchStance = true; } if (!this._crouchStance || this._jabStance) { this._slamStance = false; } } if (!this._crouchStance) { this._hold = -0.4f; this.handOffset = new Vec2(this._addOffsetX, this._addOffsetY); this._holdOffset = new Vec2(-4f + this._addOffsetX, 4f + this._addOffsetY); } else { this._hold = 0f; this._holdOffset = new Vec2(0f + this._addOffsetX, 4f + this._addOffsetY); this.handOffset = new Vec2(3f + this._addOffsetX, this._addOffsetY); } } else { this.collisionOffset = new Vec2(-2f, -16f); this.collisionSize = new Vec2(4f, 18f); if (this._wasLifted) { this.collisionOffset = new Vec2(-4f, -2f); this.collisionSize = new Vec2(8f, 4f); } this.thickness = 0f; } if ((this._swung || this._swinging) && !this._shing) { (this.Offset(base.barrelOffset) - this.position).Normalize(); this.Offset(base.barrelOffset); IEnumerable <IAmADuck> hit2 = Level.CheckLineAll <IAmADuck>(this.barrelStartPos, base.barrelPosition); Block wallHit = Level.CheckLine <Block>(this.barrelStartPos, base.barrelPosition, null); if (wallHit != null && !this._slamStance) { if (this.offDir < 0 && wallHit.x > base.x) { wallHit = null; } else if (this.offDir > 0 && wallHit.x < base.x) { wallHit = null; } } bool clashed = false; if (wallHit != null) { this.Shing(); if (this._slamStance) { this._swung = false; this._unslam = 20; this.owner.vSpeed = -5f; } if (wallHit is Window) { wallHit.Destroy(new DTImpact(this)); } } else if (!this._jabStance && !this._slamStance) { Thing ignore = null; if (base.duck != null) { ignore = base.duck.GetEquipment(typeof(Helmet)); } Vec2 barrel = base.barrelPosition + base.barrelVector * 3f; Vec2 p3 = new Vec2((this.position.x < barrel.x) ? this.position.x : barrel.x, (this.position.y < barrel.y) ? this.position.y : barrel.y); Vec2 p2 = new Vec2((this.position.x > barrel.x) ? this.position.x : barrel.x, (this.position.y > barrel.y) ? this.position.y : barrel.y); QuadLaserBullet laserHit = Level.CheckRect <QuadLaserBullet>(p3, p2, null); if (laserHit != null) { this.Shing(); base.Fondle(laserHit); laserHit.safeFrames = 8; laserHit.safeDuck = base.duck; Vec2 travel = laserHit.travel; float mag = travel.length; float mul = 1f; if (this.offDir > 0 && travel.x < 0f) { mul = 1.5f; } else if (this.offDir < 0 && travel.x > 0f) { mul = 1.5f; } if (this.offDir > 0) { travel = new Vec2(mag * mul, 0f); } else { travel = new Vec2(-mag * mul, 0f); } laserHit.travel = travel; } else { Helmet helmetHit2 = Level.CheckLine <Helmet>(this.barrelStartPos, base.barrelPosition, ignore); if (helmetHit2 != null && helmetHit2.equippedDuck != null) { this.Shing(); helmetHit2.owner.hSpeed += (float)this.offDir * 3f; helmetHit2.owner.vSpeed -= 2f; helmetHit2.duck.crippleTimer = 1f; helmetHit2.Hurt(0.53f); clashed = true; } else { if (base.duck != null) { ignore = base.duck.GetEquipment(typeof(ChestPlate)); } ChestPlate chestHit2 = Level.CheckLine <ChestPlate>(this.barrelStartPos, base.barrelPosition, ignore); if (chestHit2 != null && chestHit2.equippedDuck != null) { this.Shing(); chestHit2.owner.hSpeed += (float)this.offDir * 3f; chestHit2.owner.vSpeed -= 2f; chestHit2.duck.crippleTimer = 1f; chestHit2.Hurt(0.53f); clashed = true; } } } } if (!clashed) { foreach (Thing thing3 in Level.current.things[typeof(Sword)]) { Sword s3 = (Sword)thing3; if (s3 != this && s3.duck != null && !this._jabStance && !s3._jabStance && base.duck != null && Collision.LineIntersect(this.barrelStartPos, base.barrelPosition, s3.barrelStartPos, s3.barrelPosition)) { this.Shing(); s3.Shing(); s3.owner.hSpeed += (float)this.offDir * 3f; s3.owner.vSpeed -= 2f; base.duck.hSpeed += -(float)this.offDir * 3f; base.duck.vSpeed -= 2f; s3.duck.crippleTimer = 1f; base.duck.crippleTimer = 1f; clashed = true; } } } if (clashed) { return; } using (IEnumerator <IAmADuck> enumerator5 = hit2.GetEnumerator()) { while (enumerator5.MoveNext()) { IAmADuck d2 = enumerator5.Current; if (d2 != base.duck) { MaterialThing realThing2 = d2 as MaterialThing; if (realThing2 != null) { realThing2.Destroy(new DTImpale(this)); } } } return; } } if (this._crouchStance && base.duck != null) { foreach (IAmADuck d3 in Level.CheckLineAll <IAmADuck>(this.barrelStartPos, base.barrelPosition)) { if (d3 != base.duck) { MaterialThing realThing3 = d3 as MaterialThing; if (realThing3 != null) { if (realThing3.vSpeed > 0.5f && realThing3.bottom < this.position.y - 8f && realThing3.left < base.barrelPosition.x && realThing3.right > base.barrelPosition.x) { realThing3.Destroy(new DTImpale(this)); } else if (!this._jabStance && !realThing3.destroyed && ((this.offDir > 0 && realThing3.x > base.duck.x) || (this.offDir < 0 && realThing3.x < base.duck.x))) { if (realThing3 is Duck) { (realThing3 as Duck).crippleTimer = 1f; } else if ((base.duck.x > realThing3.x && realThing3.hSpeed > 1.5f) || (base.duck.x < realThing3.x && realThing3.hSpeed < -1.5f)) { realThing3.Destroy(new DTImpale(this)); } base.Fondle(realThing3); realThing3.hSpeed = (float)this.offDir * 3f; realThing3.vSpeed = -2f; } } } } } }
public void Update() { if (this._done && !Level.current._waitingOnTransition) { Layer.doVirtualEffect = false; if (this._realBackground == null) { return; } Level.activeLevel.backgroundColor = this._realBackground.backgroundColor; this._realBackground.scissor = new Rectangle(0.0f, 0.0f, (float)Graphics.width, (float)Graphics.height); this._realBackground = (BackgroundUpdater)null; } else { if (Level.current._waitingOnTransition) { this._realBackground = (BackgroundUpdater)null; } if (this._realBackground == null) { using (IEnumerator <Thing> enumerator = Level.activeLevel.things[typeof(BackgroundUpdater)].GetEnumerator()) { if (enumerator.MoveNext()) { this._realBackground = (BackgroundUpdater)enumerator.Current; } } } float num = this._stick; if (this._scanStage == 2 && this._virtualMode) { this._backgroundColor = this._curBackgroundColor; Level.activeLevel.backgroundColor = Lerp.ColorSmooth(this._backgroundColor, this._curBackgroundColor, this._stick); Layer.Glow.fade = Lerp.FloatSmooth(Layer.Glow.fade, 0.0f, this._stick); } if (this._scanStage == 0 && !this._virtualMode && this._realBackground != null) { Level.activeLevel.backgroundColor = Lerp.ColorSmooth(this._backgroundColor, this._realBackground.backgroundColor, this._stick); Layer.Glow.fade = Lerp.FloatSmooth(Layer.Glow.fade, 1f, this._stick); } if (this._scanStage == -1) { Level.activeLevel.backgroundColor = Lerp.ColorSmooth(this._backgroundColor, Color.Black, 0.1f); } if (this._scanStage < 2) { num = 0.0f; } Rectangle rectangle1 = new Rectangle((float)(int)((1.0 - (double)num) * (double)Graphics.width), 0.0f, (float)(Graphics.width - (int)((1.0 - (double)num) * (double)Graphics.width)), (float)Graphics.height); if (this._realBackground != null) { if ((double)rectangle1.width == 0.0) { this._realBackground.SetVisible(false); } else { this._realBackground.scissor = rectangle1; this._realBackground.SetVisible(true); } } Rectangle rectangle2 = new Rectangle(0.0f, 0.0f, (float)Graphics.width - rectangle1.width, (float)Graphics.height); if ((double)rectangle2.width == 0.0) { this.SetVisible(false); this._visible = false; } else { this._scissor = rectangle2; this.SetVisible(true); this._visible = true; } float amount1 = 0.04f; float amount2 = 0.06f; if (Level.activeLevel != null) { amount1 *= Level.activeLevel.transitionSpeedMultiplier; amount2 *= Level.activeLevel.transitionSpeedMultiplier; } if (!this._virtualMode) { if (this._scanStage == 0) { this._stick = Lerp.Float(this._stick, 1f, amount1); if ((double)this._stick > 0.990000009536743) { this._stick = 1f; this._incStage = true; } } else if (this._scanStage == 1) { this._stick = Lerp.Float(this._stick, 0.0f, amount1); if ((double)this._stick < 0.00999999977648258) { this._stick = 0.0f; this._incStage = true; } } else if (this._scanStage == 2) { Layer.basicWireframeEffect.effect.Parameters["screenCross"].SetValue(0.0f); if (Layer.basicWireframeTex) { Layer.basicWireframeEffect.effect.Parameters["scanMul"].SetValue(0.0f); } this._stick = Lerp.Float(this._stick, 1f, amount1); if ((double)this._stick > 0.990000009536743) { this._stick = 1f; this._incStage = true; this._done = true; } } } else if (this._scanStage == 2) { Layer.basicWireframeEffect.effect.Parameters["screenCross"].SetValue(0.0f); if (Layer.basicWireframeTex) { Layer.basicWireframeEffect.effect.Parameters["scanMul"].SetValue(0.0f); } this._stick = Lerp.Float(this._stick, 0.0f, amount2); if ((double)this._stick < 0.00999999977648258) { this._stick = 0.0f; this._decStage = true; } } else if (this._scanStage == 1) { this._stick = Lerp.Float(this._stick, 1f, amount2); if ((double)this._stick > 0.990000009536743) { this._stick = 1f; this._decStage = true; } } else if (this._scanStage == 0) { this._stick = Lerp.Float(this._stick, 0.0f, amount2); if ((double)this._stick < 0.00999999977648258) { this._stick = 0.0f; this._decStage = true; this._done = true; } } if (this._incStage) { this._incStage = false; ++this._scanStage; } if (this._decStage) { this._decStage = false; --this._scanStage; } if (this._scanStage < 2) { Layer.doVirtualEffect = true; Layer.basicWireframeTex = this._scanStage == 1; Layer.basicWireframeEffect.effect.Parameters["screenCross"].SetValue(this._stick); if (Layer.basicWireframeTex) { Layer.basicWireframeEffect.effect.Parameters["scanMul"].SetValue(1f); } } this._fullyVirtual = false; this._fullyNonVirtual = false; if (this._scanStage == 3) { this._fullyNonVirtual = true; } else if (this._scanStage == -1) { this._fullyVirtual = true; } this._lastCameraX = Level.activeLevel.camera.centerX; if ((double)this._scissor.width == 0.0) { return; } this._parallax.scissor = this._scissor; } }
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() { ++this._framesSinceFeed; this.fluidWave += 0.1f; if ((double)this.data.amount < 9.99999974737875E-05) { Level.Remove((Thing)this); } if ((double)this.collisionSize.y > 10.0) { ++this.bubbleWait; if (this.bubbleWait > Rando.Int(15, 25)) { for (int index = 0; index < (int)Math.Floor((double)this.collisionSize.x / 16.0); ++index) { if ((double)Rando.Float(1f) > 0.850000023841858) { Level.Add((Thing) new TinyBubble(this.left + (float)(index * 16) + Rando.Float(-4f, 4f), this.bottom + Rando.Float(-4f), 0.0f, this.top + 10f)); } } this.bubbleWait = 0; } foreach (PhysicsObject physicsObject in Level.CheckRectAll <PhysicsObject>(this.topLeft, this.bottomRight)) { physicsObject.sleeping = false; } } FluidPuddle fluidPuddle = Level.CheckLine <FluidPuddle>(new Vec2(this.left, this.y), new Vec2(this.right, this.y), (Thing)this); if (fluidPuddle != null && (double)fluidPuddle.data.amount < (double)this.data.amount) { fluidPuddle.active = false; float num1 = Math.Min(fluidPuddle.left, this.left); float num2 = Math.Max(fluidPuddle.right, this.right); this.x = num1 + (float)(((double)num2 - (double)num1) / 2.0); this.Feed(fluidPuddle.data); Level.Remove((Thing)fluidPuddle); } if (this._leftStream != null) { this._leftStream.Update(); this._leftStream.onFire = this.onFire; } if (this._rightStream != null) { this._rightStream.Update(); this._rightStream.onFire = this.onFire; } float distance = this.FeedAmountToDistance(this.data.amount); if ((double)this._wide == 0.0) { this._wide = 1f / 1000f; } float num = Maths.Clamp(distance / this._wide, 1f, 99999f); if (this.onFire) { this._fireRise = Lerp.FloatSmooth(this._fireRise, 1f, 0.1f, 1.2f); if (this._framesSinceFeed > 10) { FluidData data = this.data; data.amount = -1f / 1000f; this.Feed(data); if ((double)this.data.amount <= 0.0) { this.data.amount = 0.0f; this.alpha = Lerp.Float(this.alpha, 0.0f, 0.04f); } else { this.alpha = Lerp.Float(this.alpha, 1f, 0.04f); } if ((double)this.alpha <= 0.0) { Level.Remove((Thing)this); } } } else { this.alpha = Lerp.Float(this.alpha, 1f, 0.04f); if ((double)num < 3.0) { FluidData data = this.data; data.amount = -0.0001f; this.Feed(data); } } float depth = this.CalculateDepth(); if ((double)depth > 4.0 && !this._initializedUpperCorners) { this._initializedUpperCorners = true; foreach (BlockCorner groupCorner in this._block.GetGroupCorners()) { if (this._leftCorner != null && (double)groupCorner.corner.x == (double)this._leftCorner.corner.x && (double)groupCorner.corner.y < (double)this._leftCorner.corner.y) { if (this._topLeftCorner == null) { this._topLeftCorner = groupCorner; } else if ((double)groupCorner.corner.y > (double)this._topLeftCorner.corner.y) { this._topLeftCorner = groupCorner; } } else if (this._rightCorner != null && (double)groupCorner.corner.x == (double)this._rightCorner.corner.x && (double)groupCorner.corner.y < (double)this._rightCorner.corner.y) { if (this._topRightCorner == null) { this._topRightCorner = groupCorner; } else if ((double)groupCorner.corner.y > (double)this._topRightCorner.corner.y) { this._topRightCorner = groupCorner; } } } } if (this._leftStream != null) { this._leftStream.position.y = this.y - this._collisionOffset.y; } if (this._rightStream != null) { this._rightStream.position.y = this.y - this._collisionOffset.y; } this._collisionOffset.y = -depth; this._collisionSize.y = depth; }
private RockWeatherState GetWeatherState(float time, bool lerp = true) { RockWeatherState rockWeatherState1 = (RockWeatherState)null; RockWeatherState rockWeatherState2 = (RockWeatherState)null; float num1 = 0.0f; int index = 0; switch (RockWeather._weather) { case Weather.Sunny: num1 = 1f / (float)this.timeOfDayColorMultMap.Count; index = (int)((double)RockWeather._timeOfDay * (double)this.timeOfDayColorMultMap.Count); if (index >= this.timeOfDayColorMultMap.Count) { index = this.timeOfDayColorMultMap.Count - 1; } rockWeatherState1 = this.timeOfDayColorMultMap[index]; rockWeatherState2 = index + 1 <= this.timeOfDayColorMultMap.Count - 1 ? this.timeOfDayColorMultMap[index + 1] : this.timeOfDayColorMultMap[0]; break; case Weather.Snowing: num1 = 1f / (float)this.timeOfDayColorMultMapWinter.Count; index = (int)((double)RockWeather._timeOfDay * (double)this.timeOfDayColorMultMapWinter.Count); if (index >= this.timeOfDayColorMultMapWinter.Count) { index = this.timeOfDayColorMultMapWinter.Count - 1; } rockWeatherState1 = this.timeOfDayColorMultMapWinter[index]; rockWeatherState2 = index + 1 <= this.timeOfDayColorMultMapWinter.Count - 1 ? this.timeOfDayColorMultMapWinter[index + 1] : this.timeOfDayColorMultMapWinter[0]; break; case Weather.Raining: num1 = 1f / (float)this.timeOfDayColorMultMapRaining.Count; index = (int)((double)RockWeather._timeOfDay * (double)this.timeOfDayColorMultMapRaining.Count); if (index >= this.timeOfDayColorMultMapRaining.Count) { index = this.timeOfDayColorMultMapRaining.Count - 1; } rockWeatherState1 = this.timeOfDayColorMultMapRaining[index]; rockWeatherState2 = index + 1 <= this.timeOfDayColorMultMapRaining.Count - 1 ? this.timeOfDayColorMultMapRaining[index + 1] : this.timeOfDayColorMultMapRaining[0]; break; } float num2 = Maths.NormalizeSection(RockWeather._timeOfDay, num1 * (float)index, num1 * (float)(index + 1)); RockWeatherState rockWeatherState3 = new RockWeatherState(); if (this._lastAppliedState == null) { this._lastAppliedState = rockWeatherState1.Copy(); } if (lerp) { float amount = 1f / 1000f; rockWeatherState3.add = Lerp.Vec3(this._lastAppliedState.add, rockWeatherState1.add + (rockWeatherState2.add - rockWeatherState1.add) * num2, amount); rockWeatherState3.multiply = Lerp.Vec3(this._lastAppliedState.multiply, rockWeatherState1.multiply + (rockWeatherState2.multiply - rockWeatherState1.multiply) * num2, amount); rockWeatherState3.sky = Lerp.Vec3(this._lastAppliedState.sky, rockWeatherState1.sky + (rockWeatherState2.sky - rockWeatherState1.sky) * num2, amount); rockWeatherState3.lightOpacity = Lerp.Float(this._lastAppliedState.lightOpacity, rockWeatherState1.lightOpacity + (rockWeatherState2.lightOpacity - rockWeatherState1.lightOpacity) * num2, amount); rockWeatherState3.sunPos = Lerp.Vec2(this._lastAppliedState.sunPos, rockWeatherState1.sunPos + (rockWeatherState2.sunPos - rockWeatherState1.sunPos) * num2, amount); rockWeatherState3.sunGlow = Lerp.Float(this._lastAppliedState.sunGlow, rockWeatherState1.sunGlow + (rockWeatherState2.sunGlow - rockWeatherState1.sunGlow) * num2, amount); rockWeatherState3.sunOpacity = Lerp.Float(this._lastAppliedState.sunOpacity, rockWeatherState1.sunOpacity + (rockWeatherState2.sunOpacity - rockWeatherState1.sunOpacity) * num2, amount); rockWeatherState3.rainbowLight = Lerp.Float(this._lastAppliedState.rainbowLight, rockWeatherState1.rainbowLight + (rockWeatherState2.rainbowLight - rockWeatherState1.rainbowLight) * num2, amount); rockWeatherState3.rainbowLight2 = Lerp.Float(this._lastAppliedState.rainbowLight2, rockWeatherState1.rainbowLight2 + (rockWeatherState2.rainbowLight2 - rockWeatherState1.rainbowLight2) * num2, amount); } else { rockWeatherState3.add = rockWeatherState1.add + (rockWeatherState2.add - rockWeatherState1.add) * num2; rockWeatherState3.multiply = rockWeatherState1.multiply + (rockWeatherState2.multiply - rockWeatherState1.multiply) * num2; rockWeatherState3.sky = rockWeatherState1.sky + (rockWeatherState2.sky - rockWeatherState1.sky) * num2; rockWeatherState3.lightOpacity = rockWeatherState1.lightOpacity + (rockWeatherState2.lightOpacity - rockWeatherState1.lightOpacity) * num2; rockWeatherState3.sunPos = rockWeatherState1.sunPos + (rockWeatherState2.sunPos - rockWeatherState1.sunPos) * num2; rockWeatherState3.sunGlow = rockWeatherState1.sunGlow + (rockWeatherState2.sunGlow - rockWeatherState1.sunGlow) * num2; rockWeatherState3.sunOpacity = rockWeatherState1.sunOpacity + (rockWeatherState2.sunOpacity - rockWeatherState1.sunOpacity) * num2; rockWeatherState3.rainbowLight = rockWeatherState1.rainbowLight + (rockWeatherState2.rainbowLight - rockWeatherState1.rainbowLight) * num2; rockWeatherState3.rainbowLight2 = rockWeatherState1.rainbowLight2 + (rockWeatherState2.rainbowLight2 - rockWeatherState1.rainbowLight2) * num2; } this._lastAppliedState = rockWeatherState3; return(rockWeatherState3); }
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 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(); } } } } }
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() { float num = this.stick; if (this.scanStage < 2) { Level.current.backgroundColor = Lerp.Color(Level.current.backgroundColor, this.backgroundColor, 0.04f); num = 0.0f; } else if (this._realBackground != null) { Level.current.backgroundColor = Lerp.Color(Level.current.backgroundColor, this._realBackground.backgroundColor, 0.04f); } Rectangle rectangle1 = new Rectangle((float)(int)((1.0 - (double)num) * (double)Graphics.width), 0.0f, (float)(Graphics.width - (int)((1.0 - (double)num) * (double)Graphics.width)), (float)Graphics.height); if (this._realBackground != null) { if ((double)rectangle1.width == 0.0) { this._realBackground.SetVisible(false); } else { this._realBackground.scissor = rectangle1; this._realBackground.SetVisible(true); } } Rectangle rectangle2 = new Rectangle(0.0f, 0.0f, (float)Graphics.width - rectangle1.width, (float)Graphics.height); if ((double)rectangle2.width == 0.0) { this.SetVisible(false); this.visible = false; } else { this.scissor = rectangle2; this.SetVisible(true); this.visible = true; } if (this.virtualMode && this.done && this.scanStage == 3) { --this.scanStage; } else if (!this.virtualMode && !this.done && this.scanStage == -1) { ++this.scanStage; } float amount1 = 0.04f; float amount2 = 0.06f; if (Level.current != null) { amount1 *= Level.current.transitionSpeedMultiplier; amount2 *= Level.current.transitionSpeedMultiplier; } if (!this.done) { if (this.scanStage == 0) { this.stick = Lerp.Float(this.stick, 1f, amount1); if ((double)this.stick > 0.949999988079071) { this.stick = 1f; this.incStage = true; } } else if (this.scanStage == 1) { this.stick = Lerp.Float(this.stick, 0.0f, amount1); if ((double)this.stick < 0.0500000007450581) { this.stick = 0.0f; this.incStage = true; } } else if (this.scanStage == 2) { this.stick = Lerp.Float(this.stick, 1f, amount1); if ((double)this.stick > 0.949999988079071) { this.stick = 1f; this.incStage = true; this.done = true; } } } else if (this.scanStage == 2) { this.stick = Lerp.Float(this.stick, 0.0f, amount2); if ((double)this.stick < 0.0500000007450581) { this.stick = 0.0f; this.decStage = true; } } else if (this.scanStage == 1) { this.stick = Lerp.Float(this.stick, 1f, amount2); if ((double)this.stick > 0.949999988079071) { this.stick = 1f; this.decStage = true; } } else if (this.scanStage == 0) { this.stick = Lerp.Float(this.stick, 0.0f, amount2); if ((double)this.stick < 0.0500000007450581) { this.stick = 0.0f; this.decStage = true; this.done = false; } } if (this.scanStage < 2) { Layer.basicWireframeEffect.effect.Parameters["screenCross"].SetValue(this.stick); Layer.basicWireframeTex = this.scanStage == 1; } if (this.incStage) { this.incStage = false; ++this.scanStage; } if (this.decStage) { this.decStage = false; --this.scanStage; } this.fullyVirtual = false; this.fullyNonVirtual = false; if (this.scanStage == 3) { this.needsWireframe = false; this.fullyNonVirtual = true; } else { this.needsWireframe = true; if (this.scanStage == -1) { this.fullyVirtual = true; } } base.Update(); }
public override void Update() { if (RockWeather.alwaysRainbow) { RockWeather.rainbowFade = 1f; RockWeather.rainbowTime = 1f; } RockWeather.rainbowFade = Lerp.Float(RockWeather.rainbowFade, (double)RockWeather.rainbowTime > 0.0 ? 1f : 0.0f, 1f / 1000f); RockWeather.rainbowTime -= Maths.IncFrameTimer(); if (RockWeather._weather != Weather.Sunny) { RockWeather.rainbowTime -= Maths.IncFrameTimer() * 8f; } if ((double)RockWeather.rainbowTime < 0.0) { RockWeather.rainbowTime = 0.0f; } if (RockWeather.neverRainbow) { RockWeather.rainbowFade = 0.0f; } RockWeatherState weatherState = this.GetWeatherState(RockWeather._timeOfDay); this.rainbowLight = weatherState.rainbowLight * RockWeather.rainbowFade; this.rainbowLight2 = weatherState.rainbowLight2 * RockWeather.rainbowFade; this.ApplyWeatherState(weatherState); RockWeather._prevWeatherLerp = Lerp.Float(RockWeather._prevWeatherLerp, 0.0f, 0.05f); if (Network.isServer) { this.wait += 3f / 1000f; if ((double)this.wait > 1.0) { this.wait = 0.0f; if ((double)RockWeather._weatherTime > 0.100000001490116) { if ((double)RockWeather.snowChance > 0.0 && RockWeather._weather != Weather.Snowing && (double)Rando.Float(1f) > 1.0 - (double)RockWeather.snowChance) { RockWeather._prevWeatherLerp = 1f; RockWeather.sunshowers = 0.0f; RockWeather._prevWeather = RockWeather._weather; RockWeather._weather = Weather.Snowing; if (Network.isActive) { Send.Message((NetMessage) new NMChangeWeather((byte)RockWeather._weather)); } RockWeather._weatherTime = 0.0f; } if ((double)RockWeather.rainChance > 0.0 && RockWeather._weather != Weather.Raining && (double)Rando.Float(1f) > 1.0 - (double)RockWeather.rainChance) { RockWeather._prevWeatherLerp = 1f; RockWeather.sunshowers = 0.0f; RockWeather._prevWeather = RockWeather._weather; RockWeather._weather = Weather.Raining; if (Network.isActive) { Send.Message((NetMessage) new NMChangeWeather((byte)RockWeather._weather)); } RockWeather._weatherTime = 0.0f; } if (RockWeather._weather != Weather.Sunny && (double)Rando.Float(1f) > 0.980000019073486) { RockWeather._prevWeatherLerp = 1f; if (RockWeather._weather == Weather.Raining) { if ((double)RockWeather._timeRaining > 900.0 && (double)Rando.Float(1f) > 0.850000023841858 || (double)Rando.Float(1f) > 0.949999988079071) { RockWeather.rainbowTime = Rando.Float(30f, 240f); } if ((double)Rando.Float(1f) > 0.300000011920929) { RockWeather.sunshowers = Rando.Float(0.1f, 60f); } } RockWeather._timeRaining = 0.0f; RockWeather._prevWeather = RockWeather._weather; RockWeather._weather = Weather.Sunny; if (Network.isActive) { Send.Message((NetMessage) new NMChangeWeather((byte)RockWeather._weather)); } RockWeather._weatherTime = 0.0f; } } } } RockWeather.sunshowers -= Maths.IncFrameTimer(); if ((double)RockWeather.sunshowers <= 0.0) { RockWeather.sunshowers = 0.0f; } switch (RockWeather._weather) { case Weather.Snowing: while ((double)this._particleWait <= 0.0) { ++this._particleWait; SnowParticle snowParticle = new SnowParticle(new Vec2(Rando.Float(-100f, 400f), Rando.Float(-500f, -550f))); snowParticle.z = Rando.Float(0.0f, 200f); this._particles.Add((WeatherParticle)snowParticle); } this._particleWait -= 0.5f; break; case Weather.Raining: while ((double)this._particleWait <= 0.0) { ++this._particleWait; RainParticle rainParticle = new RainParticle(new Vec2(Rando.Float(-100f, 900f), Rando.Float(-500f, -550f))); rainParticle.z = Rando.Float(0.0f, 200f); this._particles.Add((WeatherParticle)rainParticle); } --this._particleWait; break; default: if ((double)RockWeather.sunshowers <= 0.0) { break; } goto case Weather.Raining; } List <WeatherParticle> weatherParticleList = new List <WeatherParticle>(); foreach (WeatherParticle particle in this._particles) { particle.Update(); if ((double)particle.position.y > 0.0) { particle.die = true; } switch (particle) { case RainParticle _ when(double) particle.z <70.0 && (double)particle.position.y> -62.0: particle.die = true; particle.position.y = -58f; break; case RainParticle _ when(double) particle.z <40.0 && (double)particle.position.y> -98.0: particle.die = true; particle.position.y = -98f; break; case RainParticle _ when(double) particle.z < 25.0 && ((double)particle.position.x > 175.0 && (double)particle.position.x < 430.0) && ((double)particle.position.y > -362.0 && (double)particle.position.y < -352.0): particle.die = true; particle.position.y = -362f; break; } if ((double)particle.alpha < 0.00999999977648258) { weatherParticleList.Add(particle); } } foreach (WeatherParticle weatherParticle in weatherParticleList) { this._particles.Remove(weatherParticle); } }
public override void Update() { if (!this.opened || this._dialog.opened || (this._deleteDialog.opened || this._overwriteDialog.opened) || this._opening) { this._opening = false; foreach (ContextMenu contextMenu in this._items) { contextMenu.disabled = true; } } else { bool flag = false; foreach (ContextMenu contextMenu in this._items) { contextMenu.disabled = false; if (!flag && contextMenu.hover) { flag = true; string str = ""; int startIndex = this._currentDirectory.IndexOf(this._rootFolder); if (startIndex != -1) { str = this._currentDirectory.Remove(startIndex, this._rootFolder.Length); } if (str != "" && !str.EndsWith("/")) { str += "/"; } if (str.StartsWith("/")) { str = str.Substring(1, str.Length - 1); } string path = str + contextMenu.data; if (this._prevPreviewPath != path) { if (path.EndsWith(".lev")) { if (this._preview == null || !(this._preview is RenderTarget2D)) { this._preview = (Tex2D) new RenderTarget2D(320, 200); } this._preview = (Tex2D)Content.GeneratePreview(path.Substring(0, path.Length - 4), this._preview as RenderTarget2D); } else if (path.EndsWith(".png")) { Texture2D texture2D = ContentPack.LoadTexture2D(this._currentDirectory + "/" + Path.GetFileName(path)); this._preview = texture2D == null ? Content.invalidTexture : (this._type != ContextFileType.Block && this._type != ContextFileType.Background && this._type != ContextFileType.Platform || texture2D.Width == 128 && texture2D.Height == 128 ? (this._type != ContextFileType.Parallax || texture2D.Width == 320 && texture2D.Height == 240 ? (this._type != ContextFileType.ArcadeStyle || texture2D.Width == 27 && texture2D.Height == 34 || texture2D.Width == 54 && texture2D.Height == 68 ? (Tex2D)texture2D : this._badArcade.texture) : this._badParallax.texture) : this._badTileset.texture); } else { this._previewSprite = (Sprite)null; this._prevPreviewPath = (string)null; } this._previewSprite = new Sprite(this._preview); if (this._type == ContextFileType.Block || this._type == ContextFileType.Background || (this._type == ContextFileType.Platform || this._type == ContextFileType.Parallax)) { this._previewSprite.scale = new Vec2(2f, 2f); } this._prevPreviewPath = path; } } } if (!flag && this._type == ContextFileType.ArcadeStyle) { this._preview = this._badArcade.texture; this._previewSprite = new Sprite(this._preview); this._prevPreviewPath = (string)null; } Editor.lockInput = (ContextMenu)this; base.Update(); this._scrollWait = Lerp.Float(this._scrollWait, 0.0f, 0.2f); if (this._dialog.result != null && this._dialog.result != "") { Editor current = Level.current as Editor; current._guid = Guid.NewGuid().ToString(); Editor.ResetWorkshopData(); current.DoSave(this._currentDirectory + "/" + this._dialog.result); this._dialog.result = ""; this.Close(); } if (!this._overwriteDialog.opened && this._doOverwriteDialog) { this._doOverwriteDialog = false; if (this._overwriteDialog.result) { (Level.current as Editor).DoSave(this._currentDirectory + "/" + this._overwriteName); this._overwriteDialog.result = false; this._overwriteName = ""; this.Close(); } } if (!this._deleteDialog.opened && this._doDeleteDialog) { this._doDeleteDialog = false; if (this._deleteDialog.result) { foreach (ContextMenu contextMenu in this._items) { if (contextMenu.hover) { Editor.Delete(this._currentDirectory + "/" + contextMenu.text); break; } } this.ClearItems(); this.SetDirectory(this._currentDirectory); } } if (Keyboard.Pressed(Keys.Escape) || Mouse.right == InputState.Pressed || Input.Pressed("QUACK")) { this.Close(); } if (!this._selectLevels && Input.Pressed("GRAB")) { this._deleteDialog.Open("CONFIRM DELETE"); Editor.lockInput = (ContextMenu)this._deleteDialog; this._doDeleteDialog = true; this._deleteDialog.result = false; } else { if (Input.Pressed("LEFT")) { this._selectedIndex -= this._maxItems; } else if (Input.Pressed("RIGHT")) { this._selectedIndex += this._maxItems; } this._selectedIndex = Maths.Clamp(this._selectedIndex, 0, this._items.Count - 1); if (this._items.Count <= this._maxItems) { return; } float num1 = 1f / (float)(this._items.Count - this._maxItems); if ((double)Mouse.scroll != 0.0) { this._scrollPosition += (float)Math.Sign(Mouse.scroll) * num1; if ((double)this._scrollPosition > 1.0) { this._scrollPosition = 1f; } if ((double)this._scrollPosition < 0.0) { this._scrollPosition = 0.0f; } } int num2 = (int)Math.Round(((double)(this._items.Count - this._maxItems) - 1.0) * (double)this._scrollPosition); int num3 = 0; int num4 = 0; for (int index = 0; index < this._items.Count; ++index) { if (this._items[index].hover) { num4 = index; break; } } if (Editor.gamepadMode) { if (num4 > num2 + this._maxItems) { this._scrollPosition += (float)(num4 - (num2 + this._maxItems)) * num1; } else if (num4 < num2) { this._scrollPosition -= (float)(num2 - num4) * num1; } } for (int index = 0; index < this._items.Count; ++index) { this._items[index].disabled = false; if (index < num2 || index > num2 + this._maxItems) { this._items[index].visible = false; this._items[index].hover = false; } else { ContextMenu contextMenu = this._items[index]; this._items[index].visible = true; this._items[index].position = new Vec2(this._items[index].position.x, (float)((double)this.y + 3.0 + (double)num3 * (double)this._items[index].itemSize.y)); ++num3; } } } } }
public override void 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 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(); }
public override void Draw() { this.menuSize.y = this._fdHeight; if (!this.opened) { return; } base.Draw(); float num1 = 350f; float num2 = this._fdHeight + 22f; Vec2 p1_1 = new Vec2((float)((double)this.layer.width / 2.0 - (double)num1 / 2.0) + this.hOffset, (float)((double)this.layer.height / 2.0 - (double)num2 / 2.0 - 15.0)); Vec2 p2_1 = new Vec2((float)((double)this.layer.width / 2.0 + (double)num1 / 2.0) + this.hOffset, (float)((double)this.layer.height / 2.0 + (double)num2 / 2.0 - 12.0)); DuckGame.Graphics.DrawRect(p1_1, p2_1, new Color(70, 70, 70), this.depth, false); DuckGame.Graphics.DrawRect(p1_1, p2_1, new Color(30, 30, 30), this.depth - 8); DuckGame.Graphics.DrawRect(p1_1 + new Vec2(4f, 23f), p2_1 + new Vec2(-16f, -4f), new Color(10, 10, 10), this.depth - 4); Vec2 p1_2 = new Vec2(p2_1.x - 14f, p1_1.y + 23f); Vec2 p2_2 = p2_1 + new Vec2(-4f, -4f); DuckGame.Graphics.DrawRect(p1_2, p2_2, new Color(10, 10, 10), this.depth - 4); DuckGame.Graphics.DrawRect(p1_1 + new Vec2(3f, 3f), new Vec2(p2_1.x - 3f, p1_1.y + 19f), new Color(70, 70, 70), this.depth - 4); if (this._scrollBar) { this._scrollLerp = Lerp.Float(this._scrollLerp, this._scrollPosition, 0.05f); Vec2 p1_3 = new Vec2(p2_1.x - 12f, (float)((double)this.topRight.y + 7.0 + (240.0 * (double)this._scrollLerp - 4.0))); Vec2 p2_3 = new Vec2(p2_1.x - 6f, (float)((double)this.topRight.y + 11.0 + (240.0 * (double)this._scrollLerp + 8.0))); bool flag = false; if ((double)Mouse.x > (double)p1_3.x && (double)Mouse.x < (double)p2_3.x && ((double)Mouse.y > (double)p1_3.y && (double)Mouse.y < (double)p2_3.y)) { flag = true; if (Mouse.left == InputState.Pressed) { this.drag = true; } } if (Mouse.left == InputState.None) { this.drag = false; } if (this.drag) { this._scrollPosition = (float)(((double)Mouse.y - (double)p1_2.y - 10.0) / ((double)p2_2.y - (double)p1_2.y - 20.0)); if ((double)this._scrollPosition < 0.0) { this._scrollPosition = 0.0f; } if ((double)this._scrollPosition > 1.0) { this._scrollPosition = 1f; } this._scrollLerp = this._scrollPosition; } DuckGame.Graphics.DrawRect(p1_3, p2_3, this.drag ? new Color(190, 190, 190) : (flag ? new Color(120, 120, 120) : new Color(70, 70, 70)), this.depth + 4); } string str1 = this._currentDirectory; int startIndex1 = this._currentDirectory.IndexOf(this._rootFolder); if (startIndex1 != -1) { str1 = this._currentDirectory.Remove(startIndex1, this._rootFolder.Length); } string str2 = Path.GetFileName(this._rootFolder) + str1; if (str2 == "") { str2 = this._type != ContextFileType.Block ? (this._type != ContextFileType.Platform ? (this._type != ContextFileType.Background ? (this._type != ContextFileType.Parallax ? (this._type != ContextFileType.ArcadeStyle ? "LEVELS" : "Custom/Arcade") : "Custom/Parallax") : "Custom/Background") : "Custom/Platform") : "Custom/Blocks"; } if (this._save) { DuckGame.Graphics.DrawString("@SAVEICON@Save Level - " + str2, p1_1 + new Vec2(5f, 7f), Color.White, this.depth + 8); } else if (this._selectLevels) { DuckGame.Graphics.DrawString("Select Active Levels - " + str2, p1_1 + new Vec2(5f, 7f), Color.White, this.depth + 8); } else if (this._type == ContextFileType.Block) { DuckGame.Graphics.DrawString("@LOADICON@Custom - " + str2, p1_1 + new Vec2(5f, 7f), Color.White, this.depth + 8); } else if (this._type == ContextFileType.Platform) { DuckGame.Graphics.DrawString("@LOADICON@Custom - " + str2, p1_1 + new Vec2(5f, 7f), Color.White, this.depth + 8); } else if (this._type == ContextFileType.Background) { DuckGame.Graphics.DrawString("@LOADICON@Custom - " + str2, p1_1 + new Vec2(5f, 7f), Color.White, this.depth + 8); } else if (this._type == ContextFileType.Parallax) { DuckGame.Graphics.DrawString("@LOADICON@Custom - " + str2, p1_1 + new Vec2(5f, 7f), Color.White, this.depth + 8); } else if (this._type == ContextFileType.ArcadeStyle) { DuckGame.Graphics.DrawString("@LOADICON@Custom - " + str2, p1_1 + new Vec2(5f, 7f), Color.White, this.depth + 8); } else { DuckGame.Graphics.DrawString("@LOADICON@Load Level - " + str2, p1_1 + new Vec2(5f, 7f), Color.White, this.depth + 8); } Vec2 p1_4 = new Vec2(p2_1.x + 2f, p1_1.y); Vec2 p2_4 = p1_4 + new Vec2(166f, 120f); if (this._previewSprite != null && this._previewSprite.texture != null && (this._type == ContextFileType.Block || this._type == ContextFileType.Background || (this._type == ContextFileType.Platform || this._type == ContextFileType.Parallax) || (this._type == ContextFileType.ArcadeStyle || this._type == ContextFileType.ArcadeAnimation))) { p2_4 = this._type != ContextFileType.Parallax ? p1_4 + new Vec2((float)(this._previewSprite.width + 4), (float)(this._previewSprite.height + 4)) : p1_4 + new Vec2((float)(this._previewSprite.width / 2 + 4), (float)(this._previewSprite.height / 2 + 4)); } DuckGame.Graphics.DrawRect(p1_4, p2_4, new Color(70, 70, 70), this.depth, false); DuckGame.Graphics.DrawRect(p1_4, p2_4, new Color(30, 30, 30), this.depth - 8); if (this._previewSprite == null || this._previewSprite.texture == null) { return; } this._previewSprite.depth = new Depth(0.95f); this._previewSprite.scale = new Vec2(0.5f); if (this._type == ContextFileType.Block || this._type == ContextFileType.Background || this._type == ContextFileType.Platform) { this._previewSprite.scale = new Vec2(1f); } DuckGame.Graphics.Draw(this._previewSprite, p1_4.x + 2f, p1_4.y + 2f); if (Content.renderingPreview || Content.previewLevel == null || !(Content.previewLevel.level + ".lev" == this._prevPreviewPath)) { return; } bool flag1 = false; if (Content.previewLevel.things[typeof(ChallengeMode)].Count <Thing>() > 0) { flag1 = true; } bool flag2 = false; if (Content.previewLevel.things[typeof(SpawnPoint)].Count <Thing>() == 0) { flag2 = true; } bool flag3 = false; if (Content.previewLevel.things[typeof(ArcadeMode)].Count <Thing>() > 0) { flag3 = true; } string str3 = Content.previewLevel.level; int startIndex2 = str3.LastIndexOf("/"); if (startIndex2 != -1) { str3 = str3.Substring(startIndex2, str3.Length - startIndex2); } if (str3.Length > 19) { string str4 = str3.Substring(0, 18) + "."; } if (flag2) { DuckGame.Graphics.DrawString("STRANGE MAP", p1_4 + new Vec2(5f, 107f), Colors.DGPurple, this.depth + 8); } else if (flag3) { DuckGame.Graphics.DrawString("ARCADE LAYOUT", p1_4 + new Vec2(5f, 107f), Colors.DGYellow, this.depth + 8); } else if (flag1) { DuckGame.Graphics.DrawString("CHALLENGE MAP", p1_4 + new Vec2(5f, 107f), Colors.DGRed, this.depth + 8); } else if (Content.previewLevel.onlineEnabled) { DuckGame.Graphics.DrawString("ONLINE MAP", p1_4 + new Vec2(5f, 107f), Colors.DGGreen, this.depth + 8); } else { DuckGame.Graphics.DrawString("MULTIPLAYER MAP", p1_4 + new Vec2(5f, 107f), Colors.DGBlue, this.depth + 8); } }
public override void Update() { this.yOffset = Lerp.FloatSmooth(this.yOffset, this.down ? 150f : 0.0f, 0.3f, 1.1f); if (this.down) { if (this._unlocks.Count == 0) { if (!this.finished) { this.finished = true; this.Close(); } } else { this._downWait -= 0.06f; if ((double)this._downWait <= 0.0) { this._openWait = 1f; this._wrapped = true; this._downWait = 1f; this._unlock = this._unlocks.First <Unlockable>(); this._unlocks.RemoveAt(0); this.down = false; SFX.Play("pause", 0.6f); } } } else { this._openWait -= 0.06f; if ((double)this._openWait <= 0.0 && this._wrapped && !this._flash) { this._flash = true; } if (this._flash) { Graphics.flashAdd = Lerp.Float(Graphics.flashAdd, 1f, 0.2f); if ((double)Graphics.flashAdd > 0.990000009536743) { this._wrapped = !this._wrapped; if (!this._wrapped) { if (this._unlock != null && this._unlock.name == "UR THE BEST") { this._oldSong = Music.currentSong; Music.Play("jollyjingle"); } SFX.Play("harp"); HUD.AddCornerControl(HUDCorner.BottomRight, "@SELECT@CONTINUE"); this._unlock.DoUnlock(); } this._flash = false; } } else { Graphics.flashAdd = Lerp.Float(Graphics.flashAdd, 0.0f, 0.2f); } if (!this._wrapped && Input.Pressed("SELECT")) { HUD.CloseAllCorners(); SFX.Play("resume", 0.6f); if (this._oldSong != null && this._unlock != null && this._unlock.name == "UR THE BEST") { Music.Play(this._oldSong); } this.down = true; } } base.Update(); }
public override void Update() { this._scroll += 0.1f; if ((double)this._scroll > 9.0) { this._scroll = 0.0f; } this._dots += 0.01f; if ((double)this._dots > 1.0) { this._dots = 0.0f; } if (this.open) { foreach (BlacklistServer failedAttempt in this._failedAttempts) { failedAttempt.cooldown = Lerp.Float(failedAttempt.cooldown, 0.0f, Maths.IncFrameTimer()); } if (this._signalCrossLocal.currentAnimation == "idle") { if (UIMatchmakingBox.pulseLocal) { this._signalCrossLocal.SetAnimation("flicker"); UIMatchmakingBox.pulseLocal = false; } } else if (this._signalCrossLocal.finished) { this._signalCrossLocal.SetAnimation("idle"); } if (this._signalCrossNetwork.currentAnimation == "idle") { if (UIMatchmakingBox.pulseNetwork) { this._signalCrossNetwork.SetAnimation("flicker"); UIMatchmakingBox.pulseNetwork = false; } } else if (this._signalCrossNetwork.finished) { this._signalCrossNetwork.SetAnimation("idle"); } if (Network.connections.Count > 0 && UIMatchmakingBox._state != MatchmakingState.Connecting) { this.ChangeState(MatchmakingState.Connecting); DevConsole.Log("|PURPLE|MATCHMAKING |DGGREEN|Network appears to be connecting...", Color.White); } if (DuckNetwork.status == DuckNetStatus.Connected) { if (this._tryHostingLobby != null) { (Level.current as TeamSelect2).CloseAllDialogs(); Level.current = (Level) new TeamSelect2(); DevConsole.Log("|PURPLE|MATCHMAKING |DGGREEN|Finished! (HOST).", Color.White); return; } if (Level.current is TeamSelect2) { (Level.current as TeamSelect2).CloseAllDialogs(); Level.current = (Level) new ConnectingScreen(); DevConsole.Log("|PURPLE|MATCHMAKING |DGGREEN|Finished! (CLIENT).", Color.White); return; } Network.Disconnect(); this.ChangeState(MatchmakingState.SearchForLobbies); DevConsole.Log("|PURPLE|MATCHMAKING |DGGREEN|Last minute connection error.", Color.White); return; } switch (UIMatchmakingBox._state) { case MatchmakingState.ConnectToMoon: Steam.AddLobbyStringFilter("started", "true", SteamLobbyComparison.Equal); Steam.SearchForLobby((User)null); Steam.RequestGlobalStats(); UIMatchmakingBox.pulseLocal = true; this.ChangeState(MatchmakingState.ConnectingToMoon); break; case MatchmakingState.ConnectingToMoon: if (Steam.lobbySearchComplete) { if (this.searchTryIndex == 0) { this._totalInGameLobbies = Steam.lobbiesFound; if (this._totalInGameLobbies < 0) { this._totalInGameLobbies = 0; } ++this.searchTryIndex; Steam.AddLobbyStringFilter("started", "false", SteamLobbyComparison.Equal); Steam.SearchForLobby((User)null); break; } UIMatchmakingBox.pulseNetwork = true; this._totalLobbiesFound = Steam.lobbiesFound; List <User> users = Steam.GetSearchLobbyAtIndex(0).users; this._newStatusList.Add("|DGGREEN|Connected to Moon!"); this._newStatusList.Add(""); this._newStatusList.Add("|DGYELLOW|Searching for companions."); this.ChangeState(MatchmakingState.SearchForLobbies); break; } break; case MatchmakingState.SearchForLobbies: if (this._triesSinceSearch == 3) { Steam.AddLobbyStringFilter("started", "true", SteamLobbyComparison.Equal); Steam.SearchForLobby((User)null); this.ChangeState(MatchmakingState.CheckingTotalGames); return; } if (this._tries > 0 && this._tryHostingLobby == null) { DuckNetwork.Host(TeamSelect2.GetSettingInt("maxplayers"), NetworkLobbyType.Public); this._tryHostingLobby = (Network.activeNetwork.core as NCSteam).lobby; if (!this.triedHostingAlready) { this._newStatusList.Add("|DGYELLOW|Searching even harder."); } else { this._newStatusList.Add("|DGYELLOW|Searching."); } this.triedHostingAlready = true; DevConsole.Log("|PURPLE|MATCHMAKING |DGYELLOW|Opened lobby while searching.", Color.White); this._tryHostingWait = 5f + Rando.Float(2f); } foreach (MatchSetting matchSetting in TeamSelect2.matchSettings) { if (matchSetting.value is int) { if (matchSetting.filtered) { Steam.AddLobbyNumericalFilter(matchSetting.id, (int)matchSetting.value, (SteamLobbyComparison)matchSetting.filterMode); } else if (!matchSetting.filtered) { Steam.AddLobbyNearFilter(matchSetting.id, (int)matchSetting.defaultValue); } } if (matchSetting.value is bool) { if (matchSetting.filtered) { Steam.AddLobbyNumericalFilter(matchSetting.id, (bool)matchSetting.value ? 1 : 0, (SteamLobbyComparison)matchSetting.filterMode); } else if (!matchSetting.filtered) { Steam.AddLobbyNearFilter(matchSetting.id, (bool)matchSetting.defaultValue ? 1 : 0); } } } foreach (MatchSetting onlineSetting in TeamSelect2.onlineSettings) { if (onlineSetting.value is int) { if (onlineSetting.filtered) { Steam.AddLobbyNumericalFilter(onlineSetting.id, (int)onlineSetting.value, (SteamLobbyComparison)onlineSetting.filterMode); } else if (!onlineSetting.filtered) { Steam.AddLobbyNearFilter(onlineSetting.id, (int)onlineSetting.defaultValue); } } if (onlineSetting.value is bool) { if (onlineSetting.id == "modifiers") { if (onlineSetting.filtered) { Steam.AddLobbyStringFilter(onlineSetting.id, (bool)onlineSetting.value ? "true" : "false", SteamLobbyComparison.Equal); } } else if (onlineSetting.filtered) { Steam.AddLobbyNumericalFilter(onlineSetting.id, (bool)onlineSetting.value ? 1 : 0, (SteamLobbyComparison)onlineSetting.filterMode); } else if (!onlineSetting.filtered) { Steam.AddLobbyNearFilter(onlineSetting.id, (bool)onlineSetting.defaultValue ? 1 : 0); } } } Steam.AddLobbyStringFilter("started", "false", SteamLobbyComparison.Equal); Steam.AddLobbyStringFilter("beta", "2.0", SteamLobbyComparison.Equal); Steam.AddLobbyStringFilter("dev", DG.devBuild ? "true" : "false", SteamLobbyComparison.Equal); Steam.AddLobbyStringFilter("modhash", ModLoader.modHash, SteamLobbyComparison.Equal); if (!Steam.waitingForGlobalStats) { this._globalKills = (long)Steam.GetDailyGlobalStat("kills"); } Steam.RequestGlobalStats(); UIMatchmakingBox.pulseLocal = true; this.ChangeState(MatchmakingState.Searching); ++this._triesSinceSearch; ++this._tries; break; case MatchmakingState.CheckingTotalGames: if (Steam.lobbySearchComplete) { this._totalInGameLobbies = Steam.lobbiesFound; if (this._totalInGameLobbies < 0) { this._totalInGameLobbies = 0; } this.ChangeState(MatchmakingState.SearchForLobbies); this._triesSinceSearch = 0; break; } break; case MatchmakingState.Searching: if (Steam.lobbySearchComplete) { this._totalLobbiesFound = Steam.lobbiesFound; if (this._tryHostingLobby != null) { --this._totalLobbiesFound; } List <Lobby> lobbyList = new List <Lobby>(); DevConsole.Log("|PURPLE|MATCHMAKING |LIME|found " + (object)Math.Max(this._totalLobbiesFound, 0) + " lobbies.", Color.White); for (int index1 = 0; index1 < 2; ++index1) { int num1 = index1 != 0 ? lobbyList.Count : Steam.lobbiesFound; for (int index2 = 0; index2 < num1; ++index2) { Lobby lobby = index1 != 0 ? lobbyList[index2] : Steam.GetSearchLobbyAtIndex(index2); if (this._tryHostingLobby == null || (long)lobby.id != (long)this._tryHostingLobby.id) { if (index2 == Steam.lobbiesFound - 1) { this._failedAttempts.RemoveAll((Predicate <BlacklistServer>)(x => (double)x.cooldown <= 0.0)); } if (UIMatchmakingBox.nonPreferredServers.Contains(lobby.id) && index1 == 0) { lobbyList.Add(lobby); DevConsole.Log("|PURPLE|MATCHMAKING |DGRED|Skipping " + (object)lobby.id + " (NOT PREFERRED)", Color.White); } else if (this.IsBlacklisted(lobby.id)) { DevConsole.Log("|PURPLE|MATCHMAKING |DGRED|Skipping " + (object)lobby.id + " (BLACKLISTED)", Color.White); } else { if (this._tryHostingLobby != null) { int num2 = -1; try { string lobbyData = lobby.GetLobbyData("randomID"); if (lobbyData != "") { num2 = Convert.ToInt32(lobbyData); } } catch { } if (num2 == -1) { DevConsole.Log("|PURPLE|MATCHMAKING |DGYELLOW|Bad lobby seed.", Color.White); num2 = Rando.Int(2147483646); } if (num2 >= this._tryHostingLobby.randomID) { DevConsole.Log("|PURPLE|MATCHMAKING |DGYELLOW|Lobby beats own lobby, Attempting join.", Color.White); } else { DevConsole.Log("|PURPLE|MATCHMAKING |DGYELLOW|Skipping lobby (Chose to keep hosting).", Color.White); NCSteam.UpdateRandomID(this._tryHostingLobby); continue; } } this._tryConnectLobby = lobby; if (lobby.owner != null) { this._newStatusList.Add("|LIME|Trying to join " + lobby.owner.name + "."); } else { this._newStatusList.Add("|LIME|Trying to join server."); } this.ChangeState(MatchmakingState.Disconnect); break; } } } } if (this._tryConnectLobby == null) { DevConsole.Log("|PURPLE|MATCHMAKING |DGYELLOW|Found no valid lobbies.", Color.White); this.ChangeState(MatchmakingState.SearchForLobbies, 3f); break; } break; } break; case MatchmakingState.Waiting: this._stateWait -= Maths.IncFrameTimer(); if ((double)this._stateWait <= 0.0) { this._stateWait = 0.0f; this.OnStateChange(this._pendingState); break; } break; default: int state = (int)UIMatchmakingBox._state; break; } if (Input.Pressed("QUACK")) { this._quit = true; this.ChangeState(MatchmakingState.Disconnect); } } if (this._newStatusList.Count > 0) { this._newStatusWait -= 0.1f; if ((double)this._newStatusWait <= 0.0) { this._newStatusWait = 1f; while ((double)this._fancyFont.GetWidth(this._newStatusList[0]) > 98.0) { this._newStatusList[0] = this._newStatusList[0].Substring(0, this._newStatusList[0].Length - 1); } this._statusList.Add(this._newStatusList[0]); if (this._statusList.Count > 7) { this._statusList.RemoveAt(0); } this._newStatusList.RemoveAt(0); } } base.Update(); }
public override void Update() { if (this._testMode) { this._wait += Maths.IncFrameTimer(); if (Keyboard.Pressed(Keys.F5) || (double)this._wait > 0.1) { this._wait = 0.0f; try { this._tie = new SpriteMap((Tex2D)ContentPack.LoadTexture2D("tieTest.png"), 64, 64); this._tie.center = new Vec2(26f, 27f); } catch (Exception ex) { } } } DuckGame.Graphics.fadeAdd = Lerp.Float(DuckGame.Graphics.fadeAdd, 0.0f, 0.01f); if (Main.isDemo && this._skip && !this._firedSkipLogic) { this._firedSkipLogic = true; Vote.CloseVoting(); HUD.CloseAllCorners(); this.DoSkip(); } if ((double)DuckGame.Graphics.fade > 0.990000009536743 && !this._skip && Vote.Passed(VoteType.Skip)) { this._skip = true; } if (this._talker.finished || !HighlightLevel._cancelSkip && this._skip && !Main.isDemo) { this._done -= 0.04f; } DuckGame.Graphics.fade = Lerp.Float(DuckGame.Graphics.fade, (double)this._done < 0.0 ? 0.0f : 1f, 0.02f); if ((double)DuckGame.Graphics.fade < 0.00999999977648258 && (this._talker.finished || this._skip)) { if (this._endOfHighlights || this._skip) { Vote.CloseVoting(); Level.current = (Level) new RockScoreboard(RockScoreboard.returnLevel, ScoreBoardMode.ShowWinner, true); } else { Level.current = (Level) new HighlightPlayback(4); } } if (this._state == TVState.ShowPedestals) { this._waitZoom -= 0.008f; if ((double)this._waitZoom < 0.00999999977648258) { this._waitZoom = 0.0f; this._desiredState = TVState.ShowNewscaster; } } if (this._state == TVState.ShowHotness && this._hotness.ready) { this._talker.Resume(); } if (this._state == TVState.ShowInterview) { this._interviewWait -= 0.02f; if ((double)this._interviewWait < 0.0 && !this._askedQuestion) { this._talker.InsertLine(Script.winner() + "! To what do you attribute your success?", this._interviewIndex); this._talker.Resume(); this._askedQuestion = true; } } this._cameraOffset.x = Lerp.Float(this._cameraOffset.x, HighlightLevel._image != null ? 20f : 0.0f, 2f); this._talker.active = this._talker.visible = this._state != TVState.ShowPedestals; if (this._state == this._desiredState) { return; } this._talker.active = false; this._transition.PlaySwipe(); if (!this._transition.doTransition) { return; } this._state = this._desiredState; }
public override void Update() { if (Network.isActive && this._prevVisible && !this.visible) { for (int i = 0; i < 4; i++) { SmallSmoke s = SmallSmoke.New(base.x + Rando.Float(-4f, 4f), base.y + Rando.Float(-4f, 4f)); s.hSpeed += this.hSpeed * Rando.Float(0.3f, 0.5f); s.vSpeed -= Rando.Float(0.1f, 0.2f); Level.Add(s); } } if (this._duckOwner == null) { return; } this._framesSinceTransfer++; base.Update(); if (base.y > Level.current.lowestPoint + 100f) { this.OnDestroy(new DTFall()); } this.jumpCountdown -= Maths.IncFrameTimer(); this._prevVisible = this.visible; this._shakeInc += 0.8f; this._shakeMult = Lerp.Float(this._shakeMult, 0f, 0.05f); if (Network.isActive && this._duckOwner._trapped == this && !this._duckOwner.isServerForObject && this._duckOwner.inputProfile.Pressed("JUMP", false)) { this._shakeMult = 1f; } if (this._duckOwner.isServerForObject && this._duckOwner._trapped == this) { if (!this.visible) { base.y = -9999f; } if (!this.infinite) { this._duckOwner.profile.stats.timeInNet += Maths.IncFrameTimer(); if (this._duckOwner.inputProfile.Pressed("JUMP", false)) { this._shakeMult = 1f; this._trapTime -= 0.007f; this.jumpCountdown = 0.25f; } if (base.grounded && this._duckOwner.inputProfile.Pressed("JUMP", false)) { this._shakeMult = 1f; this._trapTime -= 0.028f; if (this.owner == null) { if (Math.Abs(this.hSpeed) < 1f && this._framesSinceTransfer > 30) { this._duckOwner.Fondle(this); } this.vSpeed -= Rando.Float(0.8f, 1.1f); if (this._duckOwner.inputProfile.Down("LEFT") && this.hSpeed > -1f) { this.hSpeed -= Rando.Float(0.6f, 0.8f); } if (this._duckOwner.inputProfile.Down("RIGHT") && this.hSpeed < 1f) { this.hSpeed += Rando.Float(0.6f, 0.8f); } } } if (this._duckOwner.inputProfile.Pressed("JUMP", false) && this._duckOwner.HasEquipment(typeof(Jetpack))) { Equipment e = this._duckOwner.GetEquipment(typeof(Jetpack)); e.PressAction(); } if (this._duckOwner.inputProfile.Released("JUMP") && this._duckOwner.HasEquipment(typeof(Jetpack))) { Equipment e2 = this._duckOwner.GetEquipment(typeof(Jetpack)); e2.ReleaseAction(); } this._trapTime -= 0.0028f; if (this._trapTime <= 0f || this._duckOwner.dead) { this.OnDestroy(null); } } if (this.owner == null) { base.depth = this._duckOwner.depth; } this._duckOwner.position = this.position; this._duckOwner.UpdateSkeleton(); } }
public override void Update() { if (this.isServerForObject) { this.ownerAction = this.action; } if (this.duck != null && this.ownerAction) { this._holdOffset = Lerp.Vec2(this._holdOffset, new Vec2(-13f, -4f), 2f); this.angle = Lerp.Float(this.angle, -1f, 0.1f); this.handFlip = true; this.handOffset = Lerp.Vec2(this.handOffset, new Vec2(-3f, -4f), 1f); this._canRaise = false; } else { float num = 1f; if (this.duck != null) { this.angle = Lerp.Float(this.angle, 0.0f, 0.1f * num); } else { num = 20f; } this._holdOffset = Lerp.Vec2(this._holdOffset, new Vec2(-2f, 0.0f), num * 2f); this.handFlip = false; this.handOffset = Lerp.Vec2(this.handOffset, new Vec2(0.0f, 0.0f), 1f * num); this._canRaise = true; } if (this.owner == null && this.level.simulatePhysics) { if (this._framesSinceThrown == 0) { this._throwSpin = this.angleDegrees; } ++this._framesSinceThrown; if (this._framesSinceThrown > 15) { this._framesSinceThrown = 15; } this.angleDegrees = this._throwSpin; bool flag1 = false; bool flag2 = false; if (((double)Math.Abs(this.hSpeed) + (double)Math.Abs(this.vSpeed) > 2.0 || !this.grounded) && ((double)this.gravMultiplier > 0.0 && !flag2) && !this._grounded) { if (this.offDir > (sbyte)0) { this._throwSpin += (float)(((double)Math.Abs(this.hSpeed * 2f) + (double)Math.Abs(this.vSpeed)) * 1.0 + 5.0); } else { this._throwSpin -= (float)(((double)Math.Abs(this.hSpeed * 2f) + (double)Math.Abs(this.vSpeed)) * 1.0 + 5.0); } flag1 = true; } if (!flag1 || flag2) { this._throwSpin %= 360f; if ((double)this._throwSpin < 0.0) { this._throwSpin += 360f; } if (flag2) { this._throwSpin = (double)Math.Abs(this._throwSpin - 90f) >= (double)Math.Abs(this._throwSpin + 90f) ? Lerp.Float(-90f, 0.0f, 16f) : Lerp.Float(this._throwSpin, 90f, 16f); } else if ((double)this._throwSpin > 90.0 && (double)this._throwSpin < 270.0) { this._throwSpin = Lerp.Float(this._throwSpin, 180f, 14f); } else { if ((double)this._throwSpin > 180.0) { this._throwSpin -= 360f; } else if ((double)this._throwSpin < -180.0) { this._throwSpin += 360f; } this._throwSpin = Lerp.Float(this._throwSpin, 0.0f, 14f); } } } else { this._throwSpin = 0.0f; } base.Update(); }