using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.Tilemaps; public class GridController : MonoBehaviour { [SerializeField] Tilemap highlightMap = null; [SerializeField] TileBase hilightTile = null; private IAction hilightAction; public IAction HilightAction { get => hilightAction; set => hilightAction = value; } // Update is called once per frame void Update() { if (Input.GetMouseButtonDown(0) && hilightAction != null && hilightAction.GetHilightEnabled()) { Vector3Int clickedPos = GetMousePosition(); highlightMap.SetTile(clickedPos, hilightTile); // TODO needs better handling.. Should be in MoveAction??? YesNoDilougueUI.Instance.ShowDialog("Are you sure you want to move here?", () => { Debug.Log("YES PRESSED"); /* Confirm the move and paint the path to take. */}, () => { Debug.Log("NO PRESSED"); highlightMap.SetTile(clickedPos, null); }); } } Vector3Int GetMousePosition() { Vector3 mousePos = Input.mousePosition; mousePos.z = -Camera.main.transform.position.z; Vector3 worldPoint = Camera.main.ScreenToWorldPoint(mousePos); return GameManagerScript.GetInstance().TileMap.WorldToCell(worldPoint); } }