/// <summary> /// Called when a trigger is left /// </summary> /// <param name="cso">The selection object that was collided with</param> void TriggerExited_(CookingSelectionObject cso) { _currentItem.Remove(cso); cso.Unselected(); switch (cso.ObjectType) { case SelectionType.BreadBin: { if (_breadBinRoutine != null) { StopCoroutine(_breadBinRoutine); } _breadBinRoutine = StartCoroutine(CloseBreadBin_()); break; } case SelectionType.GrillZone: { if (_currentItem.Count == 0) { Chef.Burgers[_selectedPattyIndex].Glow.SetActive(false); _selectedPattyIndex = -1; } break; } } SelectFirstItem_(); UpdateHelp_(); }
/// <summary> /// Called when a trigger is entered /// </summary> /// <param name="cso">The selection object that was collided with</param> void TriggerEntered_(CookingSelectionObject cso) { bool valid = true; _currentItem.Insert(0, cso); // check that this item can be selected switch (_currentItem[0].ObjectType) { case SelectionType.BreadBin: valid = _burgerItemIndex == 0 && !Chef.BreadOptions[0].isActiveAndEnabled; if (_breadBinRoutine != null) { StopCoroutine(_breadBinRoutine); } _breadBinRoutine = StartCoroutine(OpenBreadBin_()); break; case SelectionType.Lettuce: case SelectionType.Tomato: case SelectionType.Pickle: valid = _burgerItemIndex > 0 && Chef.TopBun.gameObject.activeInHierarchy; break; case SelectionType.Sauce: valid = (_burgerItemIndex > 0) && (Chef.SquirtBottle.SauceImage.transform.localScale.x == 0) && Chef.TopBun.gameObject.activeInHierarchy;; break; } // don't do anything if the action is not appropriate if (!valid) { return; } // if entered a grill zone, keep track of it if (_currentItem[0].ObjectType == SelectionType.GrillZone) { _selectedPattyIndex = _currentItem[0].Index; } SelectFirstItem_(); UpdateHelp_(); }