38 lines
1.2 KiB
C#
38 lines
1.2 KiB
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
using UnityEngine.Tilemaps;
|
|
|
|
|
|
[CreateAssetMenu(menuName = "Gather And Defend/Resource Tile")]
|
|
public class ResourceTile : TileBase
|
|
{
|
|
public class ResourceTileData : ILevelObject
|
|
{
|
|
private Vector3 _position;
|
|
private string _resourceType;
|
|
|
|
public Vector3 Position => _position;
|
|
public string ResourceType => _resourceType;
|
|
|
|
public ResourceTileData(Vector2 position, string resourceType)
|
|
{
|
|
this._position = position;
|
|
this._resourceType = resourceType;
|
|
}
|
|
}
|
|
[SerializeField]
|
|
private Sprite _sprite;
|
|
public override bool StartUp(Vector3Int position, ITilemap tilemap, GameObject go)
|
|
{
|
|
if (!Application.isPlaying) return base.StartUp(position, tilemap, go);
|
|
LevelManager.Instance.Add(new ResourceTileData((Vector3)position, name));
|
|
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;
|
|
}
|
|
} |