internal void ActionFinished() { var nextAction = CurrentOrder?.GetNextAction(); if (nextAction == null) { CurrentAction = null; CurrentOrder = null; } else { StartAction(nextAction); } }
// Update is called once per frame void Update() { if (Input.GetKeyDown(KeyCode.G)) { var orderlyController = FindObjectOfType <OrderlyController>(); var station = FindObjectsOfType <PickupStationController>()[0]; var stationPos = station.transform.position; var table = FindObjectsOfType <TableStation>()[0]; var tablePos = table.transform.position; OrderlyOrder order = new OrderlyOrder(stationPos); order.AddAction(new OrderlyMoveAction(station.transform)); order.AddAction(new OrderlyInteractionAction(station)); order.AddAction(new OrderlyMoveAction(table.transform)); order.AddAction(new OrderlyInteractionAction(table)); orderlyController.StartOrder(order); } }
// Update is called once per frame private void Update() { CheckOrderQueue(); if (Input.GetMouseButtonDown(0)) { RaycastHit hit; Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition); if (Physics.Raycast(ray, out hit, 1000.0f)) { var actionable = hit.transform.root.GetComponent <Actionable>(); if (actionable != null && actionable.IsActionActive) { var order = new OrderlyOrder(actionable.transform.position); order.AddAction(new OrderlyMoveAction(actionable.transform)); order.AddAction(new OrderlyInteractionAction(actionable)); AddOrderToQueue(order); } Debug.Log("You selected the " + hit.transform.name); // ensure you picked right object } } }
internal void CancelOrder() { CurrentAction = null; CurrentOrder = null; FindObjectOfType <MouseInputController>().ClearQueue(); }
public void StartOrder(OrderlyOrder pOrder) { CurrentOrder = pOrder; StartAction(CurrentOrder.GetNextAction()); }
private OrderlyController GetNearestAvailableOrderly(OrderlyOrder pNextOrder) { return(Orderlies.Where(a => a.CurrentOrder == null).OrderBy(a => Vector3.Distance(a.transform.position, pNextOrder.FirstActionPosition)).FirstOrDefault()); }
private void AddOrderToQueue(OrderlyOrder pOrder) { Orders.Enqueue(pOrder); CheckOrderQueue(); }