static Grid RenderNetGrid(Dictionary <string, string> gsa2names, Dictionary <string, RectList> name2rects, int rangeX, int rangeY, int rangeZ) { int width = rangeX * 64 * 2; int height = rangeY * 64 * 2; int depth = rangeZ * 64 * 2; Grid grid = RasterLib.RasterApi.CreateGrid(width, 64, depth, 4); int ox = width / 2; int oz = depth / 2; IPainter painter = RasterLib.RasterApi.Painter; for (int z = -rangeZ; z <= rangeZ; z++) { //for (int y = 0; y <= rangeY; y++) int y = 0; { for (int x = -rangeX; x <= rangeX; x++) { GridSpaceAddress gsa = new GridSpaceAddress(x, y, z); if (gsa2names.ContainsKey(gsa.ToString())) { string name = gsa2names[gsa.ToString()]; RectList cellRects = name2rects[name]; Console.WriteLine("Rendering " + name); RasterLib.RasterApi.Renderer.RenderRectsToGrid(cellRects, grid, x * 64 + ox, y * 64, z * 64 + oz); } } } } GC.Collect(); return(grid); }
static Grid RenderFlatGrid(Dictionary <string, string> gsa2names, Dictionary <string, RectList> name2rects, int rangeX, int rangeY, int rangeZ) { int width = rangeX * 64; int height = rangeZ * 64; Grid grid = RasterLib.RasterApi.CreateGrid(width, height, 1, 4); IPainter painter = RasterLib.RasterApi.Painter; for (int z = -rangeZ; z <= rangeZ; z++) { //for (int y = 0; y <= rangeY; y++) int y = 0; { for (int x = -rangeX; x <= rangeX; x++) { GridSpaceAddress gsa = new GridSpaceAddress(x, y, z); if (gsa2names.ContainsKey(gsa.ToString())) { string name = gsa2names[gsa.ToString()]; RectList cellRects = name2rects[name]; Console.WriteLine("Rendering " + name); Grid tempGrid = new Grid(64, 64, 64, 4); RasterLib.RasterApi.Renderer.RenderRectsToGrid(cellRects, tempGrid, 0, 0, 0); BirdsEye(tempGrid, grid, (x + rangeX) * 64 / 2, (z + rangeZ) * 64 / 2); } } } } GC.Collect(); return(grid); }
static void Main(string[] args) { //const string URL = "http://localhost:3838/api/simulation?GateTimer"; //Connect to simulation server and display grid bool done = false; int x = 0; int y = 0; int z = 0; char _lastKey = ' '; ServerLib.MegaGridClient client = new MegaGridClient("http://localhost:3838"); while (!done) { if (Console.KeyAvailable) { ConsoleKeyInfo key = Console.ReadKey(); _lastKey = key.KeyChar; if (_lastKey == 27) { done = true; } switch (_lastKey) { case 'a': x--; break; case 'd': x++; break; case 'w': z++; break; case 's': z--; break; case 'e': y++; break; case 'q': y--; break; } } GridSpaceAddress gsa = new GridSpaceAddress(x, y, z); string name = client.RequestNameAtGSA(gsa); string rectsStr = client.RequestRects(name); SerializedRects srects = new SerializedRects(rectsStr); Console.WriteLine(srects.SerializedData); //RectList rects = Pivot.ToRects(srects); //Console.WriteLine(rects); try { string response = RequestData("http://localhost:3838/api/simulation?" + name); Console.Out.WriteLine(response); } catch (Exception e) { Console.Out.WriteLine("-----------------"); Console.Out.WriteLine(e.Message); } Thread.Sleep(1000); Console.WriteLine("GSA: " + gsa.ToString() + " = '" + name + "'"); } }
static void Main(string[] args) { int rangeX = 10; int rangeY = 1; int rangeZ = 10; string[,] stringGrid = new string[rangeX * 2, rangeZ * 2]; ServerLib.MegaGridClient client = new MegaGridClient("http://localhost:3838"); Dictionary <string, string> gsa2names = client.GetNames(rangeX * 2, rangeY, rangeZ * 3); Dictionary <string, RectList> name2rects = client.Names2Rects(gsa2names); Console.WriteLine("Names and Rectangles resolved."); int avX = 0; int avY = 0; int avZ = 0; int viewX = 0; int viewY = 0; int viewZ = 0; char _lastKey = ' '; bool done = false; string name = "Roads"; bool recordString = false; while (!done) { Console.Clear(); //TextGrid.DrawGrid(stringGrid); TextGrid.DrawGrid(gsa2names, avX, avY, avZ, viewX, viewY, viewZ, rangeX, rangeY, rangeZ); if (Console.KeyAvailable) { ConsoleKeyInfo key = Console.ReadKey(); _lastKey = key.KeyChar; if (recordString) { if (_lastKey == '\r') { recordString = false; } else { name += _lastKey; } } else { if (_lastKey == 27) { done = true; } switch (_lastKey) { case '/': recordString = true; name = ""; break; case 'o': break; case 'a': avX--; break; case 'd': avX++; break; case 's': avZ++; break; case 'w': avZ--; break; case 'j': viewX--; break; case 'l': viewX++; break; case 'i': viewZ++; break; case 'k': viewZ--; break; case ' ': name = gsa2names[GridSpaceAddress.MakeString(avX, avY, avZ)]; break; case '\b': { GridSpaceAddress gsa = new GridSpaceAddress(avX, avY, avZ); gsa2names[gsa.ToString()] = name; client.RequestSetNameAtGSA(gsa, name); break; } } } } Console.WriteLine("Clipboard: '" + name + "'"); Thread.Sleep(25); } }