public Tile(int x, int y, MapGenerator.TileType tileType) { X = x; Y = y; TileType = tileType; IsVisible = true; }
public override void OnInspectorGUI() { SerializedObject obj = new SerializedObject(targetSet); obj.Update(); EditorGUILayout.BeginVertical(); { Dictionary <MapGenerator.TileType, Sprite> dictCopy = new Dictionary <MapGenerator.TileType, Sprite>(targetSet.sprites); foreach (var v in dictCopy) { targetSet.sprites[v.Key] = (Sprite)EditorGUILayout.ObjectField(v.Key.ToString(), v.Value, typeof(Sprite), false); } } if (GUILayout.Button("Create keys")) { //loop through all valid types of TileTypes for (int i = 1; i < (int)MapGenerator.TileType.MAX; i++) { MapGenerator.TileType t = (MapGenerator.TileType)i; if (!targetSet.sprites.ContainsKey(t)) { targetSet.sprites.Add(t, null); } } } obj.Update(); EditorGUILayout.EndVertical(); }
public void AddTile(Sprite sprite, MapGenerator.TileType type) { GameObject go = new GameObject("Tile " + nextX + " : " + nextY); tiles[nextX, nextY] = go.AddComponent <Tile>(); tiles[nextX, nextY].SetType(type); SpriteRenderer sr = go.AddComponent <SpriteRenderer>(); sr.sprite = sprite; sr.sortingOrder = 0; go.transform.parent = transform; float posX = 2 - nextX; if (nextY % 2 == 1) { posX -= .5f; } float posY = (2 - nextY) * yPerPosition; go.transform.position = new Vector3(posX, posY, 0); NextTileStep(); }
public void SetType(MapGenerator.TileType type) { this.type = type; }