void Deactivate(int score) { // After an order is dispatched we can destroy the complete Indication System // FIXME: If more indications are added later this have to be changed! GameObject[] gos = GameObject.FindGameObjectsWithTag("Order"); foreach (GameObject go in gos) { Order_v2 o = go.GetComponent <Order_v2>(); if (o != null) { o.onOrderReady -= HandleOrderReady; o.onOrderGrabbed -= HandleOrderGrabbed; o.onOrderDropped -= Deactivate; } } OrderSlot_v2 os = orderSlot.GetComponent <OrderSlot_v2>(); os.onOrderInserted -= HandleOrderInserted; os.onOrderRemoved -= Deactivate; OMController_v2 omc = orderSlot.GetComponentInParent <OMController_v2>(); omc.onOMDispatch -= Deactivate; ABController_v2 abc = ABController.GetComponent <ABController_v2>(); abc.onIngredientPlaced -= HandleIngredientPlaced; Destroy(gameObject); }
void OnDestroy() { ABController_v2 ABController = GetComponentInParent <ABController_v2>(); if (ABController != null) { ABController.onIngredientPlaced -= PlaySquishClip; } }
// Use this for initialization void Start() { grabOrder = false; slotOrder = false; placeIngredient = false; dispatchOrder = false; // We consider the future case in which there will be multiple orders to select from... GameObject[] gos = GameObject.FindGameObjectsWithTag("Order"); foreach (GameObject go in gos) { Order_v2 o = go.GetComponent <Order_v2>(); if (o != null) { o.onOrderReady += HandleOrderReady; o.onOrderGrabbed += HandleOrderGrabbed; o.onOrderDropped += Deactivate; } } OrderSlot_v2 os = orderSlot.GetComponent <OrderSlot_v2>(); os.onOrderInserted += HandleOrderInserted; os.onOrderRemoved += Deactivate; OMController_v2 omc = orderSlot.GetComponentInParent <OMController_v2>(); omc.onOMDispatch += Deactivate; ABController_v2 abc = ABController.GetComponent <ABController_v2>(); abc.onIngredientPlaced += HandleIngredientPlaced; AddCarriageReturn(ref BoxTooltip); AddCarriageReturn(ref OMTooltip); AddCarriageReturn(ref AssemblyTooltip); AddCarriageReturn(ref DispatchTooltip); }