public static async Task JobManager(Job job) { job.IsActive = true; while (job.IsActive) { if (job.Type == 2) { job.ElapsedTime.Start(); Console.WriteLine($"Sending Confirmation for Job ID {job.ID}..."); Speaker(new byte[] { 2, job.ID }, Client, Endpoint); if (job.ElapsedTime.ElapsedMilliseconds > 5000) { job.IsActive = false; return; } await Task.Delay(1000); } else if (job.Type == 5) { if (job.BiomeList.Count == 25 && job.LandList.Count == 25) { byte[] biome = new byte[1000000]; byte[] land = new byte[1000000]; int count = 0; foreach (byte[] b in job.BiomeList) { System.Buffer.BlockCopy(b, 0, biome, count, b.Length); count = count + b.Length; } count = 0; foreach (byte[] b in job.LandList) { System.Buffer.BlockCopy(b, 0, land, count, b.Length); count = count + b.Length; } for (int y = 0; y < 1000; y++) { for (int x = 0; x < 1000; x++) { landArray[x, y] = new Land(); landArray[x, y].biome = biome[(y * 1000) + x]; landArray[x, y].land = land[(y * 1000) + x]; } } Console.WriteLine($"Byte List Full!"); MainMenuOpen = false; LogicClock40.Start(); LogicClock100.Start(); LogicClock250.Start(); LogicClock500.Start(); LogicClock1000.Start(); Job j = new Job(job.ID, 2, job.Employee, job.Employer); UserList[0].JobList.Add(j); JobManager(j); job.IsCompleted = true; job.IsActive = false; return; } Speaker(new byte[] { 5, job.ID }, Client, Endpoint); } await Task.Delay(1000); } }
public static async Task All() { double rnd; byte biomeHolder; Land checkPosX; Land checkPosY; Land checkNegX; Land checkNegY; Land checkTile; /* * The following statements will populate the land values of the default array 1000 x 1000 * as well as the tile cache array currently 400 x 250 which will * support the tile scale .1 (10x) on most resolution scales * ^^--pending optimization--^^ * a roll is done to determine some land values as well as if the tile will be a new biome * and then check the previously drawn X & Y tiles for water or trees to increase clumping * before going on to generate full biomes, to scale * the biomes are then expanded on with more complex near-by random tile generation * done through multiple rescans of the default global land array for definition * default snow i = 40 * default ore i = 5 */ for (int y = 0; y < 1000; y++) { for (int x = 0; x < 1000; x++) { rnd = Random.Next(0, 10000); ///////////////////////// // New Biome Initiator // ///////////////////////// if (rnd < 5) { biomeHolder = 0; } else { biomeHolder = 1; } ///////////////////////////////////////////////////////////// // Randomly Generate and Instantiate Land Stored in Arrays // ///////////////////////////////////////////////////////////// landArray[x, y] = new Land(); landArray[x, y].biome = biomeHolder; if (rnd <= 9390) { landArray[x, y].land = 0; } else if (rnd > 9390 && rnd <= 9400) { landArray[x, y].land = 2; } else if (rnd > 9400 && rnd <= 9800) { landArray[x, y].land = 3; } else if (rnd > 9800 && rnd <= 9900) { landArray[x, y].land = 4; } else if (rnd > 9900 && rnd <= 9995) { landArray[x, y].land = 5; } else if (rnd > 9995) { landArray[x, y].land = -6; } ///////////////////// // Realistic Water // ///////////////////// if (landArray[Check.Min(x - 1, 0), y].land == 2 && rnd < 5300) { landArray[x, y].land = 2; } else if (landArray[x, Check.Min(y - 1, 0)].land == 2 && rnd < 5300) { landArray[x, y].land = 2; } else if (landArray[x, Check.Min(y - 1, 0)].land == 2 && landArray[Check.Min(x - 1, 0), y].land == 2 && rnd < 9900) { landArray[x, y].land = 2; } /////////////////////// // Realistic Forests // /////////////////////// if (landArray[Check.Min(x - 1, 0), y].land == 5 && rnd < 3500) { landArray[x, y].land = 5; } else if (landArray[x, Check.Min(y - 1, 0)].land == 5 && rnd < 3500) { landArray[x, y].land = 5; } else if (landArray[x, Check.Min(y - 1, 0)].land == 5 && landArray[Check.Min(x - 1, 0), y].land == 5 && rnd < 9600) { landArray[x, y].land = 5; } } } MainMenuOpen = false; Show.CursorOutline = true; LogicClock40.Start(); LogicClock100.Start(); LogicClock250.Start(); LogicClock500.Start(); LogicClock1000.Start(); UpdateDestination.Start(); ///////////////////// // Generate Biomes // ///////////////////// for (int y = 0; y < 1000; y++) { for (int x = 0; x < 1000; x++) { if (landArray[x, y].biome == 0) { rnd = Random.Next(2, 4); landArray[x, y].biome = (int)rnd; Biome(x - 1, y - 1, (int)rnd, landArray); } if (landArray[x, y].land == -6) { landArray[x, y].land = 6; Land(x - 1, y - 1, 6, landArray); } } } ///////////////////////////////////// // Expanded Deserts || Default i < 50 // ///////////////////////////////////// for (int i = 0; i < 30; i++) { for (int y = 0; y < 1000; y++) { for (int x = 0; x < 1000; x++) { checkTile = landArray[x, y]; checkPosX = landArray[Check.Max(x + 1, 999), y]; checkPosY = landArray[x, Check.Max(y + 1, 999)]; checkNegX = landArray[Check.Min(x - 1, 0), y]; checkNegY = landArray[x, Check.Min(y - 1, 0)]; if (checkTile.biome != 3) { rnd = Random.Next(0, 1000); if (checkNegX.biome == 3) { rnd = rnd * 1.25; } if (checkNegY.biome == 3) { rnd = rnd * 1.25; } if (checkPosX.biome == 3) { rnd = rnd * 1.25; } if (checkPosY.biome == 3) { rnd = rnd * 1.25; } if (rnd > 1120) { landArray[x, y].biome = 3; } } } } } ///////////////////////////////////// // Expanded Snow || Default i < 50 // ///////////////////////////////////// for (int i = 0; i < 40; i++) { for (int y = 0; y < 1000; y++) { for (int x = 0; x < 1000; x++) { checkTile = landArray[x, y]; checkPosX = landArray[Check.Max(x + 1, 999), y]; checkPosY = landArray[x, Check.Max(y + 1, 999)]; checkNegX = landArray[Check.Min(x - 1, 0), y]; checkNegY = landArray[x, Check.Min(y - 1, 0)]; if (checkTile.biome != 2) { rnd = Random.Next(0, 1000); if (checkNegX.biome == 2) { rnd = rnd * 1.25; } if (checkNegY.biome == 2) { rnd = rnd * 1.25; } if (checkPosX.biome == 2) { rnd = rnd * 1.25; } if (checkPosY.biome == 2) { rnd = rnd * 1.25; } if (rnd > 1120) { landArray[x, y].biome = 2; } } } } } //////////////////////////////////// // Sparse Nodes || Default i < 5 // //////////////////////////////////// for (int i = 0; i < 5; i++) { for (int y = 0; y < 1000; y++) { for (int x = 0; x < 1000; x++) { checkTile = landArray[x, y]; checkPosX = landArray[Check.Max(x + 1, 999), y]; checkPosY = landArray[x, Check.Max(y + 1, 999)]; checkNegX = landArray[Check.Min(x - 1, 0), y]; checkNegY = landArray[x, Check.Min(y - 1, 0)]; if (landArray[x, y].biome != 3) { rnd = Random.Next(0, 1000); int node = 6; if (Random.Next(0, 6) == 5) { node = Random.Next(10, 19); } if (landArray[Check.Min(x - 1, 0), y].land == 6 && rnd > 650) { landArray[x, y].land = node; } if (landArray[x, Check.Min(y - 1, 0)].land == 6 && rnd > 650) { landArray[x, y].land = node; } if (landArray[Check.Max(x + 1, 999), y].land == 6 && rnd > 650) { landArray[x, y].land = node; } if (landArray[x, Check.Max(y + 1, 999)].land == 6 && rnd > 650) { landArray[x, y].land = node; } } if (checkTile.land != 5 && checkTile.land != 2) { rnd = Random.Next(0, 1000); if (checkNegX.land == 5) { rnd = rnd * 1.5; } if (checkNegY.land == 5) { rnd = rnd * 1.5; } if (checkPosX.land == 5) { rnd = rnd * 1.5; } if (checkPosY.land == 5) { rnd = rnd * 1.5; } if (rnd > 1050) { checkTile.land = 5; } } } } } Edges(); Player.WorldItems.Add(new GPS(50, 50, 0), 0); }