Exemplo n.º 1
0
 private void startGamePhase(gamePhaseState obj)
 {
     GameWindow gameWindow = new GameWindow(obj.field, obj.socket);
     gameWindow.Show();
     this.Close();
 }
Exemplo n.º 2
0
        private void parse(string szData, IAsyncResult asyn)
        {
            Console.WriteLine(szData);
            string[] stringSeparators = new string[] { DELIMITER };
            String[] commands = szData.Split(stringSeparators, StringSplitOptions.RemoveEmptyEntries);

            foreach (String command in commands)
            {
                String[] args = command.Split(' ');

                switch (args[0])
                {
                    case "CONFIRM":

                        switch (waitForCommit)
                        {
                            case "":
                                Console.WriteLine("Unexpected CONFIRM");
                                break;
                            case "POSITION":
                                //Start GAME

                                m_pfnCallBack = null;
                                newEra = true;
                                 gamePhaseState gps = new gamePhaseState(gameField, m_clientSocket);
                                Dispatcher.Invoke(System.Windows.Threading.DispatcherPriority.Normal,
                                new Action<gamePhaseState>(startGamePhase),
                                gps);

                                break;
                        }

                        waitForCommit = "";
                        break;

                    /*case "C": //REMOVE!!!! TODO

                        switch (waitForCommit)
                        {
                            case "":
                                Console.WriteLine("Unexpected CONFIRM");
                                break;
                            case "POSITION":
                                //Start GAME

                                m_pfnCallBack = null;
                                newEra = true;
                                gamePhaseState gps = new gamePhaseState(gameField, m_clientSocket);
                                Dispatcher.Invoke(System.Windows.Threading.DispatcherPriority.Normal,
                                new Action<gamePhaseState>(startGamePhase),
                                gps);

                                break;
                        }

                        waitForCommit = "";
                        break;   */

                    case "EXIT_GAME":
                        MessageBox.Show("Server ended the game", "ERROR");
                        this.Close();
                        break;

                    case "REJECT":

                        MessageBox.Show("Field was rejected", "ERROR");
                        break;

                }

            }
        }