public static string PrintReadableWorldCell(WorldCellType worldCellType) { switch (worldCellType) { case WorldCellType.None: return("X"); case WorldCellType.Path: return("-"); case WorldCellType.Zone: return("O"); case WorldCellType.PlayerInitialPosition: return("P"); default: throw new ArgumentOutOfRangeException("worldCellType", worldCellType, null); } }
public void DrawSingleWorldUnit(WorldCellType worldCellType, int x, int y) { string worldCellTypeStr; switch (worldCellType) { case WorldCellType.None: worldCellTypeStr = "WorldNone"; break; case WorldCellType.Path: worldCellTypeStr = "WorldPath"; break; case WorldCellType.Zone: worldCellTypeStr = "WorldZone"; break; case WorldCellType.PlayerInitialPosition: // TODO handle player case. worldCellTypeStr = "WorldPath"; break; default: throw new ArgumentOutOfRangeException("worldCellType", worldCellType, null); } GameObject prefab = worldTiles.Where(tile => tile.name == worldCellTypeStr).SingleOrDefault(); if (prefab == null) { throw new ArgumentNullException("prefab"); } Vector3 pos = new Vector3(x, y, 0); // TODO review z-axis value. var newObject = Instantiate(prefab, pos, Quaternion.identity); // TODO add string to constants. newObject.transform.parent = GameObject.Find("Cells").transform; }