public static Button ToButton(this ButtonConfig button, IEnumerable <EntityVariant>?entityVariants, EntityVariant baseEntityVariant) { return(button switch { DefaultButtonConfig defaultButton => defaultButton.ToDefaultButton(entityVariants, baseEntityVariant), CustomButtonConfig customButton => customButton.ToCustomButton(), PaneButtonConfig paneButton => paneButton.ToPaneButton(baseEntityVariant), _ => throw new InvalidOperationException() });
public static string Node(string action, string collectionAlias, EntityVariant entityVariant, string?parentId, string?id) { return($"/node/{action}{parentId.ToUriPart()}/{collectionAlias}/entity/{entityVariant.Alias}{id.ToUriPart()}"); }
public static string Node(string action, string collectionAlias, EntityVariant entityVariant, ParentPath?parentPath, string?id) { var path = parentPath?.ToPathString(); return($"/{action}{path.ToUriPart()}/{collectionAlias}/entity/{entityVariant.Alias}{id.ToUriPart()}"); }
private void GenerateLevel(LevelModel[] levels) { TileCache = GenerateTileCache(levels.FirstOrDefault().floorLayer); VirtualEntityCache = GenerateEntityCache(levels.FirstOrDefault().entityLayer); if (MapRoot == null) { MapRoot = transform; } Debug.Log("Generating map and entities..."); TileCache.ForEach(tile => { // TODO: Initially add a type of decor for the asset to use on its decor slot. This will just instantiate over the top of the // wall (or floor). I was going to be cleverer about this but frankly for now it'll be fine as is. // Map editor will require a new update and type attached. TileVariant v = TileVariantMap.FirstOrDefault(x => x.scoreIndex == tile.score); if (v.prefab != null) { GameObject prefabType = tile.type == MAP_CELL_TYPE.BLOCKED ? v.prefab : v.floorPrefab; Vector3 ScaledPosition = new Vector3( tile.x, transform.position.y, tile.y ); var inst = Instantiate(prefabType, ScaledPosition, Quaternion.identity); inst.transform.SetParent(MapRoot); // For Debug inst.name = "TS: " + v.scoreIndex + " [x" + tile.x + "]:[y" + tile.y + "]"; } }); VirtualEntityCache.ForEach(entity => { EntityVariant v = EntityVariantMap.FirstOrDefault(x => x.type == entity.type); if (v != null && v.prefab != null) { Vector3 ScaledPosition = new Vector3( entity.x, // TODO: I don't understand why these must be flipped... research needed transform.position.y, // Temporary until I fix the prefabs entity.y ); // This provides a link between the actual prefab in the game world and how it's interpreted // when the player hits in within map data (such as passage checking). var inst = Instantiate(v.prefab, ScaledPosition, Quaternion.identity); inst.transform.SetParent(MapRoot); InstantiatedEntityCache.Add(inst); } }); if (OnMapGenerated != null) { OnMapGenerated(new MapResult() { StartPoint = VirtualEntityCache.FirstOrDefault(x => x.type == ENTITY_TYPE.START_POINT), EndPoint = VirtualEntityCache.FirstOrDefault(x => x.type == ENTITY_TYPE.END_POINT), InstanceCache = InstantiatedEntityCache }); } }