public void TowerSpawn(Transform tileTransform)
{
Tile tile = tileTransform.GetComponent<Tile>();
if (tile.isBuiltTower == true)
{
return;
}
tile.isBuiltTower = true;
Instantiate(GOrealRanger, new Vector3(tileTransform.position.x, tileTransform.position.y + 1, 0), Quaternion.identity);
}
public void CalcMousePos_PlaceTower()
{
ray = mainCam.ScreenPointToRay(Input.mousePosition);
if (Physics.Raycast(ray, out hit, Mathf.Infinity))
{
if (hit.transform.CompareTag("Tile"))
{
TowerSpawn(hit.transform);
}
else
{
Debug.Log("Nope");
}
}
}
public class Tile : MonoBehaviour
{
public bool isBuiltTower { set; get; }
private void Awake()
{
isBuiltTower = false;
}
}