Пример #1
0
        private void ResponseWrapper()
        {
            string response = tcpClient.LastResponse;

            if (response == "requesting move")
            {
                tcpClient.SendRequest(snakeUser.SendNextDireciton());
            }
            else if (response == "game over")
            {
                state = "postgame";
                string winner = map.getWinner();
                if (winner == "none")
                {
                    postgameMessage = "Everyone lost";
                }
                else if (winner == "multiple")
                {
                    postgameMessage = "server fail";
                }
                else
                {
                    postgameMessage = String.Format("{0} won!", winner);
                }
                tcpClient.Disconnect();
            }
            else
            {
                MapUpdatePacket mapUpdatePacket = new MapUpdatePacket(tcpClient.LastResponse);
                map.UpdateFromMapUpdatePacket(mapUpdatePacket);
            }
        }