private void GenerateRoom() { this.floorNodes = new List <FloorNode>(); var roomCount = this.config.roomGenerateCountRange.GetRandom(); var roomSize = this.config.roomGenerateSizeRange; for (var i = 0; i < roomCount; i++) { var position = GetRandomPointInCircle(this.config.dungeonRadius); var rect = new Rect(position.x, position.y, roomSize.GetRandom(), roomSize.GetRandom()); var roomNode = new FloorNode(i, rect); this.floorNodes.Add(roomNode); } }
//public EdgeNode(int id , Rect rect) //{ // this.id = id; // this.rect = rect; // this.children = new List<EdgeNode>(); //} //public void AddChildren(EdgeNode child) //{ // this.children.Add(child); //} public EdgeNode(FloorNode a, FloorNode b) { if (a == b) { throw new DuplicateFloorNodeException(a, b); } else if (a < b) { this.a = a; this.b = b; } else { this.a = b; this.b = a; } }
private bool CheckDistanceWithAllMainRooms(FloorNode node) { var isFar = true; for (var j = 0; j < this.floorNodes.Count; j++) { var room = this.floorNodes[j]; if (room.id != node.id && room.isMain) { if (Vector3.Distance(room.rect.center, node.rect.center) < this.config.distanceBetweenMainRoom) { isFar = false; break; } } } return(isFar); }
public DuplicateFloorNodeException(FloorNode a, FloorNode b) : base() { this.a = a; this.b = b; }