Exemple #1
0
        public Level(OnafMain main)
        {
            Main = main;

            Laptop = new Laptop(this);
            Office = new Office(this);

            Monsters = new MonsterManager(this);

            LaptopBattery = 1.0f;

            VolumeController = new SoundVolumeController();

            CHEAT_InfiniteExposure = false;
            CHEAT_InfiniteBattery  = false;
            CHEAT_MapDebug         = true;
            CHEAT_MonstersStayPut  = false;
            CHEAT_OwlInvincibility = false;

            Bot = new PlayerMouseInput(this);
        }
Exemple #2
0
        public void Update(GameTime gt, InputManager input)
        {
            Bot.Update(gt, input);

            if (HasWon)
            {
                _spamFadeTime += (float)gt.Elapsed.TotalSeconds;

                if (_spamFadeTime >= SPAM_FADE_TIME)
                {
                    Main.UI.SetState(UIState.SixAM);
                }
                return;
            }

            Office.Update(gt, input);
            Laptop.Update(gt, input);

            Monsters.Update(gt, input);

            // Cheats
            if (input.IsKeyPressed(Keys.D6))
            {
                Time = VICTORY_TIME;
            }

            if (input.IsKeyPressed(Keys.F7))
            {
                CHEAT_InfiniteExposure = !CHEAT_InfiniteExposure;
            }

            if (input.IsKeyPressed(Keys.F8))
            {
                CHEAT_InfiniteBattery = !CHEAT_InfiniteBattery;
            }

            if (input.IsKeyPressed(Keys.F9))
            {
                CHEAT_MapDebug = !CHEAT_MapDebug;
            }

            if (input.IsKeyPressed(Keys.F10))
            {
                CHEAT_MonstersStayPut = !CHEAT_MonstersStayPut;
            }

            if (input.IsKeyPressed(Keys.F11))
            {
                CHEAT_OwlInvincibility = !CHEAT_OwlInvincibility;
            }

            // ESC returns to main menu
            if (input.IsKeyPressed(Keys.Escape))
            {
                UI.SetState(UIState.MainMenu);
            }

            // Bot switch
            if (input.IsKeyPressed(Keys.F1))
            {
                Bot = new PlayerMouseInput(this);
                Bot.Reset();
            }
            else if (input.IsKeyPressed(Keys.F2))
            {
                Bot = new PsychicAI(this);
                Bot.Reset();
            }
            else if (input.IsKeyPressed(Keys.F3))
            {
                Bot = new SmartAI(this);
                Bot.Reset();
            }

            if (_flipUpEnabled && Bot.MousePos.Y >= FLIPUP_THRESHOLD && !_isMouseLingering && !IsJumpscaring)
            {
                Laptop.ToggleLaptop();
                _isMouseLingering = true;
            }

            if (Bot.MousePos.Y < FLIPUP_THRESHOLD && _isMouseLingering && !IsJumpscaring)
            {
                _isMouseLingering = false;
            }

            if (!IsJumpscaring)
            {
                Time += (float)gt.Elapsed.TotalSeconds;
            }
            else
            {
                if (gt.FrameCount % 2 == 0)
                {
                    jumpscareShakeOffset = new Vector2((float)(Rand.NextDouble() * JUMPSCARE_SHAKE_RANGE + JUMPSCARE_SHAKE_MIN),
                                                       (float)(Rand.NextDouble() * JUMPSCARE_SHAKE_RANGE + JUMPSCARE_SHAKE_MIN));
                }

                if (Main.UI.State == UIState.Laptop)
                {
                    Laptop.ToggleLaptop();
                }
            }

            if (Monsters.IsExposed)
            {
                _exposureShakeOffset = (int)(Math.Sin(gt.Total.TotalSeconds * SHAKE_SPEED) * EXPOSURE_SHAKE_MAX);
            }

            if (Exposure >= 0.95f && CHEAT_InfiniteExposure)
            {
                Exposure = 0;                 // Reset exposure at 95%
            }

            if (Monsters.IsExposed && Exposure >= 1.0f && !CHEAT_InfiniteExposure)
            {
                IsJumpscaring = true;
                Monsters.StartJumpscareFromExposure();
                exposureUpSound.Stop();
            }

            if (Time >= VICTORY_TIME && !IsJumpscaring)
            {
                HasWon = true;
                spamMusic.Play();

                Main.HasWon = true;

                if (IsHardBoiled)
                {
                    Main.HasWonHardboiled = true;
                }
            }

            _flipUpEnabled = false;
            if (!Laptop.IsLaptopSwitching)
            {
                if (Main.UI.State == UIState.Laptop || Office.IsLightOn)
                {
                    _flipUpEnabled = true;
                }
            }

            if (Main.UI.State == UIState.Office && Office.IsLightOn)
            {
                const float CHARGE_SPEED = 1.0f / LAPTOP_BATTERY_TIME;
                LaptopBattery = Math.Min(LaptopBattery + CHARGE_SPEED * (float)gt.Elapsed.TotalSeconds, 1.0f);
            }
        }
Exemple #3
0
 void Start()
 {
     playerhealth = GameObject.Find("Player").GetComponent <PlayerHealth>();
     mouseInput   = GameObject.Find("Player").GetComponent <PlayerMouseInput>();
 }