private IEnumerator LevelFailedRoutine() { if (!(limitLevelFail == true && hasFailed == true)) { _isFailedVisible = true; _levelFailedGameObject.SetActive(false); _levelFailedAnimator.enabled = true; yield return(new WaitForSeconds(0.1f)); _levelFailedGameObject.SetActive(true); var waitTime = Time.realtimeSinceStartup + 3; while (Time.realtimeSinceStartup < waitTime) { _gameEnergyCounter.ProcessEnergyChange(-1); yield return(null); } _levelFailedGameObject.SetActive(false); _gameEnergyCounter.ProcessEnergyChange(0.5f); _isFailedVisible = false; if (limitLevelFail == true) { hasFailed = true; } } }
public static bool Prefix(ref GameEnergyCounter __instance, float energyChange) { if (!(GMPUI.EndlessMode && Config.EndlessContinueOnFail)) { return(true); } GameObject endlessObj = GameObject.Find("GMP Endless Behavior"); if (endlessObj == null) { return(true); } if (energyChange > 0) { return(true); } EndlessBehavior endlessBehavior = endlessObj.GetComponent <EndlessBehavior>(); if (endlessBehavior.nextSong != null) { bool willFail = (__instance.energy + energyChange) <= 0; if (willFail && BS_Utils.Plugin.LevelData.IsSet && !BS_Utils.Plugin.LevelData.GameplayCoreSceneSetupData.gameplayModifiers.noFailOn0Energy) { __instance.ProcessEnergyChange(0.5f); endlessBehavior.SongEnd(); return(false); } } return(true); }
public System.Collections.IEnumerator DelayedSetup() { yield return(new WaitForSeconds(0.1f)); try { if (_spawnController == null) { _spawnController = Resources.FindObjectsOfTypeAll <BeatmapObjectSpawnController>().LastOrDefault(); } Console.WriteLine("Atemmpting Practice Plugin UI"); var canvas = GameObject.Find("PauseMenu").transform.Find("Wrapper").transform.Find("MenuWrapper").transform.Find("Canvas"); if (canvas == null) { Console.WriteLine("Canvas Null"); } GameObject uiObj = new GameObject("PracticePlugin Seeker UI", typeof(RectTransform)); (uiObj.transform as RectTransform).anchorMin = new Vector2(0, 0); (uiObj.transform as RectTransform).anchorMax = new Vector2(1, 1); (uiObj.transform as RectTransform).sizeDelta = new Vector2(0, 0); _uiElementsCreator = uiObj.AddComponent <UIElementsCreator>(); var practiceUI = new GameObject("PracticePlugin Adjustment UI").AddComponent <PracticeUI>(); UIElementsCreator.practiceUI = practiceUI; BSMLParser.instance.Parse(BeatSaberMarkupLanguage.Utilities.GetResourceContent(Assembly.GetExecutingAssembly(), "PracticePlugin.PracticeUI.bsml"), canvas.gameObject, practiceUI); _uiElementsCreator.Init(); uiObj.transform.SetParent(canvas, false); uiObj.transform.localScale = new Vector3(1, 1, 1); uiObj.transform.localPosition = new Vector3(0f, -3f, 0f); new GameObject("Practice Plugin Behavior").AddComponent <Behavior>(); if (startWithFullEnergy) { GameEnergyCounter energyCounter = Resources.FindObjectsOfTypeAll <GameEnergyCounter>().FirstOrDefault(); if (energyCounter != null) { energyCounter.ProcessEnergyChange(1 - energyCounter.energy); } } } catch (Exception ex) { Console.WriteLine(ex.ToString()); } }