Example #1
0
    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);
        }
    }
Example #3
0
    // 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
            }
        }
    }
Example #4
0
 internal void CancelOrder()
 {
     CurrentAction = null;
     CurrentOrder  = null;
     FindObjectOfType <MouseInputController>().ClearQueue();
 }
Example #5
0
 public void StartOrder(OrderlyOrder pOrder)
 {
     CurrentOrder = pOrder;
     StartAction(CurrentOrder.GetNextAction());
 }
Example #6
0
 private OrderlyController GetNearestAvailableOrderly(OrderlyOrder pNextOrder)
 {
     return(Orderlies.Where(a => a.CurrentOrder == null).OrderBy(a => Vector3.Distance(a.transform.position, pNextOrder.FirstActionPosition)).FirstOrDefault());
 }
Example #7
0
 private void AddOrderToQueue(OrderlyOrder pOrder)
 {
     Orders.Enqueue(pOrder);
     CheckOrderQueue();
 }