static public int CubeInOut_s(IntPtr l) { try { #if DEBUG var method = System.Reflection.MethodBase.GetCurrentMethod(); string methodName = GetMethodName(method); #if UNITY_5_5_OR_NEWER UnityEngine.Profiling.Profiler.BeginSample(methodName); #else Profiler.BeginSample(methodName); #endif #endif System.Single a1; checkType(l, 1, out a1); var ret = Ease.CubeInOut(a1); pushValue(l, true); pushValue(l, ret); return(2); } catch (Exception e) { return(error(l, e)); } #if DEBUG finally { #if UNITY_5_5_OR_NEWER UnityEngine.Profiling.Profiler.EndSample(); #else Profiler.EndSample(); #endif } #endif }
public override IEnumerator Leave(Oui next) { Audio.SetMusic(audioPrevMusic); Audio.SetAmbience(audioPrevAmbience); Audio.Play(SFX.ui_main_whoosh_large_out); if (playing != null) { Audio.Stop(playing); } Focused = false; Vector2 posFrom = Position; Vector2 posTo = new Vector2(0f, 1080f); for (float t = 0f; t < 1f; t += Engine.DeltaTime * 2f) { ease = 1f - Ease.CubeIn(t); Position = posFrom + (posTo - posFrom) * Ease.CubeInOut(t); yield return(null); } Visible = false; }
public override void Render() { Draw.Rect(-10f, -10f, 1940f, 1100f, Color.Black * Ease.CubeOut(Alpha)); base.Render(); if (remappingEase <= 0.0) { return; } Draw.Rect(-10f, -10f, 1940f, 1100f, Color.Black * 0.95f * Ease.CubeInOut(remappingEase)); Vector2 position = new Vector2(1920f, 1080f) * 0.5f; if (remappingKeyboard || Input.GuiInputController()) { ActiveFont.Draw( remappingKeyboard ? Dialog.Get(DialogIds.KeyConfigChanging) : Dialog.Get(DialogIds.BtnConfigChanging), position + new Vector2(0.0f, -8f), new Vector2(0.5f, 1f), Vector2.One * 0.7f, Color.LightGray * Ease.CubeIn(remappingEase)); ActiveFont.Draw(ButtonInfos[remappingType].GetLabel(), position + new Vector2(0.0f, 8f), new Vector2(0.5f, 0.0f), Vector2.One * 2f, Color.White * Ease.CubeIn(remappingEase)); } else { ActiveFont.Draw(Dialog.Clean(DialogIds.BtnConfigNoController), position, new Vector2(0.5f, 0.5f), Vector2.One, Color.White * Ease.CubeIn(remappingEase)); } }
public override void Render() { if (ease > 0f) { Draw.Rect(-10f, -10f, 1940f, 1100f, Color.Black * ease * 0.4f); } base.Render(); const float spacingX = 48f; const float spacingY = 64f; Vector2 posCenter = Position + new Vector2(1920f / 2f, 1080f / 2f); Vector2 pos; // Vector2 posInput = posCenter - new Vector2(spacingX * (digits.Length - 1f) / 2f, spacingY * 0.5f); Vector2 posInput = Position + new Vector2(384f, 1080f / 2f); pos = posInput; for (int i = 0; i < digits.Length; i++) { DrawOptionText(digits[i].ToString("X1"), pos + new Vector2(0f, wigglerDigits[i].Value * 8f), new Vector2(0f, 0.5f), Vector2.One, selectedDigit == i && !musicParamMenu.Focused, i <= 1); pos.X += spacingX; } // pos = posCenter + new Vector2(0f, spacingY * 0.5f + wigglerPath.Value * 2f); pos = posInput + new Vector2(spacingX * 2f, spacingY * 0.8f + wigglerPath.Value * 2f); ActiveFont.DrawOutline(selectedPath ?? "", pos, new Vector2(0f, 0.5f), Vector2.One * 0.75f, Color.White * ease, 2f, Color.Black * ease * ease * ease); pos = posInput + new Vector2(0f, spacingY * -0.8f + wigglerBankPath.Value * 2f); ActiveFont.DrawOutline(selectedBankPath ?? "", pos, new Vector2(0f, 0.5f), Vector2.One * 0.75f, Color.LightSlateGray * ease, 2f, Color.Black * ease * ease * ease); if (musicParamMenu.GetItems().Count > 0) { // Press... pos = posInput + new Vector2(0f, spacingY * 2f + wigglerBankPath.Value * 2f); ActiveFont.DrawOutline(Dialog.Clean("SOUNDTEST_AUDIOPARAMS_OPEN_1"), pos, new Vector2(0f, 0.5f), Vector2.One * 0.75f, Color.White * ease, 2f, Color.Black * ease * ease * ease); // ... [button image] ... pos.X += ActiveFont.Measure(Dialog.Clean("SOUNDTEST_AUDIOPARAMS_OPEN_1")).X * 0.75f + 10f; MTexture button = Input.GuiButton(Input.MenuJournal); button.DrawJustified(pos, new Vector2(0f, 0.5f), Color.White, 0.75f); pos.X += button.Width * 0.75f + 10f; // ... to edit Audio Params ActiveFont.DrawOutline(Dialog.Clean("SOUNDTEST_AUDIOPARAMS_OPEN_2"), pos, new Vector2(0f, 0.5f), Vector2.One * 0.75f, Color.White * ease, 2f, Color.Black * ease * ease * ease); } ActiveFont.DrawEdgeOutline(Dialog.Clean("soundtest_title"), Position + new Vector2(960f, 256f), new Vector2(0.5f, 0.5f), Vector2.One * 2f, Color.Gray, 4f, Color.DarkSlateBlue, 2f, Color.Black); if (musicParamMenuEase > 0f) { Draw.Rect(-10f, -10f, 1940f, 1100f, Color.Black * 0.95f * Ease.CubeInOut(musicParamMenuEase)); musicParamMenu.Alpha = Ease.CubeInOut(musicParamMenuEase); musicParamMenu.Render(); } }
public override void Update() { Player entity = Scene.Tracker.GetEntity <Player>(); if (entity != null) { alpha = Ease.CubeInOut(Calc.ClampedMap(Math.Abs(X - entity.X), 0f, 128f, 1f, 0f)); } base.Update(); }
private IEnumerator PanCameraY(float to, float speed) { float from = Level.Camera.Y; for (float p = 0f; p < 1f; p += Engine.DeltaTime * speed) { Level.Camera.Y = from + (to - from) * Ease.CubeInOut(p); yield return(null); } }
public override void Render() { base.Render(); if (subText != null) { Vector2 offset = new Vector2(Ease.CubeInOut(this.GetEase()) * 32f, this.GetWiggler().Value * 8f); ActiveFont.DrawOutline(subText, Position + offset + new Vector2(84f, 84f), new Vector2(0f, 0.5f), Vector2.One * 0.6f, Color.OrangeRed, 2f, Color.Black); } }
public override void Render() { Draw.Rect(-10f, -10f, 1940f, 1100f, Color.Black * Ease.CubeOut(Alpha)); RenderTextMenu(); if (remappingEase > 0f) { Draw.Rect(-10f, -10f, 1940f, 1100f, Color.Black * 0.95f * Ease.CubeInOut(remappingEase)); Vector2 value = new Vector2(1920f, 1080f) * 0.5f; ActiveFont.Draw(additiveRemap ? Dialog.Get("KEY_CONFIG_ADDING") : Dialog.Get("KEY_CONFIG_CHANGING"), value + new Vector2(0f, -8f), new Vector2(0.5f, 1f), Vector2.One * 0.7f, Color.LightGray * Ease.CubeIn(remappingEase)); ActiveFont.Draw(GetLabel(currentlyRemapping), value + new Vector2(0f, 8f), new Vector2(0.5f, 0f), Vector2.One * 2f, Color.White * Ease.CubeIn(remappingEase)); } }
public override void Render() { Vector2 vector = Position + new Vector2(128f, 120f); float num = Ease.CubeInOut(Math.Max(0f, turningScale)); float num2 = Ease.CubeInOut(Math.Abs(Math.Min(0f, turningScale))); if (SaveData.Instance.CheatMode) { MTN.FileSelect["cheatmode"].DrawCentered(vector + new Vector2(80f, 360f), Color.White, 1f, 1.57079637f); } if (SaveData.Instance.AssistMode) { MTN.FileSelect["assist"].DrawCentered(vector + new Vector2(100f, 370f), Color.White, 1f, 1.57079637f); } MTexture mtexture = MTN.Journal["edge"]; mtexture.Draw(vector + new Vector2((float)-mtexture.Width, 0f), Vector2.Zero, Color.White, 1f, rotation); if (PageIndex > 0) { MTN.Journal[PrevPage.PageTexture].Draw(vector, Vector2.Zero, backColor, new Vector2(-1f, 1f), rotation); } if (turningPage) { MTN.Journal[NextPage.PageTexture].Draw(vector, Vector2.Zero, Color.White, 1f, rotation); Draw.SpriteBatch.Draw(NextPageBuffer, vector, new Rectangle?(NextPageBuffer.Bounds), Color.White, rotation, Vector2.Zero, Vector2.One, SpriteEffects.None, 0f); } if (turningPage && num2 > 0f) { MTN.Journal[Page.PageTexture].Draw(vector, Vector2.Zero, backColor, new Vector2(-1f * num2, 1f), rotation); } if (num > 0f) { MTN.Journal[Page.PageTexture].Draw(vector, Vector2.Zero, Color.White, new Vector2(num, 1f), rotation); //Page.Redraw(CurrentPageBuffer); Draw.SpriteBatch.Draw(CurrentPageBuffer, vector, new Rectangle?(CurrentPageBuffer.Bounds), Color.White, rotation, Vector2.Zero, new Vector2(num, 1f), SpriteEffects.None, 0f); } if (Pages.Count > 0) { int count = Pages.Count; MTexture mtexture2 = GFX.Gui["dot_outline"]; int num3 = mtexture2.Width * count; Vector2 value = new Vector2(960f, 1040f - 40f * Ease.CubeOut(dotEase)); for (int i = 0; i < count; i++) { mtexture2.DrawCentered(value + new Vector2((float)(-(float)num3 / 2) + mtexture2.Width * (i + 0.5f), 0f), Color.White * 0.25f); } float x = 1f + Calc.YoYo(dot % 1f) * 4f; mtexture2.DrawCentered(value + new Vector2((float)(-(float)num3 / 2) + mtexture2.Width * (dot + 0.5f), 0f), Color.White, new Vector2(x, 1f)); GFX.Gui["dotarrow_outline"].DrawCentered(value + new Vector2((float)(-(float)num3 / 2 - 50), 32f * (1f - Ease.CubeOut(leftArrowEase))), Color.White * leftArrowEase, new Vector2(-1f, 1f)); GFX.Gui["dotarrow_outline"].DrawCentered(value + new Vector2(num3 / 2 + 50, 32f * (1f - Ease.CubeOut(rightArrowEase))), Color.White * rightArrowEase); } }
private IEnumerator MoveNumberCoroutine(Vector2 start, Vector2 end) { yield return(.4f); SimpleCurve curve = new SimpleCurve(start, end, (start + end) / 2f + new Vector2(0f, 48f)); for (float t = 0f; t < 1f; t += Engine.DeltaTime) { yield return(null); Position = curve.GetPoint(Ease.CubeInOut(t)); } }
// Fade the passed tiles in or out. private IEnumerator TileFade(float to, List <Image> targetTiles, bool fast = false) { float from = 1f - to; for (float t = 0f; t < 1f; t += Engine.DeltaTime * (fast ? 5f : 1.5f)) { foreach (Image img in targetTiles) { img.Color = Color.White * (from + (to - from) * Ease.CubeInOut(t)); } yield return(null); } yield break; }
private IEnumerator OutlineFade(float to) { float from = 1f - to; for (float t = 0f; t < 1f; t += Engine.DeltaTime * 2f) { Color color = Color.White * (from + (to - from) * Ease.CubeInOut(t)); foreach (Image img in outline) { img.Color = color; } yield return(null); } }
private IEnumerator EaseOut(float duration) { float rotFrom = rotation; for (float p = 0f; p < 1f; p += Engine.DeltaTime / duration) { rotation = rotFrom * (1f - Ease.BackOut(p)); X = 0f + -1920f * Ease.CubeInOut(p); dotEase = 1f - p; yield return(null); } dotEase = 0f; yield break; }
public override void Render() { Level level = (Level)Scene; if (level.FrozenOrPaused || level.Completed) { return; } if (index <= 0f || alpha <= 0f) { return; } Camera camera = level.Camera; Vector2 pos = new Vector2((Memorial.X - camera.X) * 6f, (Memorial.Y - camera.Y) * 6f - 350f - ActiveFont.LineHeight * 3.3f); float alphaEased = Ease.CubeInOut(alpha); int length = (int)Math.Min(message.Length, index); int lineIndex = 0; float sink = 64f * (1f - alphaEased); int lineLength = CountToNewline(0); for (int i = 0; i < length; i++) { char c = message[i]; if (c == '\n') { lineIndex = 0; lineLength = CountToNewline(i + 1); sink += ActiveFont.LineHeight * 1.1f; continue; } float xJustify = 1f; float x = -lineLength * widestCharacter / 2f + (lineIndex + 0.5f) * widestCharacter; float yOffs = 0f; if (Dreamy && c != ' ' && c != '-' && c != '\n') { c = message[(i + (int)(Math.Sin((timer * 2f + i / 8f)) * 4.0) + message.Length) % message.Length]; yOffs = (float)Math.Sin((timer * 2f + i / 8f)) * 8f; xJustify = (Math.Sin((timer * 4f + i / 16f)) < 0.0) ? -1f : 1f; } ActiveFont.Draw(c, pos + new Vector2(x, sink + yOffs), new Vector2(0.5f, 1f), new Vector2(xJustify, 1f), Color.White * alphaEased); lineIndex++; } }
public override void Render() { if (Everest.Flags.IsDisabled) { orig_Render(); return; } if (CoreModule.Settings.ShowEverestTitleScreen) { logo = everestLogo; title = everestTitle; reflections = everestReflections; } else { logo = vanillaLogo; title = vanillaTitle; reflections = vanillaReflections; } float alphaPrev = alpha; float textYPrev = textY; float switchAlpha = Ease.CubeInOut(Calc.Clamp(Math.Max(switchingToVanilla, switchingToVanillaBack), 0f, 1f)); alpha = Calc.Clamp(alpha - switchAlpha, 0f, 1f); textY += switchAlpha * 200f; orig_Render(); arrowToVanilla?.DrawJustified(new Vector2(1920f - 80f + (textY - 1000f) * 2f, 540f), new Vector2(1f, 0.5f), Color.White * alpha); updateTex?.DrawJustified(new Vector2(80f - 4f, textY + 8f * (1f - updateAlpha) + 2f), new Vector2(1f, 1f), Color.White * updateAlpha, 0.8f); alpha = alphaPrev; textY = textYPrev; if (switchAlpha > 0f) { Draw.Rect(0f, 0f, 1920f, 1080f, Color.Black * switchAlpha); float offs = 40f * (1f - switchAlpha); ActiveFont.Draw(Dialog.Clean("MENU_TITLESCREEN_RESTART_VANILLA"), new Vector2(960f + offs, 540f - 4f), new Vector2(0.5f, 1f), Vector2.One, Color.White * switchAlpha); Draw.Rect(960f - 200f + offs, 540f + 4f, 400f, 4f, Color.Black * switchAlpha * switchAlpha); Draw.HollowRect(960f - 200f + offs, 540f + 4f, 400f, 4f, Color.DarkSlateGray * switchAlpha); Draw.Rect(960f - 200f + offs, 540f + 4f, 400f * Calc.Clamp(Math.Max(switchingToVanilla, switchingToVanillaBack) / switchingToVanillaDuration, 0f, 1f), 4f, Color.White * switchAlpha); } }
private IEnumerator ZoomAndPan(Vector2 panTo, float zoomTo, float speed, bool centered = false) { Vector2 panFrom = Level.Camera.Position; if (centered) { panTo -= 1 / zoomTo * new Vector2(320, 180) / 2; } float zoomFrom = Level.Camera.Zoom; for (float p = 0f; p < 1f; p += Engine.DeltaTime * speed) { Level.Camera.Position = panFrom + (panTo - panFrom) * Ease.CubeInOut(p); Level.Camera.Zoom = zoomFrom + (zoomTo - zoomFrom) * Ease.CubeInOut(p); yield return(null); } }
public override IEnumerator Leave(Oui next) { Overworld.ShowInputUI = true; Focused = false; Vector2 posFrom = Position; Vector2 posTo = new Vector2(0f, 1080f); for (float t = 0f; t < 1f; t += Engine.DeltaTime * 2f) { ease = 1f - Ease.CubeIn(t); Position = posFrom + (posTo - posFrom) * Ease.CubeInOut(t); yield return(null); } Visible = false; }
public override IEnumerator Enter(Oui from) { audioPrevMusic = Audio.GetEventName(Audio.CurrentMusicEventInstance); Audio.SetMusic(null); audioPrevAmbience = Audio.GetEventName(Audio.CurrentAmbienceEventInstance); Audio.SetAmbience(null); Visible = true; musicParamMenu = new TextMenu(); musicParamMenu.Focused = false; musicParamMenu.MinWidth = 500f; for (int i = 0; i < digits.Length; i++) { digits[i] = 0; } selectedDigit = digits.Length - 1; UpdateSelectedPath(); Vector2 posFrom = Position; Vector2 posTo = Vector2.Zero; for (float t = 0f; t < 1f; t += Engine.DeltaTime * 2f) { ease = Ease.CubeIn(t); Position = posFrom + (posTo - posFrom) * Ease.CubeInOut(t); yield return(null); } ease = 1f; posFrom = Vector2.Zero; posTo = Vector2.Zero; yield return(0.2f); Focused = true; yield return(0.2f); for (int i = 0; i < digits.Length; i++) { wigglerDigits[i].Start(); } wigglerPath.Start(); wigglerBankPath.Start(); }
private IEnumerator BirdRoutine(float delay) { yield return(delay); Level.Add(bird = new BirdNPC(Vector2.Zero, BirdNPC.Modes.None)); bird.Sprite.Play("flyupIdle"); Vector2 center = new Vector2(320f, 180f) / 2f; Vector2 topCenter = new Vector2(center.X, 0.0f); Vector2 botCenter = new Vector2(center.X, 180f); Vector2 from1 = botCenter + new Vector2(40f, 40f); Vector2 to1 = center + new Vector2(-32f, -24f); for (var t = 0.0f; t < 1.0; t += Engine.DeltaTime / 4f) { birdScreenPosition = from1 + (to1 - from1) * Ease.BackOut(t); yield return(null); } bird.Sprite.Play("flyupRoll"); for (var t = 0.0f; t < 1.0; t += Engine.DeltaTime / 2f) { birdScreenPosition = to1 + new Vector2(64f, 0.0f) * Ease.CubeInOut(t); yield return(null); } Vector2 from2 = birdScreenPosition; Vector2 to2 = topCenter + new Vector2(-40f, -100f); var playedAnim = false; for (var t = 0.0f; t < 1.0; t += Engine.DeltaTime / 4f) { if (t >= 0.349999994039536 && !playedAnim) { bird.Sprite.Play("flyupRoll"); playedAnim = true; } birdScreenPosition = from2 + (to2 - from2) * Ease.BigBackIn(t); birdScreenPosition.X += t * 32f; yield return(null); } bird.RemoveSelf(); bird = null; }
public override void Update() { if (_speedingUp && (_percent < 1f)) { _percent = Calc.Approach(_percent, 1f, Engine.DeltaTime / 1f); } else if (!_speedingUp && (_percent > 0f)) { _percent = Calc.Approach(_percent, 0f, Engine.DeltaTime / 1.5f); } PositionParticles(); foreach (WindMover component in Scene.Tracker.GetComponents <WindMover>()) { if (component.Entity.CollideCheck(this)) { if (_componentPercentages.ContainsKey(component)) { _componentPercentages[component] = Calc.Approach(_componentPercentages[component], 1f, Engine.DeltaTime / _windUpTime); } else { _componentPercentages.Add(component, 0f); } } else { if (_componentPercentages.ContainsKey(component)) { _componentPercentages[component] = Calc.Approach(_componentPercentages[component], 0.0f, Engine.DeltaTime / _windDownTime); if (_componentPercentages[component] == 0f) { _componentPercentages.Remove(component); } } } } foreach (WindMover component in _componentPercentages.Keys) { if (component != null && component.Entity != null && component.Entity.Scene != null) { component.Move(_actualWindSpeed * 0.1f * Engine.DeltaTime * Ease.CubeInOut(_componentPercentages[component])); } } base.Update(); }
public override void Render() { if (!loading && screenBuffer != null && !screenBuffer.IsDisposed) { float num = ScreenWidth * Ease.CubeOut(Calc.ClampedMap(ease, 0f, 0.5f, 0f, 1f)); float num2 = ScreenHeight * Ease.CubeInOut(Calc.ClampedMap(ease, 0.5f, 1f, 0.2f, 1f)); Rectangle rectangle = new Rectangle((int)((1920f - num) / 2f), (int)((1080f - num2) / 2f), (int)num, (int)num2); Draw.SpriteBatch.Draw(screenBuffer, rectangle, Color.White); if (ShowInput && waitingForInputTime > 0.2f) { GFX.Gui["textboxbutton"].DrawCentered(new Vector2(1856f, 1016 + ((Scene.TimeActive % 1f < 0.25f) ? 6 : 0)), Color.Black); } if ((Scene as Level).Paused) { Draw.Rect(rectangle, Color.Black * 0.7f); } } }
public override void Render() { Draw.Rect(-10f, -10f, 1940f, 1100f, Color.Black * Ease.CubeOut(Alpha)); Vector2 center = new Vector2(1920f, 1080f) * 0.5f; if (Input.GuiInputController()) { RenderTextMenu(); if (remappingEase > 0f) { Draw.Rect(-10f, -10f, 1940f, 1100f, Color.Black * 0.95f * Ease.CubeInOut(remappingEase)); ActiveFont.Draw(Dialog.Get("BTN_CONFIG_CHANGING"), center + new Vector2(0f, -8f), new Vector2(0.5f, 1f), Vector2.One * 0.7f, Color.LightGray * Ease.CubeIn(remappingEase)); ActiveFont.Draw(GetLabel(currentlyRemapping), center + new Vector2(0f, 8f), new Vector2(0.5f, 0f), Vector2.One * 2f, Color.White * Ease.CubeIn(remappingEase)); } } else { ActiveFont.Draw(Dialog.Clean("BTN_CONFIG_NOCONTROLLER"), center, new Vector2(0.5f, 0.5f), Vector2.One, Color.White * Ease.CubeOut(Alpha)); } }
private void UpdateBlockFill() { Vector2 rayAngle = Calc.AngleToVector(-1.670796f, 1f); Vector2 rayAngleCompl = new Vector2(-rayAngle.Y, rayAngle.X); int verticeCount = 0; for (int index1 = 0; index1 < rays.Length; ++index1) { // Ray lifetime and expiry if ((double)rays[index1].Percent >= 1.0) { rays[index1].Reset(); } rays[index1].Percent += Engine.DeltaTime / rays[index1].Duration; rays[index1].Y += 8f * Engine.DeltaTime; Vector2 rayPosition = new Vector2( mod(rays[index1].X - this.level.Camera.X * 0.9f, 320f + 160f) - 80f, mod(rays[index1].Y - this.level.Camera.Y * 0.7f, 580f) - 200f ); // Construct the ray float width = rays[index1].Width; float length = rays[index1].Length; Color rayLifeColor = this.rayColor * Ease.CubeInOut(Calc.YoYo(rays[index1].Percent)); VertexPositionColor vert1 = new VertexPositionColor(new Vector3(rayPosition + rayAngleCompl * width + rayAngle * length, 0.0f), rayLifeColor); VertexPositionColor vert2 = new VertexPositionColor(new Vector3(rayPosition - rayAngleCompl * width, 0.0f), rayLifeColor); VertexPositionColor vert3 = new VertexPositionColor(new Vector3(rayPosition + rayAngleCompl * width, 0.0f), rayLifeColor); VertexPositionColor vert4 = new VertexPositionColor(new Vector3(rayPosition - rayAngleCompl * width - rayAngle * length, 0.0f), rayLifeColor); // Add ray tris this.vertices[verticeCount++] = vert1; this.vertices[verticeCount++] = vert2; this.vertices[verticeCount++] = vert3; this.vertices[verticeCount++] = vert2; this.vertices[verticeCount++] = vert3; this.vertices[verticeCount++] = vert4; } this.vertexCount = verticeCount; }
public override void Update() { if (fade == FadeMode.NoFade) { alpha = 1; } else { Player entity = Scene.Tracker.GetEntity <Player>(); if (entity != null) { float alphaTmp = Ease.CubeInOut(Calc.ClampedMap(Math.Abs(X - entity.X), 0f, 128f, 1f, 0f)); if (fade == FadeMode.FadeIn) { alphaTmp = Math.Max(alpha, alphaTmp); } alpha = alphaTmp; } } base.Update(); }
public override IEnumerator Leave(Oui next) { TextInput.OnInput -= OnTextInput; Overworld.ShowInputUI = true; Focused = false; Engine.Commands.Enabled = (Celeste.PlayMode == Celeste.PlayModes.Debug); Vector2 posFrom = Position; Vector2 posTo = new Vector2(0f, 1080f); for (float t = 0f; t < 1f; t += Engine.DeltaTime * 2f) { ease = 1f - Ease.CubeIn(t); Position = posFrom + (posTo - posFrom) * Ease.CubeInOut(t); yield return(null); } Visible = false; }
private IEnumerator GotoTransition(TextMenu target, bool back = false) { Audio.Play(SFX.ui_main_whoosh_list_in); TextMenu menuOld = menu; menuOld.Visible = true; menuOld.Focused = false; step = new DynData <TextMenu>(target).Get <int>("oobeStep"); menu = target; menu.Visible = true; menu.Focused = false; Scene.Add(menu); if (back) { for (float p = 0f; p < 1f; p += Engine.DeltaTime * 4f) { menuOld.X = onScreenX + 1920f * Ease.CubeInOut(p); menu.X = offScreenLeftX + 1920f * Ease.CubeInOut(p); yield return(null); } } else { for (float p = 0f; p < 1f; p += Engine.DeltaTime * 4f) { menuOld.X = onScreenX - 1920f * Ease.CubeInOut(p); menu.X = offScreenRightX - 1920f * Ease.CubeInOut(p); yield return(null); } } menuOld.Visible = false; menuOld.RemoveSelf(); menu.Focused = true; }
public IEnumerator Enter() { PageIndex = 0; Visible = true; X = -1920f; turningPage = false; turningScale = 1f; rotation = 0f; dot = 0f; dotTarget = 0f; dotEase = 0f; leftArrowEase = 0f; rightArrowEase = 0f; NextPageBuffer = VirtualContent.CreateRenderTarget("journal-a", 1610, 1000, false, true, 0); CurrentPageBuffer = VirtualContent.CreateRenderTarget("journal-b", 1610, 1000, false, true, 0); int num = 0; foreach (CustomJournalPage CustomJournalPage in Pages) { CustomJournalPage.PageIndex = num++; } Pages[0].Redraw(CurrentPageBuffer); //this.cameraStart = this.Overworld.Mountain.UntiltedCamera; //this.cameraEnd = this.cameraStart; //this.cameraEnd.Position = this.cameraEnd.Position + -this.cameraStart.Rotation.Forward() * 1f; //this.Overworld.Mountain.EaseCamera(this.Overworld.Mountain.Area, this.cameraEnd, new float?(2f), true, false); //this.Overworld.Mountain.AllowUserRotation = false; for (float p = 0f; p < 1f; p += Engine.DeltaTime / 0.4f) { rotation = -0.025f * Ease.BackOut(p); X = -1920f + 1920f * Ease.CubeInOut(p); dotEase = p; yield return(null); } dotEase = 1f; yield break; }
public override IEnumerator Enter(Oui from) { TextInput.OnInput += OnKeyboardInput; Overworld.ShowInputUI = false; selectingOptions = false; optionsIndex = 0; index = 0; line = 0; // Create the keyboard, and take the measurements for it. string letterChars = "7 8 9\n4 5 6\n1 2 3\n- 0 ."; letters = letterChars.Split('\n'); foreach (char c in letterChars) { float width = ActiveFont.Measure(c).X; if (width > widestLetter) { widestLetter = width; } } widestLineCount = 0; foreach (string letter in letters) { if (letter.Length > widestLineCount) { widestLineCount = letter.Length; } } widestLine = widestLineCount * widestLetter; letterChars = null; boxPadding = widestLetter; keyboardWidth = widestLine + boxPadding * 2f; lineHeight = ActiveFont.LineHeight; lineSpacing = ActiveFont.LineHeight * 0.1f; // take the measurements for options. optionsScale = 0.75f; cancel = Dialog.Clean("name_back"); backspace = Dialog.Clean("name_backspace"); accept = Dialog.Clean("name_accept"); cancelWidth = ActiveFont.Measure(cancel).X *optionsScale; backspaceWidth = ActiveFont.Measure(backspace).X *optionsScale; acceptWidth = ActiveFont.Measure(accept).X *optionsScale; optionsWidth = cancelWidth + backspaceWidth + acceptWidth + widestLetter * 3f; boxWidth = Math.Max(widestLine, optionsWidth) + boxPadding * 2f; boxHeight = (letters.Length + 1f) * lineHeight + letters.Length * lineSpacing + boxPadding * 3f; Visible = true; // Ease the keyboard in. Vector2 posFrom = Position; Vector2 posTo = Vector2.Zero; for (float t = 0f; t < 1f; t += Engine.DeltaTime * 2f) { ease = Ease.CubeIn(t); Position = posFrom + (posTo - posFrom) * Ease.CubeInOut(t); yield return(null); } ease = 1f; posFrom = Vector2.Zero; posTo = Vector2.Zero; yield return(0.2f); Focused = true; yield return(0.2f); wiggler.Start(); }
public override void Render() { Level level = (Level)Scene; if (level.FrozenOrPaused || level.Completed) { return; } if (index <= 0f || alpha <= 0f) { return; } Camera camera = level.Camera; Vector2 pos = new Vector2((Memorial.X - camera.X) * 6f, (Memorial.Y - camera.Y) * 6f - 350f - ActiveFont.LineHeight * 3.3f); if (SaveData.Instance != null && SaveData.Instance.Assists.MirrorMode) { pos.X = 1920f - pos.X; } float alphaEased = Ease.CubeInOut(alpha); int length = (int)Math.Min(Message.Length, index); // Render the text twice. Once for the border, then once again properly. for (int mode = 0; mode < 2; mode++) { float sink = 64f * (1f - alphaEased); int lineLength = CountToNewline(0); int lineIndex = 0; int line = 0; float xNext = 0f; for (int i = 0; i < length; i++) { char c = Message[i]; if (c == '\n') { lineIndex = 0; line++; lineLength = CountToNewline(i + 1); sink += ActiveFont.LineHeight * 1.1f; xNext = 0f; continue; } if (!charChars.TryGetValue(c, out PixelFontCharacter pfc)) { continue; } float x = xNext - lineWidths[line] * 0.5f; xNext += pfc.XAdvance; if (i < Message.Length - 1 && pfc.Kerning.TryGetValue(Message[i + 1], out int kerning)) { xNext += kerning; } xNext += Spacing; float xScale = 1f; float yOffs = 0f; if (Dreamy && c != ' ' && c != '-' && c != '\n') { c = Message[(i + (int)(Math.Sin((timer * 2f + i / 8f)) * 4.0) + Message.Length) % Message.Length]; yOffs = (float)Math.Sin((timer * 2f + i / 8f)) * 8f; xScale = (Math.Sin((timer * 4f + i / 16f)) < 0.0) ? -1f : 1f; } if (mode == 0) { ActiveFont.DrawOutline(c.ToString(), pos + new Vector2(x, sink + yOffs), new Vector2(0f, 1f), new Vector2(xScale, 1f), Color.Transparent, 2f, Color.Black * alphaEased * alphaEased * alphaEased); } else { ActiveFont.DrawOutline(c.ToString(), pos + new Vector2(x, sink + yOffs), new Vector2(0f, 1f), new Vector2(xScale, 1f), Color.White * alphaEased, 2f, Color.Transparent); } lineIndex++; } } }
public new void BeforeRender(Scene scene) { if (vanillaMoonParticles == null) { // back up the vanilla particles. vanillaMoonParticles = (Engine.Scene as Overworld)?.Entities.OfType <MoonParticle3D>().First(); } string path; try { path = Path.Combine("Maps", SaveData.Instance?.LastArea.GetSID() ?? "").Replace('\\', '/'); } catch (ArgumentException) { path = "Maps"; } string SIDToUse = SaveData.Instance?.LastArea.GetSID() ?? ""; bool fadingIn = true; // Check if we're changing any mountain parameter // If so, we want to fade out and then back in if (PreviousSID != null && !(SaveData.Instance?.LastArea.GetSID() ?? "").Equals(PreviousSID)) { MapMetaMountain oldMountain = null; MapMetaMountain newMountain = null; if (SaveData.Instance != null && Everest.Content.TryGet(path, out ModAsset asset1)) { MapMeta meta; if (asset1 != null && (meta = asset1.GetMeta <MapMeta>()) != null && meta.Mountain != null) { newMountain = meta.Mountain; } } string oldPath; try { oldPath = Path.Combine("Maps", PreviousSID ?? "").Replace('\\', '/'); } catch (ArgumentException) { oldPath = "Maps"; } if (SaveData.Instance != null && Everest.Content.TryGet(oldPath, out asset1)) { MapMeta meta; if (asset1 != null && (meta = asset1.GetMeta <MapMeta>()) != null && meta.Mountain != null) { oldMountain = meta.Mountain; } } if (oldMountain?.MountainModelDirectory != newMountain?.MountainModelDirectory || oldMountain?.MountainTextureDirectory != newMountain?.MountainTextureDirectory || (oldMountain?.FogColors == null) != (newMountain?.FogColors == null) || // only fade to black if one end has custom fog colors and the other doesn't. oldMountain?.StarFogColor != newMountain?.StarFogColor || (oldMountain?.ShowSnow ?? true) != (newMountain?.ShowSnow ?? true) || !arrayEqual(oldMountain?.StarStreamColors, newMountain?.StarStreamColors) || !arrayEqual(oldMountain?.StarBeltColors1, newMountain?.StarBeltColors1) || !arrayEqual(oldMountain?.StarBeltColors2, newMountain?.StarBeltColors2)) { if (fade != 1f) { // fade out, and continue using the old mountain during the fadeout. SIDToUse = PreviousSID; path = oldPath; fade = Calc.Approach(fade, 1f, Engine.DeltaTime * 4f); fadingIn = false; } else { // start holding the black screen fadeHoldCountdown = .3f; } } } if (fadingIn && fade != 0f) { if (fadeHoldCountdown <= 0) { // fade in fade = Calc.Approach(fade, 0f, Engine.DeltaTime * 4f); } else { // hold the black screen fadeHoldCountdown -= Engine.DeltaTime; } } if (SaveData.Instance != null && Everest.Content.TryGet(path, out ModAsset asset)) { MapMeta meta; if (asset != null && (meta = asset.GetMeta <MapMeta>()) != null && meta.Mountain != null && hasCustomSettings(meta)) { // there is a custom mountain! render it, similarly to vanilla. MountainResources resources = MTNExt.MountainMappings[path]; ResetRenderTargets(); Quaternion rotation = Camera.Rotation; if (ignoreCameraRotation) { rotation = lastCameraRotation; } Matrix matrix = Matrix.CreatePerspectiveFieldOfView((float)Math.PI / 4f, (float)Engine.Width / (float)Engine.Height, 0.25f, 50f); Matrix matrix2 = Matrix.CreateTranslation(-Camera.Position) * Matrix.CreateFromQuaternion(rotation); Matrix matrix3 = matrix2 * matrix; Forward = Vector3.Transform(Vector3.Forward, Camera.Rotation.Conjugated()); Engine.Graphics.GraphicsDevice.SetRenderTarget(buffer); if (StarEase < 1f) { Matrix matrix4 = Matrix.CreateTranslation(0f, 5f - Camera.Position.Y * 1.1f, 0f) * Matrix.CreateFromQuaternion(rotation) * matrix; if (currState == nextState) { (resources.MountainStates?[currState] ?? mountainStates[currState]).Skybox.Draw(matrix4, Color.White); } else { (resources.MountainStates?[currState] ?? mountainStates[currState]).Skybox.Draw(matrix4, Color.White); (resources.MountainStates?[nextState] ?? mountainStates[nextState]).Skybox.Draw(matrix4, Color.White * easeState); } if (currState != nextState) { GFX.FxMountain.Parameters["ease"].SetValue(easeState); GFX.FxMountain.CurrentTechnique = GFX.FxMountain.Techniques["Easing"]; } else { GFX.FxMountain.CurrentTechnique = GFX.FxMountain.Techniques["Single"]; } Engine.Graphics.GraphicsDevice.DepthStencilState = DepthStencilState.Default; Engine.Graphics.GraphicsDevice.BlendState = BlendState.AlphaBlend; Engine.Graphics.GraphicsDevice.RasterizerState = MountainRasterizer; GFX.FxMountain.Parameters["WorldViewProj"].SetValue(matrix3); GFX.FxMountain.Parameters["fog"].SetValue(customFog.TopColor.ToVector3()); Engine.Graphics.GraphicsDevice.Textures[0] = (resources.MountainStates?[currState] ?? mountainStates[currState]).TerrainTexture.Texture; Engine.Graphics.GraphicsDevice.SamplerStates[0] = SamplerState.LinearClamp; if (currState != nextState) { Engine.Graphics.GraphicsDevice.Textures[1] = (resources.MountainStates?[nextState] ?? mountainStates[nextState]).TerrainTexture.Texture; Engine.Graphics.GraphicsDevice.SamplerStates[1] = SamplerState.LinearClamp; } (resources.MountainTerrain ?? MTN.MountainTerrain).Draw(GFX.FxMountain); GFX.FxMountain.Parameters["WorldViewProj"].SetValue(Matrix.CreateTranslation(CoreWallPosition) * matrix3); (resources.MountainCoreWall ?? MTN.MountainCoreWall).Draw(GFX.FxMountain); GFX.FxMountain.Parameters["WorldViewProj"].SetValue(matrix3); for (int i = 0; i < resources.MountainExtraModels.Count; i++) { Engine.Graphics.GraphicsDevice.Textures[0] = (resources.MountainExtraModelTextures[i][currState] ?? mountainStates[currState].TerrainTexture).Texture; Engine.Graphics.GraphicsDevice.SamplerStates[0] = SamplerState.LinearClamp; if (currState != nextState) { Engine.Graphics.GraphicsDevice.Textures[1] = (resources.MountainExtraModelTextures[i][nextState] ?? mountainStates[nextState].TerrainTexture).Texture; Engine.Graphics.GraphicsDevice.SamplerStates[1] = SamplerState.LinearClamp; } resources.MountainExtraModels[i].Draw(GFX.FxMountain); } GFX.FxMountain.Parameters["WorldViewProj"].SetValue(matrix3); Engine.Graphics.GraphicsDevice.Textures[0] = (resources.MountainStates?[currState] ?? mountainStates[currState]).BuildingsTexture.Texture; Engine.Graphics.GraphicsDevice.SamplerStates[0] = SamplerState.LinearClamp; if (currState != nextState) { Engine.Graphics.GraphicsDevice.Textures[1] = (resources.MountainStates?[nextState] ?? mountainStates[nextState]).BuildingsTexture.Texture; Engine.Graphics.GraphicsDevice.SamplerStates[1] = SamplerState.LinearClamp; } (resources.MountainBuildings ?? MTN.MountainBuildings).Draw(GFX.FxMountain); customFog.Draw(matrix3); } if (StarEase > 0f) { Draw.SpriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, SamplerState.LinearClamp, null, null); Draw.Rect(0f, 0f, buffer.Width, buffer.Height, Color.Black * Ease.CubeInOut(Calc.ClampedMap(StarEase, 0f, 0.6f))); Draw.SpriteBatch.End(); Matrix matrix5 = Matrix.CreateTranslation(starCenter - Camera.Position) * Matrix.CreateFromQuaternion(rotation) * matrix; float alpha = Calc.ClampedMap(StarEase, 0.8f, 1f); customStarsky.Draw(matrix5, CullCCRasterizer, alpha); customStarfog.Draw(matrix5, CullCCRasterizer, alpha); customStardots0.Draw(matrix5, CullCCRasterizer, alpha); customStarstream0.Draw(matrix5, CullCCRasterizer, alpha); customStarstream1.Draw(matrix5, CullCCRasterizer, alpha); customStarstream2.Draw(matrix5, CullCCRasterizer, alpha); Engine.Graphics.GraphicsDevice.DepthStencilState = DepthStencilState.Default; Engine.Graphics.GraphicsDevice.BlendState = BlendState.AlphaBlend; Engine.Graphics.GraphicsDevice.RasterizerState = CullCRasterizer; Engine.Graphics.GraphicsDevice.Textures[0] = (resources.MountainMoonTexture ?? MTN.MountainMoonTexture).Texture; Engine.Graphics.GraphicsDevice.SamplerStates[0] = SamplerState.LinearClamp; GFX.FxMountain.CurrentTechnique = GFX.FxMountain.Techniques["Single"]; GFX.FxMountain.Parameters["WorldViewProj"].SetValue(matrix3); GFX.FxMountain.Parameters["fog"].SetValue(fog.TopColor.ToVector3()); (resources.MountainMoon ?? MTN.MountainMoon).Draw(GFX.FxMountain); float num = birdTimer * 0.2f; Matrix matrix6 = Matrix.CreateScale(0.25f) * Matrix.CreateRotationZ((float)Math.Cos(num * 2f) * 0.5f) * Matrix.CreateRotationX(0.4f + (float)Math.Sin(num) * 0.05f) * Matrix.CreateRotationY(0f - num - (float)Math.PI / 2f) * Matrix.CreateTranslation((float)Math.Cos(num) * 2.2f, 31f + (float)Math.Sin(num * 2f) * 0.8f, (float)Math.Sin(num) * 2.2f); GFX.FxMountain.Parameters["WorldViewProj"].SetValue(matrix6 * matrix3); GFX.FxMountain.Parameters["fog"].SetValue(fog.TopColor.ToVector3()); (resources.MountainBird ?? MTN.MountainBird).Draw(GFX.FxMountain); } DrawBillboards(matrix3, scene.Tracker.GetComponents <Billboard>()); if (StarEase < 1f) { customFog2.Draw(matrix3, CullCRasterizer); } if (DrawDebugPoints && DebugPoints.Count > 0) { GFX.FxDebug.World = Matrix.Identity; GFX.FxDebug.View = matrix2; GFX.FxDebug.Projection = matrix; GFX.FxDebug.TextureEnabled = false; GFX.FxDebug.VertexColorEnabled = true; VertexPositionColor[] array = DebugPoints.ToArray(); foreach (EffectPass pass in GFX.FxDebug.CurrentTechnique.Passes) { pass.Apply(); Engine.Graphics.GraphicsDevice.DrawUserPrimitives(PrimitiveType.TriangleList, array, 0, array.Length / 3); } } GaussianBlur.Blur((RenderTarget2D)buffer, blurA, blurB, 0.75f, clear: true, samples: GaussianBlur.Samples.Five); // render the fade to black. Draw.SpriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, SamplerState.LinearClamp, null, null); Draw.Rect(-10f, -10f, 1940f, 1100f, Color.Black * fade); Draw.SpriteBatch.End(); // Initialize new custom fog and star belt when we switch between maps if (!(SIDToUse).Equals(PreviousSID)) { // save values to make transition smoother. Color fogColorBeforeReload = customFog?.TopColor ?? Color.White; float spinBeforeReload = customFog.Verts[1].TextureCoordinate.X; // build new objects with custom textures. customFog = new Ring(6f, -1f, 20f, 0f, 24, Color.White, resources.MountainFogTexture ?? MTN.MountainFogTexture); customFog2 = new Ring(6f, -4f, 10f, 0f, 24, Color.White, resources.MountainFogTexture ?? MTN.MountainFogTexture); customStarsky = new Ring(18f, -18f, 20f, 0f, 24, Color.White, Color.Transparent, resources.MountainSpaceTexture ?? MTN.MountainStarSky); customStarfog = new Ring(10f, -18f, 19.5f, 0f, 24, resources.StarFogColor ?? Calc.HexToColor("020915"), Color.Transparent, resources.MountainFogTexture ?? MTN.MountainFogTexture); customStardots0 = new Ring(16f, -18f, 19f, 0f, 24, Color.White, Color.Transparent, resources.MountainSpaceStarsTexture ?? MTN.MountainStars, 4f); customStarstream0 = new Ring(5f, -8f, 18.5f, 0.2f, 80, resources.StarStreamColors?[0] ?? Color.Black, resources.MountainStarStreamTexture ?? MTN.MountainStarStream); customStarstream1 = new Ring(4f, -6f, 18f, 1f, 80, resources.StarStreamColors?[1] ?? Calc.HexToColor("9228e2") * 0.5f, resources.MountainStarStreamTexture ?? MTN.MountainStarStream); customStarstream2 = new Ring(3f, -4f, 17.9f, 1.4f, 80, resources.StarStreamColors?[2] ?? Calc.HexToColor("30ffff") * 0.5f, resources.MountainStarStreamTexture ?? MTN.MountainStarStream); // restore values saved earlier. customFog.TopColor = customFog.BotColor = fogColorBeforeReload; customFog.Rotate(spinBeforeReload); customFog2.Rotate(spinBeforeReload); if (Engine.Scene is Overworld thisOverworld) { thisOverworld.Remove(customMoonParticles); if (resources.StarBeltColors1 != null && resources.StarBeltColors2 != null) { // there are custom moon particle colors. build the new particles and add them to the scene thisOverworld.Remove(vanillaMoonParticles); thisOverworld.Add(customMoonParticles = new patch_MoonParticle3D(this, new Vector3(0f, 31f, 0f), resources.StarBeltColors1, resources.StarBeltColors2)); } else { // there are no more moon particle colors. restore the vanilla particles customMoonParticles = null; thisOverworld.Add(vanillaMoonParticles); } } } PreviousSID = SIDToUse; return; } } // if we are here, it means we don't have a custom mountain. if (customMoonParticles != null && Engine.Scene is Overworld overworld) { // revert back the moon particles to vanilla. overworld.Remove(customMoonParticles); customMoonParticles = null; overworld.Add(vanillaMoonParticles); } // run vanilla code. orig_BeforeRender(scene); // render the fade to black. Draw.SpriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, SamplerState.LinearClamp, null, null); Draw.Rect(-10f, -10f, 1940f, 1100f, Color.Black * fade); Draw.SpriteBatch.End(); PreviousSID = SIDToUse; }