using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.Tilemaps; [CreateAssetMenu(menuName = "Gather And Defend/Resource Tile")] public class ResourceTile : TileBase, ILevelObject { [SerializeField] [Tooltip("the prefab of the currency that will be spawned when mining this resource")] private GameObject _yieldPrefab; [SerializeField] private Sprite _sprite; public Vector3 Position { get; private set; } public Sprite Sprite { get => _sprite; set => _sprite = value; } public override bool StartUp(Vector3Int position, ITilemap tilemap, GameObject go) { if (!Application.isPlaying) return base.StartUp(position, tilemap, go); //need to create an instance of the tile, otherwise the position will change for all tiles instead of only this one. var instance = Instantiate(this); instance.Position = position; LevelManager.Instance.Add(instance); return base.StartUp(position, tilemap, go); } public override void GetTileData(Vector3Int position, ITilemap tilemap, ref TileData tileData) { tileData.sprite = _sprite; tileData.transform.SetTRS(Vector3.zero, Quaternion.identity, Vector3.one); tileData.color = Color.white; } }