Exemplo n.º 1
0
        protected override void LoadContent()
        {
            // Create a new SpriteBatch, which can be used to draw textures.
            spriteBatch = new SpriteBatch(GraphicsDevice);
            spriteFont = Content.Load<SpriteFont>("font");
            formFont = Content.Load<SpriteFont>("FormFont");

            popUpTexture = Content.Load<Texture2D>("quitscreen");
            actionScreentexture = Content.Load<Texture2D>("greenmetal");
            blankBlackTexture = Content.Load<Texture2D>("black");

            //initialize and start the screens
            startScreen = new StartScreen(this, spriteBatch, formFont);
            Components.Add(startScreen);
            startScreen.ButtonClicked += new StartScreen.ClickEvent(HandleStartScreenButtons);
            startScreen.Hide();

            networkScreen = new NetworkGameSelectScreen(this, spriteBatch, spriteFont, blankBlackTexture);
            Components.Add(networkScreen);
            networkScreen.ButtonClicked += new NetworkGameSelectScreen.ClickEvent(HandleNetworkSelectScreenButtons);
            networkScreen.Hide();

            joinGameScreen = new JoinNetworkGameScreen(this, spriteBatch, formFont, blankBlackTexture);
            Components.Add(joinGameScreen);
            joinGameScreen.ButtonClicked += new JoinNetworkGameScreen.ClickEvent(HandleJoinGameScreenButtons);
            joinGameScreen.Hide();

            hostGameScreen = new HostNetworkGameScreen(this, spriteBatch, formFont, blankBlackTexture);
            Components.Add(hostGameScreen);
            hostGameScreen.ButtonClicked += new HostNetworkGameScreen.ClickEvent(HandleHostGameScreenButtons);
            hostGameScreen.Hide();

            actionScreen = new ActionScreen(this, spriteBatch, actionScreentexture);
            Components.Add(actionScreen);
            actionScreen.Hide();

            popUpScreen = new PopUpScreen(this, spriteBatch, spriteFont, popUpTexture);
            Components.Add(popUpScreen);
            popUpScreen.Hide();

            activeScreen = startScreen;
            //activeScreen = joinGameScreen;
            activeScreen.Show();

            IsMouseVisible = true;
        }
Exemplo n.º 2
0
        private void HandleStartScreenButtons(Control sender)
        {
            if (sender.Name == "StartGame")
            {
                gameType = Client.Client.GameType.local;
                StartServer(gameType);
            }
            if (sender.Name == "NetworkGame")
            {
                activeScreen.Hide();
                activeScreen = networkScreen;
                activeScreen.Show();
            }
            if (sender.Name == "QuitGame")
            {
                this.Exit();
            }

               /* if (CheckKey(Keys.Enter))
            {
                if (startScreen.SelectedIndex == 0) //start
                {
                    gameType = Client.Client.GameType.local;
                    StartServer(gameType);
                    //activeScreen.Hide();
                    //activeScreen = actionScreen;
                    //activeScreen.Show();
                }

                if (startScreen.SelectedIndex == 1) //Multiplayer game
                {
                    activeScreen.Hide();
                    activeScreen = networkScreen;
                    activeScreen.Show();
                }

                if (startScreen.SelectedIndex == 2) //quit
                {
                    this.Exit();
                }
            }*/
        }
Exemplo n.º 3
0
 void StartClient()
 {
     client = new Client.Client(this, spriteBatch, gameConfigName, this.gameType);
     Components.Add(client);
     activeScreen.Hide();
     activeScreen = client;
     activeScreen.Show();
 }
Exemplo n.º 4
0
 private void HandlePopUpScreen()
 {
     if (CheckKey(Keys.Enter))
     {
         if (popUpScreen.SelectedIndex == 0)
         {
             activeScreen.Hide();
             actionScreen.Hide();
             activeScreen = startScreen;
             activeScreen.Show();
         }
         if (popUpScreen.SelectedIndex == 1)
         {
             activeScreen.Hide();
             activeScreen = actionScreen;
             activeScreen.Show();
         }
     }
 }
Exemplo n.º 5
0
 private void HandleNetworkSelectScreenButtons(Control sender)
 {
     if (sender.Name == "HostGame")
     {
         gameType = Client.Client.GameType.hosted;
         activeScreen.Hide();
         activeScreen = hostGameScreen;
         activeScreen.Show();
     }
     if (sender.Name == "JoinGame")
     {
         //load join screen
         activeScreen.Hide();
         activeScreen = joinGameScreen;
         activeScreen.Show();
     }
     if (sender.Name == "BackButton")
     {
         //go back to startScreen
         activeScreen.Hide();
         activeScreen = startScreen;
         activeScreen.Show();
     }
 }
Exemplo n.º 6
0
 private void HandleJoinGameScreenButtons(Control sender)
 {
     if (sender.Name == "ScanLan")
     {
         //TODO: Only start client if local game is found
         gameType = Client.Client.GameType.scanLan;
         StartClient();
         Console.WriteLine("SCAN LAN!");
     }
     if (sender.Name == "Connect") //Join a network game by address
     {
         gameType = Client.Client.GameType.hosted;
         Console.WriteLine("Connect to {0}:{1}", joinGameScreen.Address, joinGameScreen.Port);
     }
     if (sender.Name == "BackButton")
     {
         activeScreen.Hide();
         activeScreen = networkScreen;
         activeScreen.Show();
     }
 }
Exemplo n.º 7
0
 private void HandleHostGameScreenButtons(Control sender)
 {
     if (sender.Name == "Start")
     {
         gameType = Client.Client.GameType.hosted;
         StartServer(gameType);
     }
     if (sender.Name == "BackButton")
     {
         activeScreen.Hide();
         activeScreen = networkScreen;
         activeScreen.Show();
     }
 }
Exemplo n.º 8
0
 private void HandleActionScreen()
 {
     if (CheckKey(Keys.F1))
     {
         //activeScreen.Hide();
         activeScreen.Enabled = false;
         activeScreen = popUpScreen;
         activeScreen.Show();
     }
 }