public void Awake() { gameEnd = false; stopped = true; textToggle = true; _remastered = DebugManager.remastered; lastCostume = null; var ar = AspectRatio.GetAspectRatio(Screen.width, Screen.height); if (ar.x == 16f && ar.y == 9f) { wideAspect = true; } Logger.LogDebug($"Wide Aspect: {wideAspect}"); DontDestroyOnLoad(gameObject); if (OverlayCanvas == null) { CanvasUtil.CreateFonts(); OverlayCanvas = CanvasUtil.CreateCanvas(RenderMode.ScreenSpaceOverlay, new Vector2(1920, 1080)); OverlayCanvas.name = "IGTDisplay"; DontDestroyOnLoad(OverlayCanvas); _background = CanvasUtil.CreateImagePanel(OverlayCanvas, new Color32(0x28, 0x28, 0x28, 0x00), wideAspect ? topRightLegacy : topRightHD); _textPanel = CanvasUtil.CreateTMProPanel(_background, string.Empty, 24, TextAnchor.UpperLeft, new CanvasUtil.RectData(new Vector2(-5, -5), new Vector2(0, 0), new Vector2(0, 0), new Vector2(1, 1))); tmProObjRef = _textPanel.GetComponent <TextMeshProUGUI>(); tmProObjRef.alignment = TextAlignmentOptions.TopRight; } }
public void EnableRedwing() { _isEnabled = true; textures.loadAllTextures(); ModHooks.Instance.FocusCostHook += InstanceOnFocusCostHook; ModHooks.Instance.BeforeAddHealthHook += InstanceOnBeforeAddHealthHook; ModHooks.Instance.AttackHook += InstanceOnAttackHook; ModHooks.Instance.CharmUpdateHook += RedwingLance; ModHooks.Instance.DashPressedHook += NoDashWhileHoldingUp; On.HeroController.JumpReleased += NoVelocityResetOnReleaseWithJetpack; On.NailSlash.StartSlash += NailSlashOnStartSlash; ModCommon.ModCommon.OnSpellHook += OverwriteSpells; On.HeroController.CancelHeroJump += DontCancelWithJetpack; On.HeroController.AffectedByGravity += AffectedByGravityIsShit; On.HeroController.Jump += RocketJumpIfRocketJumping; canvasObj = CanvasUtil.CreateCanvas(RenderMode.ScreenSpaceOverlay, new Vector2(1920f, 1080f)); FireBar = CanvasUtil.CreateImagePanel(canvasObj, Sprite.Create(Texture2D.whiteTexture, new Rect(0, 0, 1, 1), new Vector2(0.5f, 0.5f)), new CanvasUtil.RectData(new Vector2(300f, 100f), new Vector2(0.9f, 0.9f), new Vector2(0.910f, 0.89f), new Vector2(0.910f, 0.89f))); DontDestroyOnLoad(canvasObj); DontDestroyOnLoad(FireBar); FireBarImage = FireBar.GetComponent <Image>(); FireBarImage.preserveAspect = false; FireBarImage.type = Image.Type.Filled; FireBarImage.fillMethod = Image.FillMethod.Horizontal; FireBarImage.fillAmount = (float)firePower; StartCoroutine(AddHeroHooks()); }
public void SetupCanvasIcon() { Vector2 anchor = new Vector2(x, y); GameObject canvasSprite = CanvasUtil.CreateImagePanel ( _canvas, SpriteLoader.GetSprite(spriteName), new CanvasUtil.RectData(Vector2.zero, Vector2.zero, anchor, anchor + new Vector2(1f / 15f, 0.1f)) ); // Add a canvas group so we can fade it in and out canvasGroup = canvasSprite.AddComponent <CanvasGroup>(); canvasGroup.blocksRaycasts = false; canvasGroup.interactable = false; if (!BingoUI.globalSettings.alwaysDisplay) { canvasGroup.gameObject.SetActive(false); } GameObject text = CanvasUtil.CreateTextPanel ( canvasSprite, "0", 23, TextAnchor.LowerCenter, new CanvasUtil.RectData(Vector2.zero, Vector2.zero, Vector2.zero, Vector2.one) ); textPanel = text.GetComponent <Text>(); textPanel.color = Color.black; }
private void setupFlameGauge() { GameObject flameGaugeDisplay = CanvasUtil.CreateCanvas(RenderMode.ScreenSpaceOverlay, new Vector2(1920, 1080)); GameObject flameGauge = CanvasUtil.CreateImagePanel(flameGaugeDisplay, Sprite.Create(load_textures.SOUL_HOLDER[0], new Rect(0, 0, load_textures.SOUL_HOLDER[0].width, load_textures.SOUL_HOLDER[0].height), new Vector2(0.5f, 0.5f)), new CanvasUtil.RectData( new Vector2(0, 0), new Vector2(0, 0), new Vector2(0, 0), new Vector2(0.05f, 0.05f))); flameGaugeControl = flameGauge.AddComponent <flame_gauge>(); GameCameras.instance.hudCanvas.PrintSceneHierarchyTree("hud.txt"); }
public void Awake() { Logger.LogDebug($@"Creating HP Bar for {name}"); // On.CameraController.FadeOut += CameraController_FadeOut; screenScale = new Vector2(Screen.width / 1280f * 0.025f, Screen.height / 720f * 0.025f); bg_go = CanvasUtil.CreateImagePanel(EnemyHPBar.canvas, EnemyHPBar.bg, new CanvasUtil.RectData(Vector2.Scale(new Vector2(EnemyHPBar.bg.texture.width, EnemyHPBar.bg.texture .height), screenScale * bgScale), new Vector2(0, 32))); mg_go = CanvasUtil.CreateImagePanel(EnemyHPBar.canvas, EnemyHPBar.mg, new CanvasUtil.RectData(Vector2.Scale(new Vector2(EnemyHPBar.mg.texture.width, EnemyHPBar.mg.texture .height), screenScale * mgScale), new Vector2(0, 32))); fg_go = CanvasUtil.CreateImagePanel(EnemyHPBar.canvas, EnemyHPBar.fg, new CanvasUtil.RectData(Vector2.Scale(new Vector2(EnemyHPBar.fg.texture.width, EnemyHPBar.fg.texture .height), screenScale * fgScale), new Vector2(0, 32))); ol_go = CanvasUtil.CreateImagePanel(EnemyHPBar.canvas, EnemyHPBar.ol, new CanvasUtil.RectData(Vector2.Scale(new Vector2(EnemyHPBar.ol.texture.width, EnemyHPBar.ol.texture .height), screenScale * olScale), new Vector2(0, 32))); bg_cr = bg_go.GetComponent <CanvasRenderer>(); fg_cr = fg_go.GetComponent <CanvasRenderer>(); mg_cr = mg_go.GetComponent <CanvasRenderer>(); ol_cr = ol_go.GetComponent <CanvasRenderer>(); hpbg = mg_go.GetComponent <Image>(); hpbg.type = Image.Type.Filled; hpbg.fillMethod = Image.FillMethod.Horizontal; hpbg.preserveAspect = false; health_bar = fg_go.GetComponent <Image>(); health_bar.type = Image.Type.Filled; health_bar.fillMethod = Image.FillMethod.Horizontal; health_bar.preserveAspect = false; bg_go.GetComponent <Image>().preserveAspect = false; ol_go.GetComponent <Image>().preserveAspect = false; hm = gameObject.GetComponent <HealthManager>(); SetHPBarAlpha(0); maxHP = hm.hp; currHP = hm.hp; }
private IEnumerator showFailureScreen() { yield return(new WaitForFinishedEnteringScene()); yield return(new WaitForSeconds(0.4f)); winLossCanvas = CanvasUtil.CreateCanvas(RenderMode.ScreenSpaceOverlay, new Vector2(1920f, 1080f)); winLossBlanker = CanvasUtil.CreateImagePanel(winLossCanvas, Sprite.Create(Texture2D.whiteTexture, new Rect(0, 0, 1, 1), new Vector2(0.5f, 0.5f)), new CanvasUtil.RectData(new Vector2(4000f, 2000f), new Vector2(0.5f, 0.5f), new Vector2(0f, 0f), new Vector2(1f, 1))); Image img = winLossBlanker.GetComponent <Image>(); winLossText = CanvasUtil.CreateTextPanel(winLossCanvas, "", 42, TextAnchor.MiddleCenter, new CanvasUtil.RectData(new Vector2(400f, 150f), new Vector2(0.5f, 0.5f), new Vector2(0.5f, 0.2f), new Vector2(0.5f, 0.2f))); Text t = winLossText.GetComponent <Text>(); t.text = "Failed!\nBest combo: " + godmasterBestCombo + "\nTotal hits: " + godmasterTotalHits; Color c = img.color; c.g = 0f; c.b = 0f; c.r = 0f; c.a = 1f; img.color = c; yield return(new WaitForSeconds(3.5f)); const float fadeTime = 4f; for (float time = 0f; time < fadeTime; time += Time.deltaTime) { c.a = ((fadeTime - time) / fadeTime); img.color = c; yield return(null); } Destroy(winLossBlanker); Destroy(winLossText); Destroy(winLossCanvas); }
private void BuildItemImages() { if (itemImages != null && itemImages.Length > 0) { foreach (GameObject obj in itemImages) { Destroy(obj); } } itemImages = new GameObject[validItems.Length, 4]; for (int i = 0; i < itemImages.GetLength(0); i++) { itemImages[i, 0] = CanvasUtil.CreateImagePanel(gameObject, RandomizerMod.GetSprite(items[validItems[i]].SpriteName), new CanvasUtil.RectData(new Vector2(90, 90), Vector2.zero, new Vector2(0.525f, 0f), new Vector2(0.525f, 0f))); itemImages[i, 1] = CanvasUtil.CreateImagePanel(gameObject, geoSprite, new CanvasUtil.RectData(new Vector2(50, 50), Vector2.zero, new Vector2(0.57f, 0f), new Vector2(0.57f, 0f))); int cost = (int)(items[validItems[i]].Cost * (items[validItems[i]].DungDiscount ? 0.75f : 1)); itemImages[i, 2] = CanvasUtil.CreateTextPanel(gameObject, cost.ToString(), 34, TextAnchor.MiddleCenter, new CanvasUtil.RectData(new Vector2(1920, 1080), Vector2.zero, new Vector2(0.61f, 0f), new Vector2(0.61f, 0f)), Fonts.Get("Perpetua")); if (type == ShopType.Geo && cost > Ref.PD.geo || type == ShopType.Essence && cost > Ref.PD.dreamOrbs) { itemImages[i, 3] = CanvasUtil.CreateImagePanel(gameObject, blackPixel, new CanvasUtil.RectData(new Vector2(300, 100), Vector2.zero, new Vector2(0.57f, 0f), new Vector2(0.57f, 0f))); itemImages[i, 3].GetComponent <Image>().preserveAspect = false; } } foreach (GameObject obj in itemImages) { obj.SetActive(false); } }
public void Awake() { Logger.LogDebug($@"Creating Boss HP Bar for {name}"); screenScale = new Vector2(Screen.width / 1280f, Screen.height / 720f); bg_go = CanvasUtil.CreateImagePanel(EnemyHPBar.bossCanvas, EnemyHPBar.bossbg, new CanvasUtil.RectData(Vector2.Scale(new Vector2(EnemyHPBar.bossbg.texture.width, EnemyHPBar.bossbg .texture.height), screenScale * bossbgScale), new Vector2(0f, 32f), new Vector2(0.5f, 0f), new Vector2(0.5f, 0f))); fg_go = CanvasUtil.CreateImagePanel(EnemyHPBar.bossCanvas, EnemyHPBar.bossfg, new CanvasUtil.RectData(Vector2.Scale(new Vector2(EnemyHPBar.bossfg.texture.width, EnemyHPBar.bossfg .texture.height), screenScale * bossfgScale), new Vector2(0f, 32f), new Vector2(0.5f, 0f), new Vector2(0.5f, 0f))); ol_go = CanvasUtil.CreateImagePanel(EnemyHPBar.bossCanvas, EnemyHPBar.bossol, new CanvasUtil.RectData(Vector2.Scale(new Vector2(EnemyHPBar.bossol.texture.width, EnemyHPBar.bossol .texture.height), screenScale * bossolScale), new Vector2(0f, 32f), new Vector2(0.5f, 0f), new Vector2(0.5f, 0f))); bg_cr = bg_go.GetComponent <CanvasRenderer>(); fg_cr = fg_go.GetComponent <CanvasRenderer>(); ol_cr = ol_go.GetComponent <CanvasRenderer>(); objectPos = fg_go.transform.position; health_bar = fg_go.GetComponent <Image>(); health_bar.type = Image.Type.Filled; health_bar.fillMethod = Image.FillMethod.Horizontal; health_bar.preserveAspect = false; bg_go.GetComponent <Image>().preserveAspect = false; ol_go.GetComponent <Image>().preserveAspect = false; hm = gameObject.GetComponent <HealthManager>(); SetHPBarAlpha(0); maxHP = hm.hp; currHP = hm.hp; }
public static void AddItem(string item, string location) { if (canvas == null) { Create(); } item = RandomizerMod.Instance.Settings.GetEffectiveItem(item); string itemName = Language.Language.Get(LogicManager.GetItemDef(item).nameKey, "UI"); string areaName = LogicManager.ShopNames.Contains(location) ? location.Replace('_', ' ') : RandoLogger.CleanAreaName(LogicManager.GetItemDef(location).areaName); string msg = itemName + "\nfrom " + areaName; GameObject basePanel = CanvasUtil.CreateBasePanel(canvas, new CanvasUtil.RectData(new Vector2(200, 50), Vector2.zero, new Vector2(0.9f, 0.9f), new Vector2(0.9f, 0.9f))); string spriteKey = LogicManager.GetItemDef(item).shopSpriteKey; CanvasUtil.CreateImagePanel(basePanel, RandomizerMod.GetSprite(spriteKey), new CanvasUtil.RectData(new Vector2(50, 50), Vector2.zero, new Vector2(0f, 0.5f), new Vector2(0f, 0.5f))); CanvasUtil.CreateTextPanel(basePanel, msg, 24, TextAnchor.MiddleLeft, new CanvasUtil.RectData(new Vector2(400, 100), Vector2.zero, new Vector2(1.2f, 0.5f), new Vector2(1.2f, 0.5f)), CanvasUtil.GetFont("Perpetua")); items.Enqueue(basePanel); if (items.Count > MaxItems) { Object.Destroy(items.Dequeue()); } UpdatePositions(); }
public void Awake() { DontDestroyOnLoad(gameObject); if (OverlayCanvas == null) { CanvasUtil.CreateFonts(); OverlayCanvas = CanvasUtil.CreateCanvas(RenderMode.ScreenSpaceOverlay, new Vector2(1920, 1080)); OverlayCanvas.name = "DebugMenu"; DontDestroyOnLoad(OverlayCanvas); GameObject _background = CanvasUtil.CreateImagePanel(OverlayCanvas, new Color32(0x28, 0x28, 0x28, 0x00), topRight); _textPanel = CanvasUtil.CreateTMProPanel(_background, string.Empty, 20, TextAnchor.UpperLeft, new CanvasUtil.RectData(new Vector2(-5, -5), new Vector2(0, 0), new Vector2(0, 0), new Vector2(1, 1))); textComp = _textPanel.GetComponent <TextMeshProUGUI>(); } foreach (string fn in Assembly.GetExecutingAssembly().GetManifestResourceNames()) { if (fn.Contains("glass") || fn.Contains("talkVol")) { using (Stream imageStream = Assembly.GetExecutingAssembly().GetManifestResourceStream(fn)) { byte[] imageBuffer = new byte[imageStream.Length]; imageStream.Read(imageBuffer, 0, imageBuffer.Length); imageStream.Flush(); var assetName = fn.Contains("glass") ? "glass" : "talkVol"; modTextures[assetName] = new Texture2D(1, 1); modTextures[assetName].LoadImage(imageBuffer); Logger.Log($"Loaded Texture: {assetName}"); } } } warpCam = gameObject.AddComponent <Camera>(); warpCam.rect = new Rect(0.75f, 0f, .25f, .25f); warpCam.transform.position = Vector3.zero; warpCam.enabled = false; }
private static IEnumerator DrawCenterLines() { ScreenshotMachine.Log("Drawing middle intersection lines..."); GameObject lineCanvas = CanvasUtil.CreateCanvas(RenderMode.ScreenSpaceCamera, new Vector2(1920, 1080)); GameObject lines = CanvasUtil.CreateImagePanel(lineCanvas, LineSprite, new CanvasUtil.RectData(Vector2.zero, Vector2.zero, Vector2.zero, Vector2.one)); lines.gameObject.AddComponent <CanvasGroup>(); CanvasGroup group = lines.gameObject.GetComponent <CanvasGroup>(); group.interactable = false; group.blocksRaycasts = false; yield return(new WaitUntil(() => !_lineDrawn)); ScreenshotMachine.Log("Destroying middle intersection lines..."); Object.Destroy(lines); }
private IEnumerator ShowShop() { GameObject background = CanvasUtil.CreateImagePanel(gameObject, RandomizerMod.GetSprite("UI.Shop.Background"), new CanvasUtil.RectData(new Vector2(810, 813), Vector2.zero, new Vector2(0.675f, 0.525f), new Vector2(0.675f, 0.525f))); GameObject bottomFleur = CanvasUtil.CreateImagePanel(gameObject, RandomizerMod.GetSprite("Anim.Shop.BottomFleur.0"), new CanvasUtil.RectData(new Vector2(811, 241), Vector2.zero, new Vector2(0.675f, 0.3f), new Vector2(0.675f, 0.3f))); StartCoroutine(AnimateImage(bottomFleur, bottomFrames, 12)); StartCoroutine(TweenY(bottomFleur, 0.3f, 0.2f, 60, 15)); GameObject topFleur = CanvasUtil.CreateImagePanel(gameObject, RandomizerMod.GetSprite("Anim.Shop.TopFleur.0"), new CanvasUtil.RectData(new Vector2(808, 198), Vector2.zero, new Vector2(0.675f, 0.6f), new Vector2(0.675f, 0.6f))); StartCoroutine(AnimateImage(topFleur, topFrames, 12)); StartCoroutine(TweenY(topFleur, 0.6f, 0.85f, 60, 15)); yield return(StartCoroutine(CanvasUtil.FadeInCanvasGroup(background.AddComponent <CanvasGroup>()))); CanvasUtil.CreateImagePanel(gameObject, RandomizerMod.GetSprite("UI.Shop.Selector"), new CanvasUtil.RectData(new Vector2(340, 113), Vector2.zero, new Vector2(0.57f, 0.5825f), new Vector2(0.57f, 0.5825f))); CanvasUtil.CreateImagePanel(gameObject, RandomizerMod.GetSprite("UI.Shop.Shitpost"), new CanvasUtil.RectData(new Vector2(112, 112), Vector2.zero, new Vector2(0.6775f, 0.92f), new Vector2(0.6775f, 0.92f))); ResetItems(); StartCoroutine(ListenForInput()); }
public static (GameObject bg, GameObject interact_bg) CreateBackgrounds(GameObject canvas) { GameObject bg = CanvasUtil.CreateImagePanel ( canvas, CanvasUtil.NullSprite(new byte[] { 0, 0, 0, 64 }), new CanvasUtil.RectData ( new Vector2(600, 600), // Anchor bottom left to the top-right minus the size new Vector2(1920 - 600, 1080 - 600), Vector2.zero, Vector2.zero, Vector2.zero ) ); bg.GetComponent <Image>().preserveAspect = false; GameObject interact_bg = CanvasUtil.CreateImagePanel ( canvas, CanvasUtil.NullSprite(new byte[] { 0, 0, 0, 96 }), new CanvasUtil.RectData ( new Vector2(600, 600), // Same anchor as before, but minus the (y) size again so it's beneath the previous box. new Vector2(1920 - 600, 1080 - 600 - 20), Vector2.zero, Vector2.zero, Vector2.zero ) ); return(bg, interact_bg); }
private IEnumerator ShowPopup() { // Check for skipping popup Coroutine skipCoroutine = StartCoroutine(LookForShowInstantly()); // Begin dimming the scene GameObject dimmer = CanvasUtil.CreateImagePanel(gameObject, BlackPixel, new CanvasUtil.RectData(Vector2.zero, Vector2.zero, Vector2.zero, Vector2.one)); dimmer.GetComponent <Image>().preserveAspect = false; CanvasGroup dimmerCG = dimmer.AddComponent <CanvasGroup>(); dimmerCG.blocksRaycasts = false; dimmerCG.interactable = false; dimmerCG.alpha = 0; StartCoroutine(FadeInCanvasGroup(dimmerCG)); yield return(WaitForSeconds(0.1f)); // Aim for 400 high prompt image float scaler = _imagePrompt.texture.height / 400f; Vector2 size = new Vector2(_imagePrompt.texture.width / scaler, _imagePrompt.texture.height / scaler); // Begin fading in the top bits of the popup GameObject topImage = CanvasUtil.CreateImagePanel(gameObject, _imagePrompt, new CanvasUtil.RectData(size, Vector2.zero, new Vector2(0.5f, 0.75f), new Vector2(0.5f, 0.8f))); GameObject topTextOne = CanvasUtil.CreateTextPanel(gameObject, _takeText, 34, TextAnchor.MiddleCenter, new CanvasUtil.RectData(new Vector2(1920, 100), Vector2.zero, new Vector2(0.5f, 0.55f), new Vector2(0.5f, 0.55f)), Fonts.Get("Perpetua")); GameObject topTextTwo = CanvasUtil.CreateTextPanel(gameObject, _nameText, 76, TextAnchor.MiddleCenter, new CanvasUtil.RectData(new Vector2(1920, 300), Vector2.zero, new Vector2(0.5f, 0.49f), new Vector2(0.5f, 0.49f))); CanvasGroup topImageCG = topImage.AddComponent <CanvasGroup>(); CanvasGroup topTextOneCG = topTextOne.AddComponent <CanvasGroup>(); CanvasGroup topTextTwoCG = topTextTwo.AddComponent <CanvasGroup>(); topImageCG.blocksRaycasts = false; topImageCG.interactable = false; topImageCG.alpha = 0; topTextOneCG.blocksRaycasts = false; topTextOneCG.interactable = false; topTextOneCG.alpha = 0; topTextTwoCG.blocksRaycasts = false; topTextTwoCG.interactable = false; topTextTwoCG.alpha = 0; StartCoroutine(FadeInCanvasGroup(topImageCG)); StartCoroutine(FadeInCanvasGroup(topTextOneCG)); yield return(StartCoroutine(FadeInCanvasGroup(topTextTwoCG))); // Animate the middle fleur GameObject fleur = CanvasUtil.CreateImagePanel(gameObject, Frames[0], new CanvasUtil.RectData(new Vector2(Frames[0].texture.width / 1.6f, Frames[0].texture.height / 1.6f), Vector2.zero, new Vector2(0.5f, 0.4125f), new Vector2(0.5f, 0.4125f))); yield return(StartCoroutine(AnimateFleur(fleur, 12))); yield return(WaitForSeconds(0.25f)); // Fade in the remaining text GameObject botTextOne = CanvasUtil.CreateTextPanel(gameObject, _buttonText, 34, TextAnchor.MiddleCenter, new CanvasUtil.RectData(new Vector2(1920, 100), Vector2.zero, new Vector2(0.5f, 0.335f), new Vector2(0.5f, 0.335f)), Fonts.Get("Perpetua")); GameObject botTextTwo = CanvasUtil.CreateTextPanel(gameObject, _descOneText, 34, TextAnchor.MiddleCenter, new CanvasUtil.RectData(new Vector2(1920, 100), Vector2.zero, new Vector2(0.5f, 0.26f), new Vector2(0.5f, 0.26f)), Fonts.Get("Perpetua")); GameObject botTextThree = CanvasUtil.CreateTextPanel(gameObject, _descTwoText, 34, TextAnchor.MiddleCenter, new CanvasUtil.RectData(new Vector2(1920, 100), Vector2.zero, new Vector2(0.5f, 0.205f), new Vector2(0.5f, 0.205f)), Fonts.Get("Perpetua")); CanvasGroup botTextOneCG = botTextOne.AddComponent <CanvasGroup>(); CanvasGroup botTextTwoCG = botTextTwo.AddComponent <CanvasGroup>(); CanvasGroup botTextThreeCG = botTextThree.AddComponent <CanvasGroup>(); botTextOneCG.blocksRaycasts = false; botTextOneCG.interactable = false; botTextOneCG.alpha = 0; botTextTwoCG.blocksRaycasts = false; botTextTwoCG.interactable = false; botTextTwoCG.alpha = 0; botTextThreeCG.blocksRaycasts = false; botTextThreeCG.interactable = false; botTextThreeCG.alpha = 0; yield return(StartCoroutine(FadeInCanvasGroup(botTextOneCG))); StartCoroutine(FadeInCanvasGroup(botTextTwoCG)); yield return(StartCoroutine(FadeInCanvasGroup(botTextThreeCG))); yield return(WaitForSeconds(1.5f)); // Can I offer you an egg in this trying time? GameObject egg = CanvasUtil.CreateImagePanel(gameObject, AreaRando.GetSprite("UI.egg"), new CanvasUtil.RectData( new Vector2(AreaRando.GetSprite("UI.egg").texture.width / 1.65f, AreaRando.GetSprite("UI.egg").texture.height / 1.65f), Vector2.zero, new Vector2(0.5f, 0.1075f), new Vector2(0.5f, 0.1075f))); CanvasGroup eggCG = egg.AddComponent <CanvasGroup>(); eggCG.blocksRaycasts = false; eggCG.interactable = false; eggCG.alpha = 0; // Should wait for one fade in, don't want to poll input immediately yield return(FadeInCanvasGroup(eggCG)); // Stop doing things instantly before polling input if (!_showInstantly) { StopCoroutine(skipCoroutine); } _showInstantly = false; // Save the coroutine to stop it later Coroutine coroutine = StartCoroutine(BlinkCanvasGroup(eggCG)); // Wait for the user to cancel the menu while (true) { HeroActions actions = Ref.Input.inputActions; if (actions.jump.WasPressed || actions.attack.WasPressed || actions.menuCancel.WasPressed) { break; } yield return(new WaitForEndOfFrame()); } // Fade out the full popup yield return(FadeOutCanvasGroup(gameObject.GetComponent <CanvasGroup>())); // Small delay before hero control yield return(WaitForSeconds(0.75f)); // Optionally send FSM event after finishing if (_fsmObj != null && _fsmEvent != null) { FSMUtility.SendEventToGameObject(_fsmObj, _fsmEvent); } // Stop the egg routine and destroy everything StopCoroutine(coroutine); Destroy(gameObject); }
private IEnumerator loadComboBars() { yield return(new WaitForFinishedEnteringScene()); if (comboBar != null) { yield break; } canvasObj = CanvasUtil.CreateCanvas(RenderMode.ScreenSpaceOverlay, new Vector2(1920f, 1080f)); comboBar = CanvasUtil.CreateImagePanel(canvasObj, Sprite.Create(Texture2D.whiteTexture, new Rect(0, 0, 1, 1), new Vector2(0.5f, 0.5f)), new CanvasUtil.RectData(new Vector2(300f, 100f), new Vector2(0.9f, 0.9f), new Vector2(0.917f, 0.89f), new Vector2(0.917f, 0.89f))); blueComboBar = CanvasUtil.CreateImagePanel(canvasObj, Sprite.Create(Texture2D.whiteTexture, new Rect(0, 0, 1, 1), new Vector2(0.5f, 0.5f)), new CanvasUtil.RectData(new Vector2(301f, 20f), new Vector2(0.5f, 0.5f), new Vector2(0.917f, 0.85f), new Vector2(0.917f, 0.85f))); comboBarPicture = comboBar.GetComponent <Image>(); comboBarPicture.preserveAspect = false; comboBarPicture.type = Image.Type.Filled; comboBarPicture.fillMethod = Image.FillMethod.Horizontal; comboBarPicture.fillAmount = (float)comboMeter; blueComboPicture = blueComboBar.GetComponent <Image>(); blueComboPicture.preserveAspect = false; blueComboPicture.type = Image.Type.Filled; blueComboPicture.fillMethod = Image.FillMethod.Horizontal; blueComboPicture.color = Color.blue; radiantText = CanvasUtil.CreateTextPanel(canvasObj, "", 42, TextAnchor.UpperRight, new CanvasUtil.RectData(new Vector2(400f, 150f), new Vector2(0.5f, 0.5f), new Vector2(0.89f, 0.92f), new Vector2(0.89f, 0.92f))); radiantTextBox = radiantText.GetComponent <Text>(); hitText = CanvasUtil.CreateTextPanel(canvasObj, "", 42, TextAnchor.LowerRight, new CanvasUtil.RectData(new Vector2(400f, 150f), new Vector2(0.5f, 0.5f), new Vector2(0.89f, 0.854f), new Vector2(0.89f, 0.854f))); totalHitNumber = hitText.GetComponent <Text>(); if (knightRadiantEffect == null) { knightRadiantEffect = new GameObject("knightRadiantParticles", typeof(ParticleSystem)); radKnightSystem = knightRadiantEffect.GetComponent <ParticleSystem>(); radKnightRenderer = knightRadiantEffect.GetComponent <ParticleSystemRenderer>(); ParticleSystem.MainModule partMain = radKnightSystem.main; partMain.loop = true; radKnightSystem.useAutoRandomSeed = true; partMain.gravityModifier = 0f; //partMain.startColor = new // ParticleSystem.MinMaxGradient(new Color(1f, 0f, 0f), new Color(1f, 1f, 0.3f)); //partMain.startColor = new // ParticleSystem.MinMaxGradient(new Color(1f, 1f, 0.3f)); partMain.startSize = new ParticleSystem.MinMaxCurve(0.25f); partMain.startLifetime = new ParticleSystem.MinMaxCurve(0.3f); partMain.maxParticles = 300; partMain.startSpeed = new ParticleSystem.MinMaxCurve(3f, 15f); ParticleSystem.EmissionModule partEmission = radKnightSystem.emission; partEmission.enabled = true; partEmission.rateOverTime = new ParticleSystem.MinMaxCurve(50f); ParticleSystem.SizeOverLifetimeModule soe = radKnightSystem.sizeOverLifetime; AnimationCurve curve = new AnimationCurve(); curve.AddKey(0.0f, 1f); curve.AddKey(1f, 0f); soe.size = new ParticleSystem.MinMaxCurve(1f, curve); soe.enabled = true; radKnightRenderer.material.shader = Shader.Find("Particles/Additive"); radKnightRenderer.material.mainTexture = perfectWhiteCircle; radKnightRenderer.renderMode = ParticleSystemRenderMode.Billboard; if (voidKnight != null) { knightRadiantEffect.transform.parent = voidKnight.transform; knightRadiantEffect.transform.localPosition = Vector3.zero; } } //canvasObj.SetActive(true); //comboBar.SetActive(true); //blueComboBar.SetActive(true); updateComboBars(); }