public StartUpMenuViewModel() { StartGameCommand = new RelayParameterizedCommand((parameter) => StartGame(parameter)); }
//game wining mechanism incomplete //red home column enter problem //double piece zindex problem //piece win message not working //piece position after reopening the beaten piece not correct(cause start index & current index are referencing same address) //if the player has beaten a piece only then he should be allowed to enter the home column #endregion #region Default Constructor public GameBoardViewModel(int playerNumber, double height, Grid grid) { //set the grids width and height grid.Height = height; grid.Width = height; GameBoardHeight = height; this.grid = grid; //set the number of players switch (playerNumber) { case 2: NumberOfPlayer = PlayerType.Blue; break; case 3: NumberOfPlayer = PlayerType.Green; break; case 4: NumberOfPlayer = PlayerType.Yellow; break; default: break; } //initialize the position , HomePosition and safe position lists SetPositionList(); SetHomePosition(); SetSafePosition(); //initialize the Players RedPlayer = new Player(1, PlayerType.Red); BluePlayer = new Player(20, PlayerType.Blue); GreenPlayer = new Player(39, PlayerType.Green); YellowPlayer = new Player(58, PlayerType.Yellow); //initialize the player list Players = new List <Player>(); //add the players Players.Add(RedPlayer); Players.Add(BluePlayer); Players.Add(GreenPlayer); Players.Add(YellowPlayer); //initialize the commands PieceCommand = new RelayParameterizedCommand((parameter) => Piece_Click(parameter)); RollDiceCommand = new RelayCommand(RollDice); MoveNextCommand = new RelayCommand(MoveNextCommandMethod); RestartCommand = new RelayCommand(Restart); int index = 0; //add all pieces in game board for (int j = 0; j < 4; j++) { for (int i = 0; i < 4; i++) { var Piece = Players[j].Pieces[i]; grid.Children.Add(Piece); Piece.HomeIndex = index; var NewPosition = _HomePosition[index++]; Grid.SetColumn(Piece, NewPosition.Column); Grid.SetRow(Piece, NewPosition.Row); } } //initialize the random variable rollDice = new Random(); Dice = new ObservableCollection <int>(); //set the first player turn PlayerTurn = ActivePlayerType.ToString(); }