using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.EventSystems;

public class BuildingButtonController : MonoBehaviour, IPointerClickHandler {

	public Transform building;
	public LevelController level;
	public float scrapMetalCost = 10f;

	//Detect if a click occurs
	public void OnPointerClick(PointerEventData pointerEventData)
	{
		//Use this to tell when the user left-clicks on the Button
		if (pointerEventData.button == PointerEventData.InputButton.Left)
		{
			if (level.buildObject == null && level.scrapMetal >= scrapMetalCost) {
				level.buildObject = building;
				level.scrapMetal = level.scrapMetal - scrapMetalCost;
			}
		}
	}
}
