public void PassConnectedZone2() { Zone originalZone = new Zone(); Zone connectedZone = new Zone(); originalZone.AddConnectionPoint(new int2(0, 0), connectedZone); originalZone.AddConnectionPoint(new int2(7, 13), connectedZone); Zone passedZone = PassValueToScript(originalZone); Assert.IsTrue(passedZone.connections[new int2(0, 0)] != null && passedZone.connections[new int2(0, 0)].id == connectedZone.id); Assert.IsTrue(passedZone.connections[new int2(7, 13)] != null && passedZone.connections[new int2(7, 13)].id == connectedZone.id); }
public void LayoutZone_AddConnectionPoint() { Zone layout = new Zone(); layout.bounds = new RectangleInt(0, 0, 3, 3); Zone layout1 = new Zone(); layout1.bounds = new RectangleInt(0, 3, 3, 3); layout.AddConnectionPoint(new int2(0, 2), layout1); Assert.True(layout.connections.Count == 1); }
public override TileMap <TileType> PreConnectZones(TileMap <TileType> map, int level) { SetLevelSettings(level); List <Zone> zonesToConnect = new List <Zone>(); if (map.Layout.Zones.Count > 0) { zonesToConnect.Add(map.Layout.InitialZone); while (zonesToConnect.Count > 0) { Zone zone = zonesToConnect[0]; zonesToConnect.Remove(zone); NodeList <Zone> neighbors = map.Layout.GetAdjacentZones(zone); if (neighbors != null) { Zone neighbor; for (int i = 0; i < neighbors.Count; i++) { neighbor = neighbors[i].Value; if (!zone.connections.ContainsValue(neighbor)) { int2 connectionPoint; List <int2> connectionCandidates = zone.bounds.ContactArea(neighbor.bounds, true); connectionPoint = connectionCandidates[Random.Range(0, connectionCandidates.Count - 1)]; zone.AddConnectionPoint(connectionPoint, neighbor); int2 contactPoint; if (neighbor.ContactPoint(connectionPoint, out contactPoint)) { neighbor.AddConnectionPoint(contactPoint, zone); zonesToConnect.Add(neighbor); } } } } } } return(map); }
private static void AddZoneConnections(Table zoneTable, Zone zone) { DynValue connections = zoneTable.Get(DynValue.NewString("connections")); Table connectionsTable = connections.Table; foreach (var pair in connectionsTable.Pairs) { int zoneId = (int)pair.Key.Number; Table pointsTable = pair.Value.Table; foreach (var point in pointsTable.Values) { zone.AddConnectionPoint(point.ToObject <int2>(), new Zone(zoneId)); } } }