Working on UI and job assignment, harvesting and depositing to TownHall working
This commit is contained in:
22
Assets/Scripts/JobButton.cs
Normal file
22
Assets/Scripts/JobButton.cs
Normal file
@@ -0,0 +1,22 @@
|
||||
using UnityEngine;
|
||||
using UnityEngine.EventSystems;
|
||||
|
||||
// IPointerClickHandler is the magic interface that listens to ALL mouse clicks
|
||||
public class JobButton : MonoBehaviour, IPointerClickHandler
|
||||
{
|
||||
[Tooltip("Select which job this specific button manages.")]
|
||||
public NPC.Job jobType;
|
||||
|
||||
public void OnPointerClick(PointerEventData eventData)
|
||||
{
|
||||
// Intercept the click and pass the command to the UIController
|
||||
if (eventData.button == PointerEventData.InputButton.Left)
|
||||
{
|
||||
UIController.Instance.AddJob(jobType);
|
||||
}
|
||||
else if (eventData.button == PointerEventData.InputButton.Right)
|
||||
{
|
||||
UIController.Instance.RemoveJob(jobType);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user