public void GoUnVirtual() { if (!this._virtualMode) { return; } this._realBackground = (BackgroundUpdater)null; this._virtualMode = false; this._scanStage = 0; this._stick = 0.0f; this._done = false; }
public VirtualBackground(float xpos, float ypos, BackgroundUpdater realBackground, bool fore = false) : base(xpos, ypos) { this.graphic = (Sprite) new SpriteMap("backgroundIcons", 16, 16) { frame = 2 }; this.center = new Vec2(8f, 8f); this._collisionSize = new Vec2(16f, 16f); this._collisionOffset = new Vec2(-8f, -8f); this.depth = new Depth(0.9f); this.layer = Layer.Foreground; this._visibleInGame = false; this._editorName = "Virtual"; this._realBackground = realBackground; this._foreground = fore; }
public void GoVirtual() { if (this._virtualMode) { return; } this._scanStage = 2; this._stick = 1f; this._virtualMode = true; this._done = false; if (this._realBackground == null) { using (IEnumerator <Thing> enumerator = Level.activeLevel.things[typeof(BackgroundUpdater)].GetEnumerator()) { if (enumerator.MoveNext()) { BackgroundUpdater current = (BackgroundUpdater)enumerator.Current; this._realBackground = current; this._curBackgroundColor = current.backgroundColor; } } } this._transitionLevel = Level.activeLevel; }
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; } }