예제 #1
0
        static void Main(string[] args)
        {
            VictoryValidator victoryValidator = new VictoryValidator();
            PlayerFactory playerFactory = new PlayerFactory(victoryValidator);
            ScenarioFactory scenarioFactory = new ScenarioFactory(playerFactory);

            TicTacToeControlsViewModel TicTacToeControlsViewModel = new TicTacToeControlsViewModel(new TicTacToeControlsModel(), scenarioFactory);
            TicTacToeGridViewModel TicTacToeGridViewModel = new TicTacToeGridViewModel(new TicTacToeGridModel(), TicTacToeControlsViewModel);
            GameWindowViewModel GameWindowViewModel = new GameWindowViewModel(TicTacToeControlsViewModel, TicTacToeGridViewModel);

            GameWindow gameWindow = new GameWindow(GameWindowViewModel);
            gameWindow.ShowDialog();
        }
예제 #2
0
        static void Main(string[] args)
        {
            VictoryValidator victoryValidator = new VictoryValidator();
            PlayerFactory    playerFactory    = new PlayerFactory(victoryValidator);
            ScenarioFactory  scenarioFactory  = new ScenarioFactory(playerFactory);

            TicTacToeControlsViewModel TicTacToeControlsViewModel = new TicTacToeControlsViewModel(new TicTacToeControlsModel(), scenarioFactory);
            TicTacToeGridViewModel     TicTacToeGridViewModel     = new TicTacToeGridViewModel(new TicTacToeGridModel(), TicTacToeControlsViewModel);
            GameWindowViewModel        GameWindowViewModel        = new GameWindowViewModel(TicTacToeControlsViewModel, TicTacToeGridViewModel);

            GameWindow gameWindow = new GameWindow(GameWindowViewModel);

            gameWindow.ShowDialog();
        }
예제 #3
0
        static void Main(string[] args)
        {
            string[,] TicTacToeBoard = new string[3, 3];
            // Use an interface to encourage polymorphism - ability of an object to take on many forms
            IPlayer player1;
            IPlayer player2;

            VictoryValidator gameEngine = new VictoryValidator();
            GameVisualizer gameVisualizer = new GameVisualizer();
            // Inject dependencies
            GameManager gameManager = new GameManager(gameVisualizer, gameEngine);

            //GameWindow gameWindow = new GameWindow();
            //gameWindow.ShowDialog();

            while (true)
            {
                Console.WriteLine("Choose playing mode - 2 Players or Computer(AI)?");
                var mode = Console.ReadLine().ToUpper();

                // Polymorphism - Two objects are of the same type, but they can be interchangable and defined by the user
                if (mode.Equals("2 PLAYERS"))
                {
                    player1 = new RealPlayer();
                    player2 = new RealPlayer();
                    break;
                }
                else if (mode.Equals("AI"))
                {
                    player1 = new RealPlayer();
                    player2 = new AIPlayer();
                    break;
                }
            }

            //Play game just plays game, not about who the players are, so its better to pass in the players to play the game.
            gameManager.PlayGame(TicTacToeBoard, player1, player2);
        }
예제 #4
0
        [STAThread] //STA-Single Threaded Apartment, refers to the threading model used by the current main thread.
        static void Main(string[] args)
        {
            string[,] TicTacToeBoard = new string[3, 3];
            // Use an interface to encourage polymorphism - ability of an object to take on many forms
            IPlayer player1;
            IPlayer player2;

            VictoryValidator gameEngine     = new VictoryValidator();
            GameVisualizer   gameVisualizer = new GameVisualizer();
            // Inject dependencies
            GameManager gameManager = new GameManager(gameVisualizer, gameEngine);

            //GameWindow gameWindow = new GameWindow();
            //gameWindow.ShowDialog();

            while (true)
            {
                Console.WriteLine("Choose playing mode - 2 Players or Computer(AI)?");
                var mode = Console.ReadLine().ToUpper();

                // Polymorphism - Two objects are of the same type, but they can be interchangable and defined by the user
                if (mode.Equals("2 PLAYERS"))
                {
                    player1 = new RealPlayer();
                    player2 = new RealPlayer();
                    break;
                }
                else if (mode.Equals("AI"))
                {
                    player1 = new RealPlayer();
                    player2 = new AIPlayer();
                    break;
                }
            }

            //Play game just plays game, not about who the players are, so its better to pass in the players to play the game.
            gameManager.PlayGame(TicTacToeBoard, player1, player2);
        }
예제 #5
0
 // Inject our classes as "dependencies" in our constructors
 // Pass in class names in actual parameters (dependency injection)
 public GameManager(GameVisualizer argGameVisualizer, VictoryValidator argVictoryValidator)
 {
     _gameVisualizer   = argGameVisualizer;
     _victoryValidator = argVictoryValidator;
 }
예제 #6
0
 // Inject our classes as "dependencies" in our constructors
 // Pass in class names in actual parameters (dependency injection)
 public GameManager(GameVisualizer argGameVisualizer, VictoryValidator argVictoryValidator)
 {
     _gameVisualizer = argGameVisualizer;
     _victoryValidator = argVictoryValidator;
 }