Ejemplo n.º 1
0
 /// <summary>
 /// The main entry point for the application.
 /// </summary>
 /// 
 static void Main(string[] args)
 {
     using (Main game = new Main())
     {
         game.Run();
     }
 }
Ejemplo n.º 2
0
        public Menu(Main game1)
        {
            this._game1 = game1;

            int width = (int)(Main.DefaultResWidth / 2f / Main.WidthRatio);
            int height = (int)(200 / Main.HeightRatio);
            int diff = (int)(40 / Main.HeightRatio);
            _first = new Vector2(width, height + (diff * 0));
            _second = new Vector2(width, height + (diff * 1));
            _third = new Vector2(width, height + (diff * 2));
            _fourth = new Vector2(width, height + (diff * 3));
            _fifth = new Vector2(width, height + (diff * 4));

            background = ContentHelper.LoadTexture("Backgrounds/Main Menu/menu_background_temp");
            _font32 = ContentHelper.LoadFont("Fonts/x32");
            _font64 = ContentHelper.LoadFont("Fonts/x64");

            _chooseLevel = new TextButton(_second, "Choose a Level");
            _chooseLevel.MouseClicked += chooseLevel_MouseClicked;
            _buttons.Add(_chooseLevel);

            _quit = new TextButton(_fifth, "Quit");
            _quit.MouseClicked += quit_MouseClicked;
            _buttons.Add(_quit);

            _options = new TextButton(_third, "Options");
            _options.MouseClicked += options_MouseClicked;
            _buttons.Add(_options);

            _multiplayer = new TextButton(_fourth, "Multiplayer");
            _multiplayer.MouseClicked += multiplayer_MouseClicked;
            _buttons.Add(_multiplayer);

            _storyMode = new TextButton(_first, "Story Mode");
            _storyMode.MouseClicked += storyMode_MouseClicked;
            _buttons.Add(_storyMode);

            //smoothPixels = new Button(first, "Smooth Pixels: ");
            //smoothPixels.MouseClicked += smoothPixels_MouseClicked;
            //buttons.Add(smoothPixels);

            //lighting = new Button(second, "Lighting: ");
            //lighting.MouseClicked += lighting_MouseClicked;
            //buttons.Add(lighting);

            _fullscreen = new TextButton(_first, "Borderless Mode: ");
            _fullscreen.MouseClicked += fullscreen_MouseClicked;
            _fullscreen.IsActive = game1.GameData.Settings.IsFullscreen;
            _buttons.Add(_fullscreen);

            _backButton = new TextButton(_fifth, "Back");
            _backButton.MouseClicked += backButton_MouseClicked;
            _buttons.Add(_backButton);

            //save1 = new Button(first, "Save 1");
            //save1.MouseClicked += level1_MouseClicked;
            //buttons.Add(save1);

            //save2 = new Button(second, "Save 2");
            //save2.MouseClicked += level2_MouseClicked;
            //buttons.Add(save2);

            //save3 = new Button(third, "Save 3");
            //save3.MouseClicked += level3_MouseClicked;
            //buttons.Add(save3);

            _hostGame = new TextButton(_first, "Host Game");
            _hostGame.MouseClicked += hostGame_MouseClicked;
            _buttons.Add(_hostGame);

            _joinGame = new TextButton(_second, "Join Game");
            _joinGame.MouseClicked += joinGame_MouseClicked;
            _buttons.Add(_joinGame);

            _startMultiplayerGame = new TextButton(_third, "Start Game");
            _startMultiplayerGame.MouseClicked += StartMultiplayerGame_MouseClicked;
            _buttons.Add(_startMultiplayerGame);

            _levelSelection = new LevelSelection();
        }
Ejemplo n.º 3
0
        public Main()
        {
            _instance = this;

            // Get the current monitor resolution and set it as the game's resolution
            var monitorRes = new Vector2(GraphicsAdapter.DefaultAdapter.CurrentDisplayMode.Width,
                GraphicsAdapter.DefaultAdapter.CurrentDisplayMode.Height);

            #pragma warning disable 0162
            // ReSharper disable once ConditionIsAlwaysTrueOrFalse
            if (IsTestingMultiplayer)
            {
                UserResWidth = 960;
                UserResHeight = 540;
            }
            else
            {
                UserResWidth = (int)monitorRes.X;
                UserResHeight = (int)monitorRes.Y;
            }
            #pragma warning restore 0162

            WidthRatio = (DefaultResWidth / (double)UserResWidth);
            HeightRatio = (DefaultResHeight / (double)UserResHeight);

            // Important services that need to be instanstiated before other things.
            _graphics = new GraphicsDeviceManager(this);
            Content = new ContentManager(Services, "Content");
            GameData = new GameDataManager();

            // Sets the current screen resolution to the user resolution.
            _graphics.PreferredBackBufferWidth = UserResWidth;
            _graphics.PreferredBackBufferHeight = UserResHeight;

            // Change game settings here.
            _graphics.SynchronizeWithVerticalRetrace = true;
            _graphics.PreferMultiSampling = false;
            IsFixedTimeStep = true;
            _graphics.IsFullScreen = GameData.Settings.IsFullscreen;

            // Set window to borderless.
            var hWnd = Window.Handle;
            var control = Control.FromHandle(hWnd);
            var form = control.FindForm();
            #pragma warning disable
            // ReSharper disable once ConditionIsAlwaysTrueOrFalse
            if (IsTestingMultiplayer)
            {
                form.WindowState = FormWindowState.Normal;
            }
            else
            {
                // ReSharper disable once PossibleNullReferenceException
                form.FormBorderStyle = FormBorderStyle.None;
                form.WindowState = FormWindowState.Maximized;
            }
            #pragma warning restore

            //MediaPlayer Settings
            MediaPlayer.Volume = MaxVolume;
            Thread.CurrentThread.Priority = ThreadPriority.Highest;
        }
Ejemplo n.º 4
0
        public void Update(Main game1, GameTime gameTime, Settings settings)
        {
            this._gameTime = gameTime;
            switch (CurrentMenuState)
            {
                case MenuState.Main:
                    _chooseLevel.Update();
                    _quit.Update();
                    _options.Update();
                    _multiplayer.Update();
                    _storyMode.Update();
                    break;
                case MenuState.LevelSelector:
                    _levelSelection.Update();
                    break;
                case MenuState.Options:
                    //smoothPixels.Text = "Smooth Pixels: " + smoothPixels.IsActive;
                    //lighting.Text = "Lighting: " + lighting.IsActive;
                    _fullscreen.Text = "Borderless Mode: " + !_fullscreen.IsActive;

                    //smoothPixels.Update();
                    //lighting.Update();
                    _fullscreen.Update();

                    _backButton.Update();
                    break;

                case MenuState.HostJoin:
                    _hostGame.Update();
                    _joinGame.Update();

                    _backButton.Update();
                    break;
                case MenuState.MultiplayerSession:
                    _startMultiplayerGame.Update();
                    break;
            }

            if (game1.CurrentGameState == GameState.MainMenu)
            SoundtrackManager.PlayMainTheme();
        }
Ejemplo n.º 5
0
        public void Update(Main game1, Player.Player player, GameWorld map, bool isOnDebug)
        {
            if (!isOnDebug)
            {
                _textString = "";
                IsWritingCommand = false;
                map.IsOnDebug = false;
                return;
            }

            if (!IsWritingCommand)
            {
                map.IsOnDebug = false;
                if (Keyboard.GetState().IsKeyDown(Keys.LeftControl)
                    && Keyboard.GetState().IsKeyDown(Keys.LeftShift)
                    && Keyboard.GetState().IsKeyDown(Keys.C))
                {
                    IsWritingCommand = true;
                    _textString = "";
                    return;
                }
                else return;
            }
            else
            {
                map.IsOnDebug = true;
            }

            if (Keyboard.GetState().IsKeyDown(Keys.LeftControl)
                    && Keyboard.GetState().IsKeyDown(Keys.LeftShift)
                    && Keyboard.GetState().IsKeyDown(Keys.C))
            {
                _textString = "";
            }

            if (_textString == "No command found" && Keyboard.GetState().IsKeyDown(Keys.Back))
                _textString = "";

            this._game1 = game1;
            this._player = player;

            _oldKeyboardState = _currentKeyboardState;
            _currentKeyboardState = Keyboard.GetState();

            InputHelper.TryLinkToKeyboardInput(ref _textString, _currentKeyboardState, _oldKeyboardState);
            if (InputHelper.IsKeyDown(Keys.Enter) &&!_definitionFound)
            {
                AnalyzeText();
            }
        }