コード例 #1
0
        private static void ResolveMovement(ClientConnection client, string movement)
        {
            string move   = movement.Substring(0, 4);
            var    result = client.game.ResolveMovement(move);

            if (result.move == Direction.None)
            {
                return;
            }
            client.Send($"POS:{result.x}x{result.y}");
        }
コード例 #2
0
        private static void SendCurrentMap(ClientConnection client)
        {
            PacmanGame    game = client.game;
            List <string> map  = game.map.GetText();
            int           w    = game.map.width;
            int           h    = game.map.height;

            map.Insert(0, $"{game.pacmanX}x{game.pacmanY}");
            map.Insert(0, $"{w}x{h}");
            strbuilder.Clear();
            for (int i = 0; i < map.Count; i++)
            {
                strbuilder.Append(map[i]);
                char append = (i == map.Count - 1) ? ClientConnection.terminator : ClientConnection.delimiter;
                strbuilder.Append(append);
            }
            client.Send(strbuilder.ToString());
            strbuilder.Clear();
        }
コード例 #3
0
 public void SendToClient(ClientConnection client, string message, bool terminated)
 {
     client.Send(message, terminated);
 }