예제 #1
0
        public override void Update(GameTime gameTime)
        {
            MouseState currentMouseState = Mouse.GetState();
            Rectangle  MouseRect         = new Rectangle(currentMouseState.X, currentMouseState.Y, 1, 1);

            changeScreen = PossibleScreen.game;

            serverIP = GameGlobals.UpdateString(serverIP, 15);

            foreach (GraphObject _graphObject in graphList)
            {
                var temp = new Rectangle((int)_graphObject.Position.X, (int)_graphObject.Position.Y, _graphObject.Texture.Width, _graphObject.Texture.Height);
                if ((MouseRect.Intersects(temp)) && (_graphObject.IsButton))
                {
                    _graphObject.Color = Color.Brown;
                }
                else
                {
                    _graphObject.Color = Color.White;
                }

                if ((currentMouseState.LeftButton == ButtonState.Pressed) && MouseRect.Intersects(temp) && (_graphObject.IsButton) && (_graphObject.Color == Color.Brown))
                {
                    if (_graphObject.Name.Equals("BACK"))
                    {
                        MediaPlayer.Stop();
                        changeScreen = PossibleScreen.main;
                        Hide();
                    }
                    if (_graphObject.Name.Equals("SERVER"))
                    {
                        MediaPlayer.Stop();
                        GameGlobals.Initialize();
                        GameGlobals.StartServer();
                        GameGlobals.Player = new Player(GameGlobals.NICKNAMES[0], Player.PlayerColor.Red);
                        GameGlobals.Player.Connect(GameGlobals.LocalIPAddress(), GameGlobals.PORT);
                        changeScreen = PossibleScreen.lobby;
                        Hide();
                    }
                    if (_graphObject.Name.Equals("JOIN"))
                    {
                        if (GameGlobals.isIP(serverIP))
                        {
                            MediaPlayer.Stop();
                            GameGlobals.Initialize();
                            GameGlobals.Player = new Player(GameGlobals.NICKNAMES[1], Player.PlayerColor.Blue);
                            GameGlobals.Player.Connect(serverIP, GameGlobals.PORT);
                            changeScreen = PossibleScreen.lobby;
                            Hide();
                        }
                    }
                }
            }
        }
예제 #2
0
        public override void Update(GameTime gameTime)
        {
            MouseState currentMouseState = Mouse.GetState();
            Rectangle  MouseRect         = new Rectangle(currentMouseState.X, currentMouseState.Y, 1, 1);

            changeScreen = PossibleScreen.lobby;

            GameGlobals.message = GameGlobals.UpdateString(GameGlobals.message, 23);


            foreach (GraphObject _graphObject in graphList)
            {
                var temp = new Rectangle((int)_graphObject.Position.X, (int)_graphObject.Position.Y, _graphObject.Texture.Width, _graphObject.Texture.Height);
                if ((MouseRect.Intersects(temp)) && (_graphObject.IsButton))
                {
                    _graphObject.Color = Color.Brown;
                }
                else
                {
                    _graphObject.Color = Color.White;
                }

                if ((currentMouseState.LeftButton == ButtonState.Pressed) && MouseRect.Intersects(temp) && (_graphObject.IsButton) && (_graphObject.Color == Color.Brown))
                {
                    if (_graphObject.Name.Equals("BACK"))
                    {
                        changeScreen = PossibleScreen.main;
                        GameGlobals.Player.Disconnect();
                        GameGlobals.StopServer();
                        GameGlobals.Initialize();
                        Hide();
                    }
                    if (_graphObject.Name.Equals("SENDTEXT"))
                    {
                        GameGlobals.Player.SendMessage(GameGlobals.message);
                        GameGlobals.message = "";
                    }
                    if ((_graphObject.Name.Equals("START")))
                    {
                        if (GameGlobals.Player.isReady == false)
                        {
                            GameGlobals.Player.SendMessage(GameGlobals.IAMREADY);
                            GameGlobals.Player.isReady = true;
                        }
                        if (GameGlobals.GAMESTATE == GameGlobals.GameState.game)
                        {
                            changeScreen = PossibleScreen.startgame;
                            Hide();
                        }
                    }
                }
            }
        }