private void generateLakeHouse(int HouseID) { int Radius = 32; int PX = (int)CenterPosition.X; int PY = (int)CenterPosition.Y; for (int countX = -Radius; countX <= Radius; countX += 2) { for (int countY = -Radius; countY <= Radius; countY += 2) { if (MapUtil.HasSurrounding(PX + countX, PY + countY, IslandMap.lk, 8) && !IslandMap.lk[PX + countX, PY + countY] && !MapUtil.HasSurrounding(PX + countX, PY + countY, IslandMap.m, 1)) { Point LakePoint = MapUtil.getClosest(PX + countX, PY + countY, IslandMap.lk, Radius); int angle = MapUtil.GetDirectionAngle(PX + countX, PY + countY, IslandMap.lk) + 90; if (angle >= 0) { Point3D Dimensions = VoxelModels.VoxelModels.ModelDimensionLibrary["House_" + HouseID + "_Dimensions"]; //Debug.WriteLine(Dimensions); Structure Structure = new Structure(new Point3D(PX + countX, IslandMap.h[PX + countX, PY + countY], PY + countY), angle, (int)Dimensions.X, (int)Dimensions.Y, (int)Dimensions.Z); Boolean HasNearbyBuilding = MapUtil.HasStructureSurroundingStructure(Structure, this, 3); if (!HasNearbyBuilding) { Boolean HasLake = MapUtil.HasStructureSurrounding(Structure, IslandMap.lk, 6); if (!HasLake) { //add system for random houses IslandMap.StructureNames.Add("House_" + HouseID + "_"); //IslandMap.StructurePoints.Add(new Point3D(PX + countX, IslandMap.h[PX + countX, PY + countY], PX + countX)); IslandMap.StructurePoints.Add(new Point3D(PX + countX, IslandMap.h[PX + countX, PY + countY], PY + countY)); //IslandMap.StructurePoints.Add(new Point3D(512, 2, 512)); //IslandMap.StructureRotations.Add(new Vector3D(dir.X, 1, dir.Y)); IslandMap.StructureRotations.Add(angle); StructureList.Add(Structure); //Debug.WriteLine("House added"); return; } } } } } } }
public static void Start(string mapfile) { Renderer.Initialize(); PlayerPosition = new Point(0, 0); Health = 100; Inventory = new Dictionary <int, Item>(); HandSlots = new int[5]; MapUtil.Load(mapfile); HandCraftingRecipes = new Recipe[] { new Recipe(new[] { new Item(4, '▓') }, new Item(1, '◰')), new Recipe(new[] { new Item(8, '█') }, new Item(1, '◘')) }; CraftingRecipes = new Recipe[] { new Recipe(new[] { new Item(4, '▓') }, new Item(1, '◰')), new Recipe(new[] { new Item(8, '█') }, new Item(1, '◘')), new Recipe(new[] { new Item(8, '▓') }, new Item(1, '⊠')), new Recipe(new[] { new Item(2, '▓') }, new Item(2, '|')), new Recipe(new[] { new Item(2, '|'), new Item(3, '▓') }, new Item(1, '┬')), new Recipe(new[] { new Item(2, '|'), new Item(3, '█') }, new Item(1, '┯')), new Recipe(new[] { new Item(2, '|'), new Item(3, '▃') }, new Item(1, '╤')), new Recipe(new[] { new Item(2, '|'), new Item(2, '█') }, new Item(1, '┍')), new Recipe(new[] { new Item(2, '|'), new Item(2, '▃') }, new Item(1, '╒')), new Recipe(new[] { new Item(1, '|'), new Item(2, '▃') }, new Item(1, '╀')), new Recipe(new[] { new Item(1, '|'), new Item(2, '◆') }, new Item(1, '╬')), new Recipe(new[] { new Item(2, '|'), new Item(4, '§') }, new Item(1, 'D')), new Recipe(new[] { new Item(1, '|'), new Item(1, '▃') }, new Item(4, '↟')), new Recipe(new[] { new Item(2, 'Y') }, new Item(1, '§')), new Recipe(new[] { new Item(10, '‖') }, new Item(1, '§')), new Recipe(new[] { new Item(2, '§') }, new Item(1, '▦')), new Recipe(new[] { new Item(4, '▦') }, new Item(1, '⊑')), }; FurnaceRecipes = new Recipe[] { new Recipe(new[] { new Item(1, '▓') }, new Item(1, '⊚')), new Recipe(new[] { new Item(1, '⊡'), new Item(1, '⊚') }, new Item(1, '▃')), new Recipe(new[] { new Item(1, 'q'), new Item(1, '⊚') }, new Item(1, 'Q')), }; Renderer.MapSection = new Point(PlayerPosition.X, PlayerPosition.Y); Renderer.PlayerScreenPosition = new Point(0, 0); WorldName = mapfile; Running = true; Renderer.RenderMap(); Renderer.DrawPlayer(); DrawInventorySlots(); DrawHealth(); while (Running) { Cycle(); } }
public void createBridge() { Point DeltaPosition = IslandMap.GetDeltaPoint(CenterPosition); Vector dir = new Vector(DeltaPosition.X - CenterPosition.X, DeltaPosition.Y - CenterPosition.Y); dir.Normalize(); int distance = (int)MathUtil.MathUtil.distance(CenterPosition, DeltaPosition); dir.Normalize(); int allowedDistance = (int)(distance * 0.25f); for (int i = 1; i < distance; i++) { float wavePosX = (float)(dir.X * i + dir.X * Math.Sin(Math.PI * i / distance) * 10); float wavePosY = (float)(dir.Y * i + dir.Y * Math.Sin(Math.PI * i / distance) / 10); int px = (int)(CenterPosition.X + wavePosX); int py = (int)(CenterPosition.Y + wavePosY); if (!IslandMap.lk[px, py] && IslandMap.r[px, py]) { if (i > allowedDistance) { Point BridgePosition = new Point(px - 5, py - 5); int angle = MapUtil.GetDirectionAngle(px, py, IslandMap.lk); //Debug.WriteLine(BridgePositionB); IslandMap.StructureNames.Add("Bridge_"); IslandMap.StructurePoints.Add(new Point3D(BridgePosition.X, IslandMap.h[px, py], BridgePosition.Y)); //IslandMap.StructureRotations.Add(new Vector3D(CrossDir.X, 1, CrossDir.Y)); //IslandMap.StructureRotations.Add(new Vector3D(dir.X, 1, dir.Y)); IslandMap.StructureRotations.Add(angle + 270); return; } } } }
public static void Menu() { Console.ForegroundColor = ConsoleColor.Yellow; Console.SetCursorPosition(3, 1); Console.Write("\u2554\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2557"); Console.SetCursorPosition(3, 2); Console.Write("\u2551 \u2551"); Console.SetCursorPosition(3, 3); Console.Write("\u2551 Game Paused \u2551"); Console.SetCursorPosition(3, 4); Console.Write("\u2551 \u2551"); Console.SetCursorPosition(3, 5); Console.Write("\u2551 \u2551"); Console.SetCursorPosition(3, 6); Console.Write("\u2551 Resume game \u2551"); Console.SetCursorPosition(3, 7); Console.Write("\u2551 Save game \u2551"); Console.SetCursorPosition(3, 8); Console.Write("\u2551 Exit \u2551"); Console.SetCursorPosition(3, 9); Console.Write("\u2551 \u2551"); Console.SetCursorPosition(3, 10); Console.Write("\u255A\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u255D"); int ci = 0; for (; ;) { Console.ForegroundColor = ConsoleColor.Yellow; for (int i = 0; i < 3; i++) { Console.SetCursorPosition(5, i + 6); Console.Write(" "); } Console.SetCursorPosition(5, ci + 6); Console.Write("\u00BB"); ConsoleKey k = Console.ReadKey(true).Key; if (k == ConsoleKey.DownArrow) { ci += 1; if (ci == 3) { ci = 0; } } else if (k == ConsoleKey.UpArrow) { ci -= 1; if (ci == -1) { ci = 2; } } else if (k == ConsoleKey.Enter) { if (ci == 0) { Renderer.RenderMap(); Renderer.DrawPlayer(); return; } else if (ci == 1) { MapUtil.Save(WorldName); Renderer.RenderMap(); Renderer.DrawPlayer(); return; } else if (ci == 2) { Running = false; return; } } else if (k == ConsoleKey.Escape) { Renderer.RenderMap(); Renderer.DrawPlayer(); return; } } }
static void SelectWorld() { Console.Clear(); string[] sf = MapUtil.GetSaves(); Console.SetWindowSize(66, sf.Length + 7); Console.SetBufferSize(66, sf.Length + 7); Console.SetCursorPosition(15, 1); Console.Write("\u2554\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2557"); Console.SetCursorPosition(15, 2); Console.Write("\u2551 Select world \u2551"); Console.SetCursorPosition(15, 3); Console.Write("\u2551 \u2551"); for (int i = 0; i < sf.Length; i++) { Console.SetCursorPosition(15, 4 + i); Console.Write("\u2551 \u2551"); Console.SetCursorPosition(19, 4 + i); if (sf[i] != "new") { Console.Write(sf[i]); } else { Console.Write("Create new world"); } } Console.SetCursorPosition(15, 4 + sf.Length); Console.Write("\u2551 \u2551"); Console.SetCursorPosition(15, 5 + sf.Length); Console.Write("\u255A\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u255D"); int ci = 0; for (; ;) { for (int i = 0; i < sf.Length; i++) { Console.SetCursorPosition(17, 4 + i); Console.Write(" "); } Console.SetCursorPosition(17, 4 + ci); Console.Write("\u00BB");; ConsoleKey ck = Console.ReadKey(true).Key; if (ck == ConsoleKey.DownArrow) { ci++; if (ci == sf.Length) { ci = 0; } } else if (ck == ConsoleKey.UpArrow) { ci--; if (ci == -1) { ci = sf.Length - 1; } } else if (ck == ConsoleKey.Enter) { if (sf[ci] != "new") { Game.Start(sf[ci]); } else { NewWorld(); } return; } else if (ck == ConsoleKey.Escape) { return; } } }