예제 #1
0
        public void Reset()
        {
            Office.Reset();
            Laptop.Reset();

            Monsters.Reset();

            Time          = 0;
            LaptopBattery = 1.0f;
            Exposure      = 0.0f;

            _flipUpEnabled = true;

            HasWon        = false;
            _spamFadeTime = 0;

            IsJumpscaring        = false;
            jumpscareShakeOffset = Vector2.Zero;

            Bot.Reset();
        }
예제 #2
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);
        }
예제 #3
0
        public void Draw(GameTime gameTime, SpriteBatch sb)
        {
            Office.Draw(gameTime, sb);

            if (IsJumpscaring)
            {
                Monsters.DrawJumpscares(sb);
            }

            Laptop.Draw(gameTime, sb);

            float x = Main.WindowSize.X - hourFont.MeasureString(TimeShown).Length() - 10;

            sb.DrawString(hourFont, TimeShown, new Vector2(x, 10), Color.White);

            string batteryText  = BATTERY_DEFAULT_TEXT;
            Color  batteryColor = Color.White;

            if (Monsters.Redman.IsRedScreenOfDeathUp)
            {
                batteryColor = BATTERY_CHARGE_OFF_COLOR;
            }
            else if (LaptopBattery >= 1.0f)
            {
                batteryColor = BATTERY_CHARGED_COLOR;
            }
            else if (LaptopBattery <= 0.0f || (Laptop.IsRebooting && Main.UI.State == UIState.Laptop))
            {
                batteryColor = BATTERY_OUT_COLOR;
            }
            else
            {
                if (!Office.IsLightOn)
                {
                    batteryColor = BATTERY_CHARGE_OFF_COLOR;
                    batteryText  = BATTERY_CHARGE_OFF_TEXT;
                }
                else if (Main.UI.State == UIState.Office)
                {
                    batteryText = BATTERY_CHARGE_TEXT;
                }
            }

            bool goldenJumpscare = Monsters.GoldenFlumpty != null && Monsters.GoldenFlumpty.IsJumpscaring;

            if (!goldenJumpscare)
            {
                gameUISprites["Battery"].Draw(sb, BATTERY_OFFSET, batteryColor, Vector2.One);

                RectangleF sourceRect = new RectangleF(0, 0, LaptopBattery * BAR_SIZE.X, BAR_SIZE.Y);

                if (Monsters.Redman.IsRedScreenOfDeathUp)
                {
                    gameUISprites["BatteryRedman"].Draw(sb, BATTERY_REDMAN_OFFSET);
                }
                else
                {
                    gameUISprites["Bar"].Draw(sb, BATTERY_BAR_OFFSET, sourceRect, batteryColor);
                    sb.DrawString(uiFont, batteryText, BATTERY_TEXT_OFFSET, batteryColor);
                }

                Color exposureColor = Color.White;
                if (Monsters.IsExposed)
                {
                    exposureColor = EXPOSED_COLOR;
                }

                Vector2 shakeOffset = new Vector2(0, Monsters.IsExposed ? _exposureShakeOffset : 0);

                gameUISprites["Exposure"].Draw(sb, EXPOSURE_OFFSET + shakeOffset, exposureColor, Vector2.One);
                sourceRect = new RectangleF(0, 0, Exposure * BAR_SIZE.X, BAR_SIZE.Y);
                gameUISprites["Bar"].Draw(sb, EXPOSURE_BAR_OFFSET + shakeOffset, sourceRect, exposureColor);
                sb.DrawString(uiFont, EXPOSURE_TEXT, EXPOSURE_TEXT_OFFSET + shakeOffset, exposureColor);

                if (_flipUpEnabled)
                {
                    gameUISprites["CamFlipUp"].Draw(sb, FLIPUP_OFFSET, Util.MakeTransparency(FLIPUP_ALPHA), Vector2.One);
                }

                if (Monsters.Redman.IsVirusUp && Monsters.Redman.warningIconVisible && UI.State == UIState.Office)
                {
                    gameUISprites["RedmanWarning"].Draw(sb, REDMAN_OFFICE_WARNING_OFFSET);
                }
            }

            if (HasWon)
            {
                Color transparency = Util.MakeTransparency(_spamFadeTime / SPAM_FADE_TIME);
                Laptop.miscScreens["SixAM"].Draw(sb, Vector2.Zero, transparency, Vector2.One);
            }

            if (Bot.ShowsMouse)
            {
                gameUISprites["AIMouse"].Draw(sb, Bot.MousePos);
            }
        }
예제 #4
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);
            }
        }
예제 #5
0
 public void Hide()
 {
     Office.Hide();
     Laptop.Hide();
     _flipUpEnabled = false;
 }