Beispiel #1
0
        private void TurnOffLight()
        {
            System.Random random = new System.Random();
            LightSwitch.duration = random.Next(1, 4);
            LightSwitch.Apply();
            int lightSwitchData = LightSwitch.duration;

            //MelonLogger.Log("full shutdown, duration " + lightSwitchData + " minutes");
            shakeDuration = 4;
            if (config.ghost_nightmare && lightSwitchData == 3)
            {
                UDebug.Execute("spawn");
                //MelonLogger.Log("spawning ghosts");
            }
        }
Beispiel #2
0
        // Update and randomize time

        public override void OnUpdate()
        {
            if (LoadingView.Loading || m_noCharacter || InMenu)
            {
                return;
            }

            lightTimer += UnityEngine.Time.deltaTime;

            if (config.quick_holetime && firstHoleSetting)
            {
                holeTimer        = config.holetime_time;
                firstHoleSetting = false;
            }

            if (config.quick_holetime)
            {
                holeTimer += UnityEngine.Time.deltaTime;
            }

            if (holeTimer >= config.holetime_time && config.quick_holetime)
            {
                holePosition++;
                UDebug.Execute("bh " + holePosition);
                holeTimer = 0;
                if (holePosition >= 360)
                {
                    holePosition = 0;
                }
            }

            if (lightTimer >= TurnOffTimer)
            {
                energyFailing = true;
                System.Random random = new System.Random();
                int           chance = random.Next(1, 101);
                if (chance >= 95)
                {
                    TurnOffLight();
                    flickerCount = 0;
                    lightTimer  -= TurnOffTimer;
                    maxFlickers  = random.Next(1, 5);
                    TurnOffTimer = random.Next(300, 361);
                    //MelonLogger.Log("next failure in " + TurnOffTimer + " seconds");
                    //MelonLogger.Log("new flicker count " + maxFlickers);
                }
                else
                {
                    LightFlicker();
                    flickerCount++;
                    lightTimer  -= TurnOffTimer;
                    TurnOffTimer = 2;
                    //MelonLogger.Log("flickering");
                    if (flickerCount >= maxFlickers)
                    {
                        flickerCount = 0;
                        lightTimer  -= TurnOffTimer;
                        maxFlickers  = random.Next(1, 5);
                        TurnOffTimer = random.Next(120, 151);
                        //MelonLogger.Log("next failure in " + TurnOffTimer + " seconds");
                        //MelonLogger.Log("new flicker count " + maxFlickers);
                    }
                }
            }
            if (energyFailing && config.shake_enabled)
            {
                ScreenShaker();
                //MelonLogger.Log("shaking " + shakeDuration + " seconds");
                shakeTime += UnityEngine.Time.deltaTime;
                if (shakeTime >= shakeDuration)
                {
                    energyFailing = false;
                    shakeTime     = 0;
                    //MelonLogger.Log("reset shaker");
                }
            }
        }