public override void HandleOrder(Order o) { lastOrder = o.type; if (o.type == eOrderType.MOVE) { if (assigned) { assigned = false; assigneStation.RemoveWorker(); animator.SetTrigger("StopWork"); } movable.MoveTo(o.position); } if (o.type == eOrderType.WORK) { if (assigned) { assigned = false; assigneStation.RemoveWorker(); } movable.MoveTo(o.position); targetStation = o.station; } }
// Checks whether the number's digits are in a certain order. // will check from right to left instead of left to right (So Asc and Desc will be the opposite of what they are suppose to be when comparing // old digit to curr digit). private static bool isNumDigitsInOrder(eOrderType i_OrderType, int i_Num) { const bool v_IsValidOrderType = true; bool isInOrder = i_Num != 0; int lastDigitChecked = i_Num % 10; i_Num /= 10; while (isInOrder && (i_Num > 0)) { int currDigit = i_Num % 10; i_Num /= 10; switch (i_OrderType) { case eOrderType.Ascending: isInOrder = currDigit < lastDigitChecked; break; case eOrderType.Descending: isInOrder = lastDigitChecked < currDigit; break; default: isInOrder = !v_IsValidOrderType; break; } lastDigitChecked = currDigit; } return(isInOrder); }
protected override void Update() { base.Update(); if (lastOrder == eOrderType.WORK && movable.hasReachedPosition) { if (targetStation.AssignWorker()) { assigned = true; animator.SetTrigger("StartWork"); assigneStation = targetStation; } lastOrder = eOrderType.NONE; } if (assigned && assigneStation.tag == "Truck") { Truck truck = (Truck)assigneStation; if (truck.state != Truck.eState.UNLOADING) { assigned = false; assigneStation.RemoveWorker(); animator.SetTrigger("StopWork"); } } }
public SortedIndex(eOrderType type) { orderType = type; }