Beispiel #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;
        }
Beispiel #2
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
        }