public void HookPageGrafUpdate(On.Menu.SlugcatSelectMenu.SlugcatPage.orig_GrafUpdate orig, SlugcatSelectMenu.SlugcatPage instance, float timeStacker) { float num = instance.Scroll(timeStacker); float num2 = instance.UseAlpha(timeStacker); float depth = instance.slugcatDepth; if (instance.HasMark) { float num3 = Mathf.Lerp(instance.lastMarkAlpha, instance.markAlpha, timeStacker) * num2; if (instance.slugcatNumber == 2) { num3 *= ((!(instance is SlugcatSelectMenu.SlugcatPageContinue)) ? 0f : Mathf.Pow(Mathf.InverseLerp(4f, 14f, (float)(instance as SlugcatSelectMenu.SlugcatPageContinue).saveGameData.cycle), 3.5f)); } Vector2 a = new Vector2(instance.MidXpos + num * instance.ScrollMagnitude, instance.imagePos.y + 150f) + instance.markOffset; a -= instance.slugcatImage.CamPos(timeStacker) * 80f / depth; a -= new Vector2(0, artOffset); instance.markSquare.x = a.x; instance.markSquare.y = a.y; instance.markSquare.alpha = Mathf.Pow(num3, 0.75f); instance.markGlow.x = a.x; instance.markGlow.y = a.y; instance.markGlow.scale = Mathf.Lerp(3f, 3.3f, Mathf.Pow(num3, 0.2f)) + ((!instance.HasGlow) ? 0f : -0.5f) + Mathf.Lerp(-0.1f, 0.1f, UnityEngine.Random.value) * instance.markFlicker; instance.markGlow.alpha = ((instance.slugcatNumber != 0) ? 0.6f : 0.4f) * Mathf.Pow(num3, 0.75f); } if (instance.HasGlow) { float num4 = Mathf.Lerp(0.8f, 1f, Mathf.Lerp(instance.lastGlowAlpha, instance.glowAlpha, timeStacker)) * num2 * Mathf.Lerp(instance.lastInposition, instance.inPosition, timeStacker); Vector2 a2 = new Vector2(instance.MidXpos + num * instance.ScrollMagnitude, instance.imagePos.y) + instance.glowOffset; a2 -= instance.slugcatImage.CamPos(timeStacker) * 80f / depth; a2 -= new Vector2(0, artOffset); instance.glowSpriteB.color = Color.Lerp(instance.effectColor, new Color(1f, 1f, 1f), 0.3f * num4); instance.glowSpriteB.x = a2.x; instance.glowSpriteB.y = a2.y; instance.glowSpriteB.scale = Mathf.Lerp(20f, 38f, Mathf.Pow(num4, 0.75f)); instance.glowSpriteB.alpha = Mathf.Pow(num4, 0.25f) * Mathf.Lerp(0.394f, 0.406f, UnityEngine.Random.value * (1f - Mathf.Lerp(instance.lastGlowAlpha, instance.glowAlpha, timeStacker))); instance.glowSpriteA.color = Color.Lerp(instance.effectColor, new Color(1f, 1f, 1f), 0.9f * num4); instance.glowSpriteA.x = a2.x; instance.glowSpriteA.y = a2.y; instance.glowSpriteA.scale = Mathf.Lerp(10f, 17f, Mathf.Pow(num4, 1.2f)); instance.glowSpriteA.alpha = num4 * 0.6f; } for (int i = 0; i < instance.slugcatImage.depthIllustrations.Count; i++) { Vector2 a3 = instance.slugcatImage.depthIllustrations[i].pos; a3 -= new Vector2(0, artOffset); a3 -= instance.slugcatImage.CamPos(timeStacker) * 80f / instance.slugcatImage.depthIllustrations[i].depth; a3 += instance.sceneOffset; a3.x += num * instance.ScrollMagnitude; instance.slugcatImage.depthIllustrations[i].sprite.x = a3.x; instance.slugcatImage.depthIllustrations[i].sprite.y = a3.y; instance.slugcatImage.depthIllustrations[i].sprite.alpha = instance.slugcatImage.depthIllustrations[i].alpha * num2; } for (int j = 0; j < instance.slugcatImage.flatIllustrations.Count; j++) { Vector2 a4 = instance.slugcatImage.flatIllustrations[j].pos; a4 -= new Vector2(0, artOffset); a4 += instance.sceneOffset; a4.x += num * instance.ScrollMagnitude; instance.slugcatImage.flatIllustrations[j].sprite.x = a4.x; instance.slugcatImage.flatIllustrations[j].sprite.y = a4.y; instance.slugcatImage.flatIllustrations[j].sprite.alpha = instance.slugcatImage.flatIllustrations[j].alpha * num2; } if (instance.slugcatImage.depthIllustrations.Count > 0) { int lastIndex = instance.slugcatImage.depthIllustrations.Count - 1; if (customArtSprite != null) { customArtSprite.RemoveFromContainer(); Vector2 a3 = new Vector2(Futile.screen.width / 2, Futile.screen.height / 2); a3 += new Vector2(0, (Futile.screen.height * 2) - artOffset); customArtSprite.x = a3.x; customArtSprite.y = a3.y; customArtSprite.width = 400f; customArtSprite.height = 400f; customArtSprite.y += customArtSprite.height / 6; instance.slugcatImage.depthIllustrations[lastIndex].sprite.container.AddChild(customArtSprite); customArtSprite.MoveToBack(); customArtSprite.MoveInFrontOfOtherNode(instance.slugcatImage.depthIllustrations[lastIndex].sprite); } } }
private static IEnumerator AnimateScreens(bool cover = false) { if (isAnimating) { yield return(null); } isAnimating = true; if (lastScreen != null) { lastScreen.willHide(); } currentScreen.willShow(); if (cover && backdrop != null) { currentScreen.AddChild(backdrop); backdrop.MoveToBack(); } Futile.stage.AddChild(currentScreen); //ideally would put these in sub-functions, but not sure how that plays with the C# yields //would also prefer to rewrite this to not assume(0,0) as the target, but zoom to any target if (defaultAnimationType == AnimationType.Linear) { while (currentScreen.x != 0f || currentScreen.y != 0f) { if (currentScreen.x > 0f) { if (lastScreen != null && !cover) { lastScreen.x -= Mathf.Min(currentScreen.x, PUSH_SPEED_X); } currentScreen.x -= Mathf.Min(currentScreen.x, PUSH_SPEED_X); } else if (currentScreen.x < 0f) { if (lastScreen != null && !cover) { lastScreen.x -= Mathf.Max(currentScreen.x, -1f * PUSH_SPEED_X); } currentScreen.x -= Mathf.Max(currentScreen.x, -1f * PUSH_SPEED_X); } if (currentScreen.y > 0f) { if (lastScreen != null && !cover) { lastScreen.y -= Mathf.Min(currentScreen.y, PUSH_SPEED_Y); } currentScreen.y -= Mathf.Min(currentScreen.y, PUSH_SPEED_Y); } else if (currentScreen.y < 0f) { if (lastScreen != null && !cover) { lastScreen.y -= Mathf.Max(currentScreen.y, -1f * PUSH_SPEED_Y); } currentScreen.y -= Mathf.Max(currentScreen.y, -1f * PUSH_SPEED_Y); } yield return(new WaitForEndOfFrame()); } } else if (defaultAnimationType == AnimationType.Interpolated) { while (currentScreen.x != 0.0f || currentScreen.y != 0.0f) { if (Mathf.Abs(currentScreen.x) > 0.0f) { float dx = (0.0f - currentScreen.x) / INTERPOLATION; // Debug.Log ("DX = " + dx); currentScreen.x += dx; if (lastScreen != null && !cover) { lastScreen.x += dx; } if (Mathf.Abs(currentScreen.x) < CLOSE_ENOUGH) { currentScreen.x = 0.0f; } } if (Mathf.Abs(currentScreen.y) > 0.0f) { float dy = (0.0f - currentScreen.y) / INTERPOLATION; currentScreen.y += dy; if (lastScreen != null && !cover) { lastScreen.y += dy; } if (Mathf.Abs(currentScreen.y) < CLOSE_ENOUGH) { currentScreen.y = 0.0f; } } yield return(new WaitForEndOfFrame()); } } else { throw new FutileException("Invalid animation type set in ScreenManager!"); } if (lastScreen != null) { lastScreen.RemoveFromContainer(); lastScreen.didHide(); } if (backdrop != null) { currentScreen.RemoveChild(backdrop); } currentScreen.didShow(); isAnimating = false; }