/// <summary> /// Randomly attaches 2 tiles (random anchor/connector) within a given group, tile=previous tile already on board /// </summary> public void AttachTo(Tile tile, TileGroup tg) { //anchors = white outer transforms //connectors = red inner transforms Transform[] anchorPoints = tile.GetChildren("anchor"); int[] ra = GlowEngine.GenerateRandomNumbers(anchorPoints.Length); int[] rc = GlowEngine.GenerateRandomNumbers(connectorCount); bool success = false; for (int c = 0; c < connectorCount; c++) { for (int a = 0; a < anchorPoints.Length; a++) //white anchors on board { tile.SetAnchor(ra[a]); SetConnector(rc[c]); AttachTo(tile.currentAnchor); Transform[] ap = GetChildren("connector"); success = !tg.CheckCollisionsWithinGroup(ap); if (success) { break; } } if (success) { break; } } if (!success) { Debug.Log("FAILED TO FIND OPEN TILE LOCATION"); throw new System.Exception("FAILED TO FIND OPEN TILE LOCATION"); } }