ScriptableObjects are used to store color set data and the general tileset information, for the moment, saved onto the prefab
36 lines
943 B
C#
36 lines
943 B
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
|
|
[CreateAssetMenu(fileName = "TileSetInfo", menuName = "Gameplay/TileSetInfo", order = 1)]
|
|
public class TileSetInfo : ScriptableObject {
|
|
[Header("Per-color settings / setup")]
|
|
public TileObject[] Tiles;
|
|
|
|
Dictionary<TileColor, TileObject> _TileLookup;
|
|
void BuildLookup() {
|
|
_TileLookup = new Dictionary<TileColor, TileObject>();
|
|
foreach (var tile in Tiles)
|
|
_TileLookup.Add(tile.color, tile);
|
|
}
|
|
|
|
public TileObject this[TileColor tc] {
|
|
get {
|
|
if (_TileLookup == null) BuildLookup();
|
|
|
|
bool exists = _TileLookup.TryGetValue(tc, out TileObject to);
|
|
if (exists) return to;
|
|
|
|
return null; // return null if we don't got anything
|
|
}
|
|
}
|
|
|
|
[Header("Layered")]
|
|
public Sprite IceOverlay;
|
|
public Sprite FairyUnderlay, Tanuki;
|
|
|
|
[Header("Special tile sprites")]
|
|
public Sprite Rock;
|
|
public Sprite Seal, Bomb, Dynamite, Mystery, Spark, Explosion;
|
|
}
|