Exemplo n.º 1
0
        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.AddEnergy(-1);
                    yield return(null);
                }
                _levelFailedGameObject.SetActive(false);

                _gameEnergyCounter.AddEnergy(0.5f);
                _isFailedVisible = false;
                if (limitLevelFail == true)
                {
                    hasFailed = true;
                }
            }
        }
Exemplo n.º 2
0
        public override bool Activate(ref LightSwitchEventEffect light, ref BeatmapEventData data, ref BeatmapEventType eventType)
        {
            GameEnergyCounter counter = GameObject.FindObjectOfType <GameEnergyCounter>();

            if (counter != null)
            {
                ChromaLogger.Log("Changing health by " + HealthChangeAmount);
                counter.AddEnergy(HealthChangeAmount);
                return(true);
            }
            return(false);
        }
Exemplo n.º 3
0
        public System.Collections.IEnumerator DelayedSetup()
        {
            yield return(new WaitForSeconds(0.2f));

            try
            {
                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");
                }

                BSMLParser.instance.Parse(BeatSaberMarkupLanguage.Utilities.GetResourceContent(Assembly.GetExecutingAssembly(), "PracticePlugin.PracticeUI.bsml"), canvas.gameObject, PracticeUI.instance);

                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>();
                _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.AddEnergy(1 - energyCounter.energy);
                    }
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.ToString());
            }
        }
Exemplo n.º 4
0
        //Our custom AddEnergy will pass along the info to the gameEnergyCounter's AddEnergy UNLESS we would have failed, in which case we withhold that information until the end of the level
        private void AddEnergy(float value)
        {
            if (!_wouldHaveFailed)
            {
                var currentEnergy = gameEnergyCounter.energy;

                if (value < 0f)
                {
                    if (currentEnergy <= 0f)
                    {
                        return;
                    }
                    if (gameEnergyCounter.instaFail)
                    {
                        currentEnergy = 0f;
                    }
                    else if (gameEnergyCounter.energyType == GameplayModifiers.EnergyType.Battery)
                    {
                        currentEnergy -= 1f / (float)gameEnergyCounter.GetField <float>("_batteryLives");
                    }
                    else
                    {
                        currentEnergy += value;
                    }
                    if (currentEnergy <= 1E-05f)
                    {
                        _wouldHaveFailed = true;
                        BS_Utils.Gameplay.ScoreSubmission.DisableSubmission(SharedConstructs.Name); //Probably not necessary since we invoke fail anyway on level end, but just to be safe...
                    }
                }

                if (!_wouldHaveFailed)
                {
                    gameEnergyCounter.AddEnergy(value);
                }
            }
        }
Exemplo n.º 5
0
        void Update()
        {
            if (Client.Status != ClientStatus.Playing)
            {
                return;
            }

            if (_gameEnergyCounter == null)
            {
                _gameEnergyCounter = Resources.FindObjectsOfTypeAll <GameEnergyCounter>().FirstOrDefault();
            }

            if (_gameEnergyCounter == null)
            {
                return;
            }

            if (Invulnerable.HasValue)
            {
                if (Time.time - Invulnerable.Value > ItemDuration)
                {
                    Invulnerable = null;
                    PluginUI.instance.SetEnergyBarColor(Color.white);
                }
                else
                {
                    _gameEnergyCounter.AddEnergy(1.0f - _gameEnergyCounter.energy);
                }
            }
            else if (Brink.HasValue)
            {
                if (Time.time - Brink.Value > ItemDuration)
                {
                    Brink = null;
                    PluginUI.instance.SetEnergyBarColor(Color.white);
                }
                else if (_gameEnergyCounter.energy > 0f)
                {
                    _gameEnergyCounter.AddEnergy(0.05f - _gameEnergyCounter.energy);
                }
            }
            else if (Drain.HasValue)
            {
                if (Time.time - Drain.Value > ItemDuration)
                {
                    Drain = null;
                    PluginUI.instance.SetEnergyBarColor(Color.white);
                }
                else
                {
                    _gameEnergyCounter.AddEnergy(-DrainPerSecond * Time.deltaTime);
                }
            }
            else if (Poison.HasValue)
            {
                if (Time.time - Poison.Value > ItemDuration)
                {
                    Poison     = null;
                    _oldEnergy = null;
                    PluginUI.instance.SetEnergyBarColor(Color.white);
                }
                else if (_oldEnergy == null)
                {
                    _oldEnergy = _gameEnergyCounter.energy;
                }
                else if (_gameEnergyCounter.energy > _oldEnergy.Value)
                {
                    _gameEnergyCounter.AddEnergy(_oldEnergy.Value - _gameEnergyCounter.energy);
                }
                else
                {
                    _oldEnergy = _gameEnergyCounter.energy;
                }
            }
            else if (AddHealthNextFrame > 0 && _gameEnergyCounter.energy > 0f)
            {
                _gameEnergyCounter.AddEnergy(AddHealthNextFrame);
                AddHealthNextFrame = 0;
            }

            if (Shield.HasValue && Time.time - Shield.Value > ItemDuration)
            {
                Shield = null;
                PluginUI.instance.SetEnergyBarColor(Color.white);
            }

            if (StartGhostNotesNextFrame)
            {
                StartCoroutine(BeatmapSpawnManager.instance.ReplaceNextXNotesWithGhostNotesCoroutine(ItemDuration));
                StartGhostNotesNextFrame = false;
            }

            if (StartGhostArrowsNextFrame)
            {
                StartCoroutine(BeatmapSpawnManager.instance.ReplaceNextXNotesWithDisappearingArrowsCoroutine(ItemDuration));
                StartGhostArrowsNextFrame = false;
            }


            float trigger = Mathf.Max(Input.GetAxis("TriggerRightHand"), Input.GetAxis("TriggerLeftHand"));

            if (trigger > 0.6 && Time.time - _triggerLastPush > 1.5f)
            {
                UseCurrentItem();
                _triggerLastPush = Time.time;
            }
        }