Exemplo n.º 1
0
        override public GameView onStart()
        {
            string[] options = { "Easy", "Hard", "Back" };

            ConsoleMenue menue    = new ConsoleMenue("Pick Dificulty", options);
            int          selected = menue.getUserSelection();

            Player p1 = new HumanPlayer("Player1", BoardSymbol.Cross);
            Player p2 = null;

            if (selected == 0)
            {
                p2 = new DumbAI("Player2", BoardSymbol.Circle);
            }
            else if (selected == 1)
            {
                p2 = new SmartAI("Player2", BoardSymbol.Circle);
            }
            else if (selected == 2)
            {
                return(GameView.main_menue_view);
            }

            GameEngine game = new GameEngine(p1, p2);

            return(new PlayGame(game));
        }
Exemplo n.º 2
0
        private void Form1_Load(object sender, EventArgs e)
        {
            var ai = new SmartAI();

            battleShip1.ArtificialIntelligence = ai;
            battleShip1.NewGame();
            battleShip1.EndGame += BattleShip1_EndGame;
        }
Exemplo n.º 3
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);
            }
        }