private void CreateDoors(Rectangle room) { int xMin = room.Left; int xMax = room.Right; int yMin = room.Top; int yMax = room.Bottom; List <Cell> borderCells = ItemsMap.GetCellsAlongLine(xMin, yMin, xMax, yMin).ToList(); borderCells.AddRange(ItemsMap.GetCellsAlongLine(xMin, yMin, xMin, yMax)); borderCells.AddRange(ItemsMap.GetCellsAlongLine(xMin, yMax, xMax, yMax)); borderCells.AddRange(ItemsMap.GetCellsAlongLine(xMax, yMin, xMax, yMax)); foreach (Cell cell in borderCells) { if (IsPotentialDoor(cell)) { GroundMap.SetCellProperties(cell.X, cell.Y, false, true); ItemsMap.SetCellProperties(cell.X, cell.Y, false, true); var door = new Item(); var instance = Instantiate <GameObject>(_door, new Vector2(cell.X, cell.Y), Quaternion.identity); door.Stat = "close"; door.go = instance; instance.transform.SetParent(itemsHolder); instance.GetComponent <Renderer>().enabled = false; ItemsTiles[cell.X, cell.Y] = door; Doors.Add(door); } } }
private void CreateVerticalTunnel(int yStart, int yEnd, int xPosition) { for (int y = Math.Min(yStart, yEnd); y <= Math.Max(yStart, yEnd); y++) { GroundMap.SetCellProperties(xPosition, y, true, true); ItemsMap.SetCellProperties(xPosition, y, true, true); } }
private void CreateHorizontalTunnel(int xStart, int xEnd, int yPosition) { for (int x = Math.Min(xStart, xEnd); x <= Math.Max(xStart, xEnd); x++) { GroundMap.SetCellProperties(x, yPosition, true, true); ItemsMap.SetCellProperties(x, yPosition, true, true); } }
void CreateRoom(Rectangle room) { for (int x = room.Left + 1; x < room.Right; x++) { for (int y = room.Top + 1; y < room.Bottom; y++) { GroundMap.SetCellProperties(x, y, true, true); ItemsMap.SetCellProperties(x, y, true, true); } } }
void OpenDoor(GameObject actor, int x, int y) { var door = GetDoor(x, y); if (door != null && door.Stat == "close") { Debug.Log("cat"); door.Stat = "open"; var ItemCell = ItemsMap.GetCell(x, y); var GroundCell = ItemsMap.GetCell(x, y); GroundMap.SetCellProperties(x, y, true, true, GroundCell.IsExplored); ItemsMap.SetCellProperties(x, y, true, true, ItemCell.IsExplored); door.go.GetComponent <Animator>().SetTrigger("Open"); } }
void UpdatePlayerFieldOfView() { GroundMap.ComputeFov((int)Player.transform.position.x, (int)Player.transform.position.y, 8, true); ItemsMap.ComputeFov((int)Player.transform.position.x, (int)Player.transform.position.y, 8, true); foreach (var cell in GroundMap.GetAllCells()) { if (GroundMap.IsInFov(cell.X, cell.Y)) { GroundMap.SetCellProperties(cell.X, cell.Y, cell.IsTransparent, cell.IsWalkable, true); } } foreach (var cell in ItemsMap.GetAllCells()) { if (ItemsMap.IsInFov(cell.X, cell.Y)) { ItemsMap.SetCellProperties(cell.X, cell.Y, cell.IsTransparent, cell.IsWalkable, true); } } }