Ejemplo n.º 1
0
 // Send Message to server with position and player id
 private void SendMessage(TicTacSquareViewModel info)
 {
     OnReceiveMessage(info);
 }
Ejemplo n.º 2
0
        // Receive Callback/Message from server
        private void OnReceiveMessage(TicTacSquareViewModel info)
        {
            _counter++;
            Player = _counter % 2;
            Positions[info.GridPosition].Value = Player.GetCurrentMark();

            if (_counter >= 4 && GameEnded())
            {
                Message = "Player " + (Player + 1) + " wins!";
                // ResetBoard(null);
            }
            else if (_counter >= 9 && !GameEnded())
            {
                Message = "Draw!";
            }
            else
            {
                Message = "Player " + (Player + 1) + "'s turn...";
            }
            OnPropertyChanged("Message");
        }