Esempio n. 1
0
        public MainWindow()
        {
            InitializeComponent();

            var configuration = GameMaster.GameMasterConfiguration.GetDefault();

            GMConfig = Configuration.Configuration.ReadFromFile(Constants.ConfigurationFilePath);
            if (GMConfig != null)
            {
                configuration = GMConfig.ConvertToGMConfiguration();
            }

            gameMaster = new GameMaster.GameMaster(configuration);

            Board = new BoardComponent(BoardCanvas);

            GMConfig.PropertyChanged += GMConfig_PropertyChanged;

            guiTimer          = new DispatcherTimer();
            guiTimer.Interval = TimeSpan.FromMilliseconds(16);
            guiTimer.Tick    += GuiTimerEvent;
            guiTimer.Start();

            gameMasterThread = new Task(RunGameMasterThread);
            gameMasterThread.Start();
        }
Esempio n. 2
0
        private void ConnectRadioButton_Checked(object sender, RoutedEventArgs e)
        {
            if (IsConnecting == true)
            {
                return;
            }

            gameMasterMutex.WaitOne();
            IsConnecting = true;
            gameMaster.SetConfiguration(GMConfig.ConvertToGMConfiguration());

            try
            {
                gameMaster.ConnectToCommunicationServer();
                ConnectRadioButton.Content = "Connected";
                StartRadioButton.IsEnabled = true;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Exception occured!", MessageBoxButton.OK, MessageBoxImage.Error);
                IsConnecting = false;
                ConnectRadioButton.IsChecked = false;
            }


            gameMasterMutex.ReleaseMutex();
        }