public static void PositionRails(AnvilWorld worldDest, BlockManager bm) { // todo low: different elevations int intReplaced = 0; for (int x = 0; x < City.mapLength; x++) { for (int z = -City.farmLength; z < City.mapLength; z++) { for (int y = 0; y < 128; y++) { switch (bm.GetID(x, y, z)) { case BlockType.POWERED_RAIL: case BlockType.DETECTOR_RAIL: case BlockType.RAILS: BlockHelper.MakeRail(x, y, z); if (++intReplaced > 100) { worldDest.Save(); intReplaced = 0; } break; } } } } }
public static void PositionRails(BetaWorld worldDest, BlockManager bm, int intCitySize) { int intReplaced = 0; for (int x = 0; x < intCitySize; x++) { for (int z = 0; z < intCitySize; z++) { for (int y = 0; y < 128; y++) { if (bm.GetID(x, y, z) == BlockType.RAILS) { BlockHelper.MakeRail(x, y, z); if (++intReplaced > 100) { worldDest.Save(); intReplaced = 0; } } } } } }
public static void PositionRails(BetaWorld worldDest, BlockManager bm) { int intReplaced = 0; for (int x = 0; x < City.MapLength; x++) { for (int z = 0; z < City.MapLength; z++) { for (int y = 0; y < 128; y++) { if (bm.GetID(x, y, z) == BlockInfo.Rails.ID) { BlockHelper.MakeRail(x, y, z); if (++intReplaced > 100) { worldDest.Save(); intReplaced = 0; } } } } } }
private static void MakeLevel(BetaWorld world, BlockManager bm, int intDepth, int intMineshaftSize) { strResourceNames = ValueFromXMLElement(Path.Combine("Resources", "MineshaftChests.xml"), "level" + intDepth, "names").Split(','); intResourceChances = StringArrayToIntArray( ValueFromXMLElement(Path.Combine("Resources", "MineshaftChests.xml"), "level" + intDepth, "chances").Split(',')); int intTorchChance = Convert.ToInt32(ValueFromXMLElement(Path.Combine("Resources", "MineshaftChests.xml"), "level" + intDepth, "torch_chance")); int[,] intMap = new int[intMineshaftSize, intMineshaftSize]; int intXPosOriginal = intMap.GetLength(0) / 2; int intZPosOriginal = intMap.GetLength(1) / 2; int[,] intArea = new int[intMap.GetLength(0) / MULTIPLIER, intMap.GetLength(1) / MULTIPLIER]; int intXPos = intXPosOriginal / MULTIPLIER; int intZPos = intZPosOriginal / MULTIPLIER; intArea[intXPos, intZPos] = 1; CreateRouteXPlus(intArea, intXPos + 1, intZPos, 0); CreateRouteZPlus(intArea, intXPos, intZPos + 1, 1); CreateRouteXMinus(intArea, intXPos - 1, intZPos, 2); CreateRouteZMinus(intArea, intXPos, intZPos - 1, 3); int intOffsetX = (intXPosOriginal - (intXPos * MULTIPLIER)) - 2; int intOffsetZ = (intZPosOriginal - (intZPos * MULTIPLIER)) - 2; int intGhostX = 0, intGhostZ = 0; bool booGhost = false; if (intDepth == 7) { for (int x = 1; x < intArea.GetLength(0) - 1 && !booGhost; x++) { for (int z = 1; z < intArea.GetLength(1) - 1 && !booGhost; z++) { if (intArea[x, z] == 1 && intArea[x + 1, z] == 0 && intArea[x - 1, z] == 0 && intArea[x, z + 1] == 0) { intArea[x, z] = 9; intGhostX = (x * MULTIPLIER) + intOffsetX; intGhostZ = (z * MULTIPLIER) + intOffsetZ; booGhost = true; } } } } for (int x = 4; x < intMap.GetLength(0) - 4; x++) { for (int z = 4; z < intMap.GetLength(1) - 4; z++) { if (intArea.GetLength(0) > x / MULTIPLIER && intArea.GetLength(1) > z / MULTIPLIER) { if (intMap[x + intOffsetX, z + intOffsetZ] < 4) { intMap[x + intOffsetX, z + intOffsetZ] = intArea[x / MULTIPLIER, z / MULTIPLIER]; } } if ((x + 3) % 5 == 0 && (z + 3) % 5 == 0 && intArea[x / MULTIPLIER, z / MULTIPLIER] == 1) { if (intArea[(x / MULTIPLIER) + 1, z / MULTIPLIER] == 1) { for (int x2 = 0; x2 < 5; x2++) { if (x2 == 1 || x2 == 3) { intMap[x + intOffsetX + 3, z + intOffsetZ + x2 - 2] = 8; intMap[x + intOffsetX + 2, z + intOffsetZ + x2 - 2] = 8; } else { intMap[x + intOffsetX + 3, z + intOffsetZ + x2 - 2] = 5; intMap[x + intOffsetX + 2, z + intOffsetZ + x2 - 2] = 5; } } for (int x2 = 0; x2 <= 5; x2++) { if (intMap[x + intOffsetX + x2, z + intOffsetZ] == 5) { intMap[x + intOffsetX + x2, z + intOffsetZ] = 4; } else { intMap[x + intOffsetX + x2, z + intOffsetZ] = 7; } } } if (intArea[x / MULTIPLIER, (z / MULTIPLIER) + 1] == 1) { for (int z2 = 0; z2 < 5; z2++) { if (z2 == 1 || z2 == 3) { intMap[x + intOffsetX + z2 - 2, z + intOffsetZ + 3] = 8; intMap[x + intOffsetX + z2 - 2, z + intOffsetZ + 2] = 8; } else { intMap[x + intOffsetX + z2 - 2, z + intOffsetZ + 3] = 5; intMap[x + intOffsetX + z2 - 2, z + intOffsetZ + 2] = 5; } } for (int z2 = 0; z2 <= 5; z2++) { if (intMap[x + intOffsetX, z + intOffsetZ + z2] == 5) { intMap[x + intOffsetX, z + intOffsetZ + z2] = 4; } else { intMap[x + intOffsetX, z + intOffsetZ + z2] = 7; } } } if (intArea[x / MULTIPLIER, z / MULTIPLIER] == 1) { MakeChestAndOrTorch(intArea, intMap, (x - 3) / MULTIPLIER, z / MULTIPLIER, x + intOffsetX - 2, z + intOffsetZ); MakeChestAndOrTorch(intArea, intMap, (x + 3) / MULTIPLIER, z / MULTIPLIER, x + intOffsetX + 2, z + intOffsetZ); MakeChestAndOrTorch(intArea, intMap, x / MULTIPLIER, (z - 3) / MULTIPLIER, x + intOffsetX, z + intOffsetZ - 2); MakeChestAndOrTorch(intArea, intMap, x / MULTIPLIER, (z + 3) / MULTIPLIER, x + intOffsetX, z + intOffsetZ + 2); } } } } intMap[intXPosOriginal, intZPosOriginal] = 3; int intSupportMaterial = RandomHelper.RandomNumber((int)BlockType.WOOD, (int)BlockType.WOOD_PLANK, (int)BlockType.FENCE); intSupportMaterial = (int)BlockType.WOOD_PLANK; for (int x = 0; x < intMap.GetLength(0); x++) { for (int z = 0; z < intMap.GetLength(1); z++) { switch (intMap[x, z]) { case 0: break; case 1: for (int y = 39 - (5 * intDepth); y <= 41 - (5 * intDepth); y++) { bm.SetID(x + intBlockStart, y, z + intBlockStart, (int)BlockType.AIR); } break; case 9: for (int y = 39 - (5 * intDepth); y <= 41 - (5 * (intDepth - 1)); y++) { bm.SetID(x + intBlockStart, y, z + intBlockStart, (int)BlockType.AIR); } break; case 2: break; case 4: for (int y = 38 - (5 * intDepth); y <= 41 - (5 * intDepth); y++) { if (y == 38 - (5 * intDepth)) { bm.SetID(x + intBlockStart, y, z + intBlockStart, (int)BlockType.GRAVEL); } else if (y == 39 - (5 * intDepth)) { bm.SetID(x + intBlockStart, y, z + intBlockStart, (int)BlockType.RAILS); } else if (y == 40 - (5 * intDepth)) { bm.SetID(x + intBlockStart, y, z + intBlockStart, (int)BlockType.AIR); } else { bm.SetID(x + intBlockStart, y, z + intBlockStart, intSupportMaterial); } } break; case 5: for (int y = 39 - (5 * intDepth); y <= 41 - (5 * intDepth); y++) { bm.SetID(x + intBlockStart, y, z + intBlockStart, intSupportMaterial); } break; case 6: for (int y = 39 - (5 * intDepth); y <= 41 - (5 * intDepth); y++) { if (y == 39 - (5 * intDepth) && RandomHelper.NextDouble() > 0.9) { bm.SetID(x + intBlockStart, y, z + intBlockStart, (int)BlockType.CHEST); MakeChestItems(bm, x + intBlockStart, y, z + intBlockStart); } else if (y == 41 - (5 * intDepth) && RandomHelper.NextDouble() < (double)intTorchChance / 100) { bm.SetID(x + intBlockStart, y, z + intBlockStart, (int)BlockType.TORCH); if (intMap[x - 1, z] == 0) { bm.SetData(x + intBlockStart, y, z + intBlockStart, 1); } else if (intMap[x + 1, z] == 0) { bm.SetData(x + intBlockStart, y, z + intBlockStart, 2); } else if (intMap[x, z - 1] == 0) { bm.SetData(x + intBlockStart, y, z + intBlockStart, 3); } else { bm.SetData(x + intBlockStart, y, z + intBlockStart, 4); } } else { bm.SetID(x + intBlockStart, y, z + intBlockStart, (int)BlockType.AIR); } } break; case 7: case 3: for (int y = 38 - (5 * intDepth); y <= 41 - (5 * intDepth); y++) { if (y == 38 - (5 * intDepth)) { bm.SetID(x + intBlockStart, y, z + intBlockStart, (int)BlockType.GRAVEL); } else if (y == 39 - (5 * intDepth)) { bm.SetID(x + intBlockStart, y, z + intBlockStart, (int)BlockType.RAILS); } else { bm.SetID(x + intBlockStart, y, z + intBlockStart, (int)BlockType.AIR); } } break; case 8: for (int y = 39 - (5 * intDepth); y <= 41 - (5 * intDepth); y++) { if (y == 41 - (5 * intDepth)) { bm.SetID(x + intBlockStart, y, z + intBlockStart, intSupportMaterial); } else { bm.SetID(x + intBlockStart, y, z + intBlockStart, (int)BlockType.AIR); } } break; } } } for (int x = 0; x < intMap.GetLength(0); x++) { for (int z = 0; z < intMap.GetLength(1); z++) { switch (intMap[x, z]) { case 3: case 4: case 7: BlockHelper.MakeRail(x + intBlockStart, 39 - (5 * intDepth), z + intBlockStart); break; } } } if (booGhost) { BlockShapes.MakeSolidBox(intBlockStart + intGhostX - 1, intBlockStart + intGhostX + 5, 39 - (5 * intDepth), 46 - (5 * intDepth), intBlockStart + intGhostZ - 1, intBlockStart + intGhostZ + 5, (int)BlockType.AIR, 0); for (int x = intBlockStart + intGhostX; x <= intBlockStart + intGhostX + 4; x++) { for (int y = 39 - (5 * intDepth); y <= 44 - (5 * intDepth); y++) { for (int z = intBlockStart + intGhostZ + 3; z <= intBlockStart + intGhostZ + 4; z++) { bm.SetID(x, y, z, (int)BlockType.WOOL); bm.SetData(x, y, z, (int)WoolColor.WHITE); } } } bm.SetID(intBlockStart + intGhostX + 0, 44 - (5 * intDepth), intBlockStart + intGhostZ + 3, (int)BlockType.TORCH); bm.SetID(intBlockStart + intGhostX + 0, 44 - (5 * intDepth), intBlockStart + intGhostZ + 4, (int)BlockType.TORCH); bm.SetID(intBlockStart + intGhostX + 4, 44 - (5 * intDepth), intBlockStart + intGhostZ + 3, (int)BlockType.TORCH); bm.SetID(intBlockStart + intGhostX + 4, 44 - (5 * intDepth), intBlockStart + intGhostZ + 4, (int)BlockType.TORCH); bm.SetData(intBlockStart + intGhostX + 0, 44 - (5 * intDepth), intBlockStart + intGhostZ + 3, (int)TorchOrientation.FLOOR); bm.SetData(intBlockStart + intGhostX + 0, 44 - (5 * intDepth), intBlockStart + intGhostZ + 4, (int)TorchOrientation.FLOOR); bm.SetData(intBlockStart + intGhostX + 4, 44 - (5 * intDepth), intBlockStart + intGhostZ + 3, (int)TorchOrientation.FLOOR); bm.SetData(intBlockStart + intGhostX + 4, 44 - (5 * intDepth), intBlockStart + intGhostZ + 4, (int)TorchOrientation.FLOOR); bm.SetID(intBlockStart + intGhostX + 1, 43 - (5 * intDepth), intBlockStart + intGhostZ + 3, (int)BlockType.OBSIDIAN); bm.SetID(intBlockStart + intGhostX + 3, 43 - (5 * intDepth), intBlockStart + intGhostZ + 3, (int)BlockType.OBSIDIAN); bm.SetID(intBlockStart + intGhostX + 1, 39 - (5 * intDepth), intBlockStart + intGhostZ + 2, (int)BlockType.TORCH); bm.SetData(intBlockStart + intGhostX + 1, 39 - (5 * intDepth), intBlockStart + intGhostZ + 2, (int)TorchOrientation.FLOOR); bm.SetID(intBlockStart + intGhostX + 2, 39 - (5 * intDepth), intBlockStart + intGhostZ + 2, (int)BlockType.SIGN_POST); bm.SetData(intBlockStart + intGhostX + 2, 39 - (5 * intDepth), intBlockStart + intGhostZ + 2, (int)SignPostOrientation.EAST); BlockHelper.MakeSignPost(intBlockStart + intGhostX + 2, 39 - (5 * intDepth), intBlockStart + intGhostZ + 2, "Ghostdancer:|Victim of the|Creeper Rush|of '09"); bm.SetID(intBlockStart + intGhostX + 3, 39 - (5 * intDepth), intBlockStart + intGhostZ + 2, (int)BlockType.TORCH); bm.SetData(intBlockStart + intGhostX + 3, 39 - (5 * intDepth), intBlockStart + intGhostZ + 2, (int)TorchOrientation.FLOOR); } world.Save(); //File.WriteAllText("c:\\output.txt", TwoDimensionalArrayToString(intMap)); }