Esempio n. 1
0
 /// <summary>
 /// Constructor creates the Model!
 /// </summary>
 public SBoardViewModel()
 {
     //Create ourselves a model
     _clientModel = new ClientModel();
     //Subscribe to the Model's PropertyChanged event
     _clientModel.PropertyChanged += ClientModelChanged;
     //Create our two Command objects
     ConnectCommand = new DelegateCommand(
         a => _clientModel.Connect(),
         b => !_clientModel.Connected
         );
     SendCommand = new DelegateCommand(
         a => _clientModel.Send("PressF"),
         b => _clientModel.Connected
         );
     China2 = new DelegateCommand(
         a => _clientModel.Send("Bruh"),
         b => _clientModel.Connected
         );
     BingBong2 = new DelegateCommand(
         a => _clientModel.Send("BingBong"),
         b => _clientModel.Connected
         );
     GreatWall2 = new DelegateCommand(
         a => _clientModel.Send("Titanic"),
         b => _clientModel.Connected
         );
     ReallyRich2 = new DelegateCommand(
         a => _clientModel.Send("AirHorn"),
         b => _clientModel.Connected
         );
     FakeNews2 = new DelegateCommand(
         a => _clientModel.Send("FakeNews"),
         b => _clientModel.Connected
         );
     Wrong2 = new DelegateCommand(
         a => _clientModel.Send("AnotherOne"),
         b => _clientModel.Connected
         );
     BuildWall = new DelegateCommand(
         a => _clientModel.Send("Heyeyeya"),
         b => _clientModel.Connected
         );
     Havana = new DelegateCommand(
         a => _clientModel.Send("TakeOnMe"),
         b => _clientModel.Connected
         );
     Fired2 = new DelegateCommand(
         a => _clientModel.Send("DaWay"),
         b => _clientModel.Connected
         );
     Random = new DelegateCommand(
         a => _clientModel.Send("ToBeContinued"),
         b => _clientModel.Connected
         );
 }
Esempio n. 2
0
 /// <summary>
 /// Constructor creates the Model!
 /// </summary>
 public ClientViewModel()
 {
     //Create ourselves a model
     _clientModel = new ClientModel();
     //Subscribe to the Model's PropertyChanged event
     _clientModel.PropertyChanged += ClientModelChanged;
     //Create our two Command objects
     ConnectCommand = new DelegateCommand(
         a => _clientModel.Connect(),
         b => !_clientModel.Connected
         );
     SendCommand = new DelegateCommand(
         a => _clientModel.Send("PressF"),
         b => _clientModel.Connected
         );
     China2 = new DelegateCommand(
         a => _clientModel.Send("China"),
         b => _clientModel.Connected
         );
     BingBong = new DelegateCommand(
         a => _clientModel.Send("BingBong"),
         b => _clientModel.Connected
         );
     GreatWall = new DelegateCommand(
         a => _clientModel.Send("GreatWall"),
         b => _clientModel.Connected
         );
     ReallyRich = new DelegateCommand(
         a => _clientModel.Send("ReallyRich"),
         b => _clientModel.Connected
         );
     FakeNews = new DelegateCommand(
         a => _clientModel.Send("FakeNews"),
         b => _clientModel.Connected
         );
     Wrong = new DelegateCommand(
         a => _clientModel.Send("Wrong"),
         b => _clientModel.Connected
         );
     BuildWall = new DelegateCommand(
         a => _clientModel.Send("BuildWall"),
         b => _clientModel.Connected
         );
 }
Esempio n. 3
0
 /// <summary>
 /// Constructor creates the Model!
 /// </summary>
 public ClientViewModel()
 {
     //Create ourselves a model
     _clientModel = new ClientModel();
     //Subscribe to the Model's PropertyChanged event
     _clientModel.PropertyChanged += ClientModelChanged;
     //Create our chat command objects
     ConnectCommand = new DelegateCommand(
         a => _clientModel.Connect(),
         b => !_clientModel.Connected
         );
     SendCommand = new DelegateCommand(
         a => _clientModel.Send(),
         b => _clientModel.Connected
         );
     TTTMove_1 = new DelegateCommand(
         a => _clientModel.TTT_Move("x0y0")
         );
     TTTMove_2 = new DelegateCommand(
         a => _clientModel.TTT_Move("x1y0")
         );
     TTTMove_3 = new DelegateCommand(
         a => _clientModel.TTT_Move("x2y0")
         );
     TTTMove_4 = new DelegateCommand(
         a => _clientModel.TTT_Move("x0y1")
         );
     TTTMove_5 = new DelegateCommand(
         a => _clientModel.TTT_Move("x1y1")
         );
     TTTMove_6 = new DelegateCommand(
         a => _clientModel.TTT_Move("x2y1")
         );
     TTTMove_7 = new DelegateCommand(
         a => _clientModel.TTT_Move("x0y2")
         );
     TTTMove_8 = new DelegateCommand(
         a => _clientModel.TTT_Move("x1y2")
         );
     TTTMove_9 = new DelegateCommand(
         a => _clientModel.TTT_Move("x2y2")
         );
     //Create our game challenge objects
 }
Esempio n. 4
0
        static void Main(string[] args)
        {
            ClientModel client = ClientModel.Connect("127.0.0.1", 13000);

            Console.WriteLine("press any key to continue...");
            Console.ReadKey();

            bool playAgain = true;

            while (playAgain)
            {
                GuessNumberRequestData requestData = new GuessNumberRequestData();
                requestData.NewGame = true;
                client.SendData(DataConvertor.ToString <GuessNumberRequestData>(requestData));
                GuessNumberResponseData responseData = null;
                do
                {
                    if (requestData.NewGame)
                    {
                        requestData.NewGame = false;
                    }
                    else
                    {
                        Console.WriteLine("Wrong guess.");
                    }
                    int number;
                    Console.WriteLine("Guess number [0-9]:");
                    if (!int.TryParse(Console.ReadLine(), out number))
                    {
                        Console.WriteLine("Wrong input!");
                        continue;
                    }
                    requestData.GuessedNumber = number;
                    responseData = DataConvertor.FromString <GuessNumberResponseData>(client.SendData(DataConvertor.ToString <GuessNumberRequestData>(requestData)));
                } while (!responseData.RightNumber);
                Console.WriteLine("You did it! Wanna play again (press r to play again).");
                if (Console.ReadKey().Key != ConsoleKey.R)
                {
                    playAgain = false;
                }
            }
            Console.WriteLine("press any key to exit...");
            Console.ReadKey();
        }
Esempio n. 5
0
 /// <summary>
 /// Connect to server.
 /// </summary>
 public void Connect()
 {
     model.Connect();
 }