RoomContainer DeterminantSpecificRoom(List <RoomContainer> ignoreParent, List <MapWay> roomWay, string roomName) { Vector2Int specificMapAdditionalDirection = RoomManager.WayDirectionSet[RoomManager.WayInverseSet[roomWay[0]]]; Vector2Int specificMapIncludeAxisOutLine = specificMapAdditionalDirection; specificMapIncludeAxisOutLine.x *= specificMapIncludeAxisOutLine.x > 0 ? mapIndexMax.x : -(mapIndexMin.x); specificMapIncludeAxisOutLine.y *= specificMapIncludeAxisOutLine.y > 0 ? mapIndexMax.y : -(mapIndexMin.y); List <RoomContainer> outLineRooms = madeRooms.Where((r) => (specificMapIncludeAxisOutLine.x != 0 && specificMapIncludeAxisOutLine.x == r.RoomIndex.x) || (specificMapIncludeAxisOutLine.y != 0 && specificMapIncludeAxisOutLine.y == r.RoomIndex.y)). Except(ignoreParent).ToList(); RoomContainer specificParentRoom = outLineRooms[Random.Range(0, outLineRooms.Count)]; MapWay ToBossWay = RoomManager.WayDirectionSet.First((p) => p.Value == specificMapAdditionalDirection).Key; specificParentRoom.Way.Add(ToBossWay); RoomContainer specificRoom = new RoomContainer(specificParentRoom.RoomIndex + specificMapAdditionalDirection, roomWay); madeRooms.Add(specificRoom); SetMapInstance(specificRoom, roomName); return(specificRoom); }
public static void ChangeRoom(MapWay way) { RoomContainer rc = Instance.AllRoom.Find((r) => r.RoomIndex == Instance.CurrentRoom.RoomIndex + WayDirectionSet[way]); if (rc != null) { Instance.ChangeRoom(rc.RoomInstance); } }
public bool GetWayDestinationIndex(MapWay way, out Vector2Int index) { if (Way.Contains(way)) { index = RoomIndex + RoomManager.WayDirectionSet[way]; return true; } index = Vector2Int.zero; return false; }
// Start is called before the first frame update void Start() { List <RoomContainer> rooms = RoomManager.Instance.AllRoom; foreach (var room in rooms) { GameObject go = new GameObject(room.RoomIndex.ToString()); go.transform.parent = transform; go.transform.localScale = Vector3.one; go.transform.localPosition = new Vector3(room.RoomIndex.x * 54f, room.RoomIndex.y * 54f, 0f); go.AddComponent <Image>().sprite = roomS; (go.transform as RectTransform).sizeDelta = Vector2.one * 36f; for (int i = 0; i < 4; ++i) { MapWay way = (MapWay)(1 << i); if (room.Way.Contains(way)) { Vector2Int dir = RoomManager.WayDirectionSet[way]; GameObject bridge = new GameObject(room.RoomIndex.ToString() + "_" + (room.RoomIndex + RoomManager.WayDirectionSet[way]).ToString()); bridge.transform.localScale = Vector3.one; bridge.transform.parent = transform; bridge.transform.localPosition = go.transform.localPosition + new Vector3(dir.x * 27f, dir.y * 27f, 0f); bridge.AddComponent <Image>().sprite = i % 2 == 1 ? hS : vS; (bridge.transform as RectTransform).sizeDelta = i % 2 == 1 ? new Vector2(8f, 18f) : new Vector2(18f, 8f); } } } GameObject cr = new GameObject(RoomManager.Instance.CurrentRoom.RoomIndex.ToString()); cr.transform.parent = transform; cr.transform.localScale = Vector3.one; cr.transform.localPosition = new Vector3(RoomManager.Instance.CurrentRoom.RoomIndex.x * 54f, RoomManager.Instance.CurrentRoom.RoomIndex.y * 54f, 0f); CurrentRoomImg = cr.AddComponent <Image>(); CurrentRoomImg.sprite = currentRoomS; (cr.transform as RectTransform).sizeDelta = Vector2.one * 36f; }
void TransitionRoomFactoryProccess(RoomContainer current) { int randomConnectionCount = CalculateTransitionRoomWayCount(current.Way.Count); List <MapWay> otherList = RoomManager.WayList.Except(current.Way).ToList(); for (int i = 0; i < randomConnectionCount; ++i) { int index = Random.Range(0, otherList.Count); MapWay currentWay = otherList[index]; if (ConnectNearRoom(current, currentWay)) { current.Way.Add(otherList[index]); } otherList.RemoveAt(index); } madeRooms.Add(current); }
bool ConnectNearRoom(RoomContainer current, MapWay currentWay) { Vector2Int wayDirIndex = current.RoomIndex + RoomManager.WayDirectionSet[currentWay]; RoomContainer container = madeRooms.Find((r) => r.RoomIndex == wayDirIndex); if (container == null) { container = roomFactoryProccess.Find((r) => r.RoomIndex == wayDirIndex); if (container == null) { roomFactoryProccess.Add(new RoomContainer(wayDirIndex, new List <MapWay>() { RoomManager.WayInverseSet[currentWay] })); mapIndexMin.x = Mathf.Min(mapIndexMin.x, wayDirIndex.x); mapIndexMin.y = Mathf.Min(mapIndexMin.y, wayDirIndex.y); mapIndexMax.x = Mathf.Max(mapIndexMax.x, wayDirIndex.x); mapIndexMax.y = Mathf.Max(mapIndexMax.y, wayDirIndex.y); } else { container.Way.Add(RoomManager.WayInverseSet[currentWay]); } return(true); } else if (container.Way.Contains(RoomManager.WayInverseSet[currentWay])) { return(true); } return(false); }