Exemple #1
0
 /// <summary>
 /// Constructor
 /// Initializes all buttons and board
 /// </summary>
 public Board() {
     //the back button vector
     backb = new Vector2(0, Game1.ScreenHeight - 50);
     //the Chess Button vector
     chessb = new Vector2(Game1.ScreenWidth - 200, 200);
     //the Checkers button vector
     checkersb = new Vector2(Game1.ScreenWidth - 200, 300);
     //The Chinese Checkers or Sterne-Halma button vector
     chineseb = new Vector2(Game1.ScreenWidth - 200, 400);
     //The reset button vector
     resetb = new Vector2(Game1.ScreenWidth - 200, 500);
     //creates the back button
     back = new Button(backb, "back", "");
     //creates the chess button
     chess = new Button(chessb, "blank", "Chess");
     //creates the checkers button
     checkers = new Button(checkersb, "blank", "Checkers");
     //creates the chinese checkers button
     chinese = new Button(chineseb, "blank", "Sterne-Halma");
     //creates the reset button
     reset = new Button(resetb, "blank", "Reset");
     //initializes to the checkers board
     if (Game1.hosting) {
         currentGame = new Host_Intro();
         _type = "HIntro";
         _gametype = "HIntro";
     }
     else {
         currentGame = new Join_Intro();
         _type = "JIntro";
         _gametype = "JIntro";
     }
 }
Exemple #2
0
        /// <summary>
        /// Automatic Update method that does things per tick
        /// </summary>
        /// <param name="gameTime"></param>
        public override void Update(GameTime gameTime) {
            //tests for if the user has chosen to change the board type and changes it
            if (!_gametype.Equals(_type)) {
                currentGame.Type = _type;
            }
            switch (currentGame.Type) {
                case "HIntro":
                    currentGame = new Host_Intro();
                    _gametype = "HIntro";
                    break;
                case "JIntro":
                    currentGame = new Join_Intro();
                    _gametype = "JIntro";
                    break;
                case "ChineseCheckers":
                    currentGame = new ChineseCheckers();
                    _gametype = "ChineseCheckers";
                    break;
                case "Checkers":
                    currentGame = new Checkers();
                    _gametype = "Checkers";
                    break;
                case "Chess":
                    currentGame = new Chess();
                    _gametype = "Chess";
                    break;
                case "Reset":
                    switch (_gametype) {
                        case "ChineseCheckers":
                            currentGame = new ChineseCheckers();
                            _gametype = "ChineseCheckers";
                            break;
                        case "Checkers":
                            currentGame = new Checkers();
                            _gametype = "Checkers";
                            break;
                        case "Chess":
                            currentGame = new Chess();
                            _gametype = "Chess";
                            break;
                    }
                    break;

            }
            _type = _gametype;
            //gets the current state of the mouse
            MouseState state = Mouse.GetState();
            mposition.X = state.X;
            mposition.Y = state.Y;

            //if the mouse was clicked
            if (previousMouseState.LeftButton == ButtonState.Pressed && state.LeftButton == ButtonState.Released) {
                MouseClicked((int)mposition.X, (int)mposition.Y);
            }
            previousMouseState = state;
            currentGame.Update(gameTime);
        }