63 lines
1.5 KiB
C#
63 lines
1.5 KiB
C#
using System.Collections.Generic;
|
|
using System.Diagnostics.CodeAnalysis;
|
|
using Escape_Room_Engine.Engine.Scripts.Utilities;
|
|
using NaughtyAttributes;
|
|
using UnityEngine;
|
|
|
|
namespace Escape_Room_Engine.Engine.Scripts
|
|
{
|
|
[SuppressMessage("ReSharper", "InconsistentNaming")]
|
|
public enum TileLocation
|
|
{
|
|
NW, N, NE,
|
|
W, C, E,
|
|
SW, S, SE
|
|
}
|
|
|
|
public class SpaceTile : MonoBehaviour
|
|
{
|
|
public static HashSet<TileLocation> EveryTileLocation => new(new[]
|
|
{
|
|
TileLocation.NW, TileLocation.N, TileLocation.NE,
|
|
TileLocation.W, TileLocation.C, TileLocation.E,
|
|
TileLocation.SW, TileLocation.S, TileLocation.SE
|
|
});
|
|
|
|
[BoxGroup("Style Prefabs")] [SerializeField]
|
|
private UDictionary<TileLocation, GameObject> tilePrefabs;
|
|
[BoxGroup("Style Prefabs")] [SerializeField]
|
|
private Material material;
|
|
|
|
public TileLocation showTile;
|
|
|
|
private GameObject _tile;
|
|
private TileLocation _showTile;
|
|
|
|
private void Start()
|
|
{
|
|
SetTile();
|
|
}
|
|
|
|
private void Update()
|
|
{
|
|
if (_showTile != showTile)
|
|
{
|
|
SetTile();
|
|
}
|
|
}
|
|
|
|
private void SetTile()
|
|
{
|
|
if (_tile)
|
|
{
|
|
Destroy(_tile);
|
|
}
|
|
|
|
_tile = Instantiate(tilePrefabs[showTile], transform);
|
|
_tile.GetComponent<MeshRenderer>().material = material;
|
|
|
|
_showTile = showTile;
|
|
}
|
|
}
|
|
}
|