Beispiel #1
0
        protected override void LoadContent()
        {
            GameDatas.GameFocus = true;
            IsMouseVisible = true;

            _spriteBatch = new SpriteBatch(GraphicsDevice);

            _gameStates = new Stack<GameState>();

            //////////////////////////////////////////////////////////

            GameDatas.Theme = new Theme("PinkTheme", 10, 40, 17, 3, 28, 33, 5, 50, 48);

            GameDatas.Theme.Load(Content);

            //////////////////////////////////////////////////////////

            _graphics.PreferredBackBufferWidth = GameDatas.Theme.GridTexture.Width*2 + 50;
            _graphics.PreferredBackBufferHeight = GameDatas.Theme.GridTexture.Height +
                                                  GameDatas.Theme.LogoTexture.Height + 50;
            _graphics.ApplyChanges();

            GameDatas.WindowWidth = Window.ClientBounds.Width;
            GameDatas.WindowHeight = Window.ClientBounds.Height;

            //////////////////////////////////////////////////////////

            var logo = new MenuPassive(GameDatas.Theme.LogoTexture);
            var comeBackButton = new MenuButton("Come Back :D");

            // CREATION MENU CREATE GAME

            var createNameTextBox = new MenuTextBox("What's your name?");
            var submitCreateGame = new MenuButton("Go !") {Click = CreateGame};

            var createGameMenuItems = new List<MenuItem> {logo, createNameTextBox, submitCreateGame, comeBackButton};
            var createGameMenuState = new MenuState(createGameMenuItems, true);
            createGameMenuState.SetPositions();
            submitCreateGame.subMenu = createGameMenuState;

            // CREATION MENU JOIN GAME

            var joinNameTextBox = new MenuTextBox("What's your name?");
            var serverIpTextBox = new MenuTextBox("IP Server :D");
            var submitJoinGame = new MenuButton("Go !");

            var joinGameMenuItems = new List<MenuItem> {logo, joinNameTextBox, serverIpTextBox, submitJoinGame, comeBackButton};
            var joinGameMenuState = new MenuState(joinGameMenuItems, true);
            joinGameMenuState.SetPositions();
            submitJoinGame.subMenu = joinGameMenuState;
            submitJoinGame.Click = JoinGame;
            comeBackButton.Click = _comeBack;

            // CREATION MENU ACCUEIL

            var createGameButton = new MenuButton("Create a Game");
            var joinGameButton = new MenuButton("Join a Game");

            createGameButton.subMenu = createGameMenuState;
            createGameButton.Click = _launchMenu;
            joinGameButton.subMenu = joinGameMenuState;
            joinGameButton.Click = _launchMenu;

            var homeMenuItems = new List<MenuItem> {logo, createGameButton, joinGameButton};
            var homeMenuState = new MenuState(homeMenuItems, true);
            homeMenuState.SetPositions();

            // FIN CREATION MENUS

            _gameStates.Push(homeMenuState);
            _gameStates.Peek().Initialize();
            _gameStates.Peek().LoadContent(Content);
        }
Beispiel #2
0
 private void _launchMenu(MenuState m)
 {
     _gameStates.Push(m);
     _gameStates.Peek().LoadContent(Content);
 }
Beispiel #3
0
 private void _comeBack(MenuState m)
 {
     if (_gameStates.Count > 1)
         _gameStates.Pop();
 }
Beispiel #4
0
        void JoinGame(MenuState m)
        {
            var client = new TcpClient();
            client.Connect(((MenuTextBox)m.Items[2]).Value, 4242);

            var p = new PlayState(new Client(client), ((MenuTextBox) m.Items[1]).Value, ref _gameStates);
            p.Initialize();
            p.LoadContent(Content);
            _gameStates.Push(p);
        }
Beispiel #5
0
 void CreateGame(MenuState m)
 {
     var p = new PlayState(new Server().AcceptClient(), ((MenuTextBox) m.Items[1]).Value, ref _gameStates, true);
     p.Initialize();
     p.LoadContent(Content);
     _gameStates.Push(p);
 }
Beispiel #6
0
        public override void LoadContent(ContentManager content)
        {
            var gameOverPassive = new MenuPassive(GameDatas.Theme.GameOverTexture);
            var gameOverItems = new List<MenuItem> {gameOverPassive};

            _gameOverMenuState = new MenuState(gameOverItems, true);
            _gameOverMenuState.SetPositions();
        }