예제 #1
0
        /*The filters to select which type of player you want is created dynamically starting from the Enum list describing the
         * list of available player type, if you add a new type of player you don't have to update the view
         */
        private void InitializePlayersTypes()
        {
            Guid guidPlayerOne = Guid.NewGuid();
            Guid guidPlayerTwo = Guid.NewGuid();

            PlayerOnePlayerType = new ObservableCollection <PlayerTypeBinder>();
            PlayerTwoPlayerType = new ObservableCollection <PlayerTypeBinder>();
            foreach (PlayerType playerType in Enum.GetValues(typeof(PlayerType)))
            {
                PlayerTypeBinder playerOneTypeBinder = new PlayerTypeBinder
                {
                    PlayerType  = playerType,
                    Group       = guidPlayerOne,
                    IsChecked   = playerType == PlayerType.HumanPlayer ? true : false,
                    Description = EnumHelper.GetEnumDescription(playerType)
                };
                PlayerOnePlayerType.Add(playerOneTypeBinder);

                PlayerTypeBinder playerTwoTypeBinder = new PlayerTypeBinder
                {
                    PlayerType  = playerType,
                    Group       = guidPlayerTwo,
                    IsChecked   = playerType == PlayerType.ComputerPlayer ? true : false,
                    Description = EnumHelper.GetEnumDescription(playerType)
                };
                PlayerTwoPlayerType.Add(playerTwoTypeBinder);
            }
        }
예제 #2
0
        private void OnStartNewGameCommand()
        {
            PlayerTypeBinder binderPlOne = PlayerOnePlayerType.FirstOrDefault(i => i.IsChecked);
            IPlayer          playerOne   = CreatePlayer(binderPlOne.PlayerType);

            playerOne.PlayerName = PlayerOneName;
            playerOne.PlayerType = binderPlOne.PlayerType;

            PlayerTypeBinder binderPlTwo = PlayerTwoPlayerType.FirstOrDefault(i => i.IsChecked);
            IPlayer          playerTwo   = CreatePlayer(binderPlTwo.PlayerType);

            playerTwo.PlayerName = PlayerTwoName;
            playerTwo.PlayerType = binderPlTwo.PlayerType;

            //TODO: Bind this to a property of the options to make the number of turns selectable.
            //PS: changing this value manualy already works

            _game.NumerberOfTurns = 3;
            _game.PlayerOne       = playerOne;
            _game.PlayerTwo       = playerTwo;
            _game.Rules           = new RockPaperScissorsRules();
            MainRegion.NavigateTo(typeof(GameView));
        }