2 using System.Collections.Generic;
5 using System.Net.Sockets;
7 using System.Threading.Tasks;
13 static void Main(string[] args)
15 TcpJsonConnection con = new TcpJsonConnection(DisplayServerInformation);
17 con.Connect(Dns.GetHostEntry(Dns.GetHostName()).AddressList[1]); //localhost
18 // con.Connect(IPAddress.Parse("fe80::c0a:44f1:63e7:bfb8%4"));
19 // con.Connect(IPAddress.Parse("127.0.0.1"));
23 con.SendEvent(TcpJsonConnection.InputState.Right);
24 System.Threading.Thread.Sleep(100);
25 con.SendEvent(TcpJsonConnection.InputState.Down);
26 System.Threading.Thread.Sleep(100);
27 con.SendEvent(TcpJsonConnection.InputState.Left);
28 System.Threading.Thread.Sleep(100);
29 con.SendEvent(TcpJsonConnection.InputState.Up);
30 System.Threading.Thread.Sleep(100);
32 con.SendEvent(TcpJsonConnection.InputState.Idle);
33 con.SendEvent(TcpJsonConnection.InputBomb.PlaceBomb);
34 System.Threading.Thread.Sleep(100);
35 con.SendEvent(TcpJsonConnection.InputBomb.Idle);
36 System.Threading.Thread.Sleep(100);
38 if(Console.KeyAvailable)
51 static void DisplayServerInformation(TcpJsonConnection.ServerPackage pkg)
53 char[,] playground = new char[pkg.Field.Count,pkg.Field.Count];
56 for (int i = 0; i < pkg.Field.Count; i++)
58 for (int j = 0; j < pkg.Field[i].Count; j++)
60 playground[i,j]= FieldTypeToChar(pkg.Field[i][j]);
64 foreach(var player in pkg.Players)
66 playground[(int)player.Y, (int)player.X] = System.Convert.ToChar(player.Id + '0');
69 foreach (var bomb in pkg.Bombs)
71 playground[(int)bomb.Y, (int)bomb.X] = 'o';
74 foreach (var flame in pkg.Flames)
76 playground[(int)flame.Y, (int)flame.X] = '/';
81 for (int i = 0; i < pkg.Field.Count; i++)
83 for (int j = 0; j < pkg.Field[i].Count; j++)
85 Console.Write(playground[i, j]);
93 static char FieldTypeToChar(TcpJsonConnection.ServerPackage.FieldTypes field)
97 case TcpJsonConnection.ServerPackage.FieldTypes.DynamicOrDestroyableBlock:
99 case TcpJsonConnection.ServerPackage.FieldTypes.StaticOrUndestroyableBlock:
101 case TcpJsonConnection.ServerPackage.FieldTypes.ItemOrMoreBombs: