Exemplo n.º 1
0
        //init
        public MainWindow()
        {
            config = new Configuration();

            StartUpScreen startUpScreen = new StartUpScreen(config);
            startUpScreen.ShowDialog();

            CreateGameLogic(config);

            game.GameOverEvent += HandleGameOver;
            game.PlayerMovesEvent += HandlePlayerMoves;

            InitializeComponent();

            AdjustUIPlayersNames();

            //The UI should easily update Buttons when an event is sent from the Engine(on GameOver or PLayerMoves)
            gameFieldUI = new Button[9];

            gameFieldUI[0] = this.One;
            gameFieldUI[1] = this.Two;
            gameFieldUI[2] = this.Three;
            gameFieldUI[3] = this.Four;
            gameFieldUI[4] = this.Five;
            gameFieldUI[5] = this.Six;
            gameFieldUI[6] = this.Seven;
            gameFieldUI[7] = this.Eight;
            gameFieldUI[8] = this.Nine;
        }
Exemplo n.º 2
0
        public StartUpScreen(Configuration config)
        {
            this.config = config;

            InitializeComponent();

            startUpScreenGrid.Background = Brushes.DarkCyan;
            listBoxChooseMode.Background = null;
            listBoxSign.Background = null;

            checkBoxSinglePlayer.IsChecked = true;
            checkBoxMultiPlayer.IsChecked = false;

            checkBoxSignX.IsChecked = true;
            checkBoxSignO.IsChecked = false;
        }
Exemplo n.º 3
0
        //Creating a custom Game depending on User choice
        private void CreateGameLogic(Configuration config)
        {
            if (config.ChosenMode.Equals("multy"))
            {
                if (config.ChosenSign.Equals(TypeOfSign.X))
                {
                    game = new GameLogic.Engine(new List<Player>()
                    {
                        new HumanPlayer("Player 2", 0, TypeOfSign.O),
                        new HumanPlayer("Player 1", 1, TypeOfSign.X)
                    }, 3);

                }
                else
                {
                    game = new GameLogic.Engine(new List<Player>()
                    {
                        new HumanPlayer("Player 2", 0, TypeOfSign.X),
                        new HumanPlayer("Player 1", 1, TypeOfSign.O)
                    }, 3);
                }
                return;
            }
            else
            {
                if (config.ChosenSign.Equals(TypeOfSign.X))
                {
                    game = new GameLogic.Engine(new List<Player>()
                    {
                        new HumanPlayer("AI Player", 0, TypeOfSign.O),
                        new AIPlayer("Player 1", 1, TypeOfSign.X)
                    }, 3);
                }
                else
                {
                    game = new GameLogic.Engine(new List<Player>()
                    {
                        new HumanPlayer("AI Player", 0, TypeOfSign.X),
                        new AIPlayer("Player 1", 1, TypeOfSign.O)
                    }, 3);
                }

                return;
            }
        }
Exemplo n.º 4
0
        /// <summary>
        /// New game works at some extend:
        /// TO DO:
        /// call it from method, better handling and last game import to history
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void menuNewGameClick(object sender, Telerik.Windows.RadRoutedEventArgs e)
        {
            config = new Configuration();

            StartUpScreen startUpScreen = new StartUpScreen(config);
            startUpScreen.ShowDialog();

            CreateGameLogic(config);

            game.GameOverEvent += HandleGameOver;
            game.PlayerMovesEvent += HandlePlayerMoves;

            InitializeComponent();

            AdjustUIPlayersNames();

            //The UI should easily update Buttons when an event is sent from the Engine(on GameOver or PLayerMoves)
            gameFieldUI = new Button[9];

            gameFieldUI[0] = this.One;
            gameFieldUI[1] = this.Two;
            gameFieldUI[2] = this.Three;
            gameFieldUI[3] = this.Four;
            gameFieldUI[4] = this.Five;
            gameFieldUI[5] = this.Six;
            gameFieldUI[6] = this.Seven;
            gameFieldUI[7] = this.Eight;
            gameFieldUI[8] = this.Nine;

            #region clearing button content and activating buttons change name

            One.Content = "";
            Two.Content = "";
            Three.Content = "";
            Four.Content = "";
            Five.Content = "";
            Six.Content = "";
            Seven.Content = "";
            Eight.Content = "";
            Nine.Content = "";
            buttonChangePlayerOneName.IsEnabled = true;
            if (startUpScreen.checkBoxMultiPlayer.IsChecked==true)
            {
                buttonChangePlayerTwoName.IsEnabled = true;
            }
            #endregion
        }