Пример #1
0
        private void neuesSpielToolStripMenuItem_Click(object sender, EventArgs e)
        {
            NewGameForm f = new NewGameForm();

            if (f.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                _game = f.GameMode;
                _game.BDarsteller.Enabled = true;
                EnableBrett();
                ((BrettDarsteller)_game.BDarsteller).BrettUpdateEvent += UpdateBrett;
                ((BrettDarsteller)_game.BDarsteller).BrettEnableEvent += EnableBrett;
                _game.PlayerOutputEvent      += OutputPlayer;
                _game.WindowTitleChangeEvent += ChangeWindowTitle;
                _game.WinMessageEvent        += OutputWinMessage;
                OutputPlayer(_game.Player.Ausgabe());
                _game.Initialize();
                label1.Location = new Point(80, label1.Location.Y);
                if (_game.Player is Logik.Player.AIPlayer || _game.Player is Logik.Player.NetworkPlayer)
                {
                    _taskTurn = true;
                }
                if (_game is Logik.Game.NetworkGame)
                {
                    ((Logik.Game.NetworkGame)_game).newGameRequestReceivedEvent += ResetGame;
                }
                _spieler1Anfang = f.Spieler1Anfang;
                _spieler2Anfang = f.Spieler2Anfang;
            }
        }
Пример #2
0
 public Game(Logik.Game.Game gameMode)
 {
     _gameMode = gameMode;
     _gameMode.GetIntEvent += GetInt;
     _gameMode.GetStringEvent += Console.ReadLine;
     _gameMode.ShowMessageEvent += Console.WriteLine;
     _gameMode.WinMessageEvent += WinMessage;
     _gameMode.PlayerOutputEvent += PlayerOutput;
     _gameMode.WindowTitleChangeEvent += TitleChange;
     _gameMode.Initialize();
 }
Пример #3
0
 public Game(Logik.Game.Game gameMode)
 {
     _gameMode                         = gameMode;
     _gameMode.GetIntEvent            += GetInt;
     _gameMode.GetStringEvent         += Console.ReadLine;
     _gameMode.ShowMessageEvent       += Console.WriteLine;
     _gameMode.WinMessageEvent        += WinMessage;
     _gameMode.PlayerOutputEvent      += PlayerOutput;
     _gameMode.WindowTitleChangeEvent += TitleChange;
     _gameMode.Initialize();
 }
Пример #4
0
 public Form1()
 {
     InitializeComponent();
     _game = new Logik.Game.Game(new Logik.Player.Player('X'), new Logik.Player.Player('O'), new BrettDarsteller(3, 3), new Logik.Fields.Brett(3, 3));
     ((BrettDarsteller)_game.BDarsteller).BrettUpdateEvent += UpdateBrett;
     ((BrettDarsteller)_game.BDarsteller).BrettEnableEvent += EnableBrett;
     _game.PlayerOutputEvent      += OutputPlayer;
     _game.WindowTitleChangeEvent += ChangeWindowTitle;
     _game.WinMessageEvent        += OutputWinMessage;
     OutputPlayer(_game.Player1.Ausgabe());
     _game.Initialize();
     MouseClick     += MouseNewStart;
     _taskToken      = new CancellationTokenSource();
     _playerWaitTask = new Task(new Action(WaitForPlayerTask), _taskToken.Token);
     _playerWaitTask.Start();
     _isGameWindowClosed = false;
     FormClosed         += GameWindowClosedEvent;
 }
Пример #5
0
 public Form1()
 {
     InitializeComponent();
     _game = new Logik.Game.Game(new Logik.Player.Player('X'), new Logik.Player.Player('O'), new BrettDarsteller(3, 3), new Logik.Fields.Brett(3, 3));
     ((BrettDarsteller)_game.BDarsteller).BrettUpdateEvent += UpdateBrett;
     ((BrettDarsteller)_game.BDarsteller).BrettEnableEvent += EnableBrett;
     _game.PlayerOutputEvent += OutputPlayer;
     _game.WindowTitleChangeEvent += ChangeWindowTitle;
     _game.WinMessageEvent += OutputWinMessage;
     OutputPlayer(_game.Player1.Ausgabe());
     _game.Initialize();
     MouseClick += MouseNewStart;
     _taskToken = new CancellationTokenSource();
     _playerWaitTask = new Task(new Action(WaitForPlayerTask), _taskToken.Token);
     _playerWaitTask.Start();
     _isGameWindowClosed = false;
     FormClosed += GameWindowClosedEvent;
 }
Пример #6
0
 private void neuesSpielToolStripMenuItem_Click(object sender, EventArgs e)
 {
     NewGameForm f = new NewGameForm();
     if (f.ShowDialog() == System.Windows.Forms.DialogResult.OK)
     {
         _game = f.GameMode;
         _game.BDarsteller.Enabled = true;
         EnableBrett();
         ((BrettDarsteller)_game.BDarsteller).BrettUpdateEvent += UpdateBrett;
         ((BrettDarsteller)_game.BDarsteller).BrettEnableEvent += EnableBrett;
         _game.PlayerOutputEvent += OutputPlayer;
         _game.WindowTitleChangeEvent += ChangeWindowTitle;
         _game.WinMessageEvent += OutputWinMessage;
         OutputPlayer(_game.Player.Ausgabe());
         _game.Initialize();
         label1.Location = new Point(80, label1.Location.Y);
         if (_game.Player is Logik.Player.AIPlayer || _game.Player is Logik.Player.NetworkPlayer)
         {
             _taskTurn = true;
         }
         if (_game is Logik.Game.NetworkGame)
         {
             ((Logik.Game.NetworkGame)_game).newGameRequestReceivedEvent += ResetGame;
         }
         _spieler1Anfang = f.Spieler1Anfang;
         _spieler2Anfang = f.Spieler2Anfang;
     }
 }