61 lines
1.7 KiB
C#
61 lines
1.7 KiB
C#
|
|
using System.Collections;
|
||
|
|
using System.Collections.Generic;
|
||
|
|
using UnityEngine;
|
||
|
|
using UnityEngine.EventSystems;
|
||
|
|
using TMPro;
|
||
|
|
|
||
|
|
public class Order {
|
||
|
|
public TableController destination;
|
||
|
|
|
||
|
|
public Order(TableController destination) {
|
||
|
|
this.destination = destination;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
public class OrderPlacementController : MonoBehaviour, IPointerClickHandler
|
||
|
|
{
|
||
|
|
[SerializeField] public Transform waypoint = null;
|
||
|
|
[SerializeField] public TextMeshPro debugText = null;
|
||
|
|
|
||
|
|
[HideInInspector] public Order order = null;
|
||
|
|
|
||
|
|
|
||
|
|
// Not owned.
|
||
|
|
[HideInInspector] private GameStateController gameStateController;
|
||
|
|
|
||
|
|
public void OnPointerClick(PointerEventData eventData) {
|
||
|
|
Debug.Log("I'm an order waypoint and you clicked on me!!");
|
||
|
|
gameStateController.HandleOrderClick(this);
|
||
|
|
}
|
||
|
|
|
||
|
|
// API to take a new order.
|
||
|
|
public void TakeOrder(Order o) {
|
||
|
|
Debug.Log("Animation update");
|
||
|
|
order = o;
|
||
|
|
}
|
||
|
|
|
||
|
|
// Yield the order to a talent, setting it as null for self.
|
||
|
|
// If an order is in the backlog, it'll be placed immediately at this table.
|
||
|
|
public Order PickUp() {
|
||
|
|
Order o = order;
|
||
|
|
order = null;
|
||
|
|
if (gameStateController.orderBacklog.Count > 0) {
|
||
|
|
TakeOrder(gameStateController.orderBacklog.Dequeue());
|
||
|
|
}
|
||
|
|
return o;
|
||
|
|
}
|
||
|
|
|
||
|
|
// Start is called before the first frame update
|
||
|
|
void Start() {
|
||
|
|
gameStateController = GameObject.FindGameObjectWithTag("GameStateController").GetComponent<GameStateController>();
|
||
|
|
}
|
||
|
|
|
||
|
|
private void LateUpdate() {
|
||
|
|
if (order != null) {
|
||
|
|
debugText.SetText(order.destination.tableId.ToString());
|
||
|
|
} else {
|
||
|
|
debugText.SetText("");
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|