public int AddDoor(DoorController cont, out DoorController.DoorType newOrientation) { newOrientation = cont.DoorLocation; if (newOrientation == DoorController.DoorType.East || newOrientation == DoorController.DoorType.West) { if (cont.gameObject.transform.position.x - transform.position.x > 0) { newOrientation = DoorController.DoorType.East; } else { newOrientation = DoorController.DoorType.West; } } else if (newOrientation == DoorController.DoorType.North || newOrientation == DoorController.DoorType.South) { if (cont.gameObject.transform.position.x - transform.position.x > 0) { newOrientation = DoorController.DoorType.South; } else { newOrientation = DoorController.DoorType.North; } } currentDoors.Add(cont); return(currentDoors.Count); }
private void SetDoor(MapTilemaps tilemaps, int x1, int y1, int x2, int y2, Vector3Int pos, DoorController.DoorType type) { tilemaps.WallTilemap.SetTile(pos, null); tilemaps.ShadowTilemap.SetTile(pos, null); PlaceDoor(tilemaps, type, pos, x1, y1, x2, y2); }
private bool openDoorInDirection(DoorController.DoorType dir) { foreach (DoorController d in currentDoors) { if (d.DoorLocation == dir) { if (doorOpenandPull(d)) { return(true); } } } return(false); }
private DoorController.DoorType getDoorType(bool hasDoorInDir) { DoorController.DoorType door = DoorController.DoorType.door; if (currentRoom.category != RoomObject.RoomCategory.Nothing && currentRoom.category != RoomObject.RoomCategory.Start && currentRoom.category != RoomObject.RoomCategory.End && currentRoom.category != RoomObject.RoomCategory.DeadEnd) { door = DoorController.DoorType.puzzle; } return(hasDoorInDir ? door : DoorController.DoorType.wall); }
private void PlaceDoor(MapTilemaps tilemaps, DoorController.DoorType doorType, Vector3Int pos, int x1, int y1, int x2, int y2) { if (HasDoor(x1, y1, x2, y2)) { return; } //tilemaps.FloorTilemap.SetTile(pos, _mapSettingsData.GetDoorTile()); // var doorGo = new GameObject($"HorizontalDoor[{GetDoorID(x1, y1, x2, y2)}]"); // doorGo.transform.SetParent(_mapHolder); // doorGo.transform.localPosition = pos + Vector3.one * 0.5f; // var door = doorGo.AddComponent<DoorController>(); // var doorTrigger = doorGo.AddComponent<BoxCollider2D>(); // doorTrigger.isTrigger = true; //var doorGO = tilemaps.FloorTilemap.GetInstantiatedObject(pos); var doorGO = Object.Instantiate(tilemaps.DoorPrefab, _mapHolder); doorGO.name = $"HorizontalDoor[{GetDoorID(x1, y1, x2, y2)}]"; doorGO.transform.localPosition = pos; if (doorGO == null) { Debug.Log(pos + " = DOOR GO IS NULL"); return; } var door = doorGO.GetComponent <DoorController>(); if (door == null) { Debug.Log("DOOR CONTROLLER IS NULL"); return; } var firstRoomController = _roomControllersMatrix[x1, y1]; var secondRoomController = _roomControllersMatrix[x2, y2]; door.Initialize(doorType, firstRoomController, secondRoomController); door.Toggle(true); firstRoomController.FloorTiles.Add(pos); secondRoomController.FloorTiles.Add(pos); _doorsIDs.Add(GetDoorID(x1, y1, x2, y2), true); }