private void OnTriggerExit(Collider other) { if (other.tag == "ShelfZone") { Debug.Log("Player exited shelf zone!"); if (PlayerInteractionManager.IsInventoryFull()) { //if inventory is full, player can now drop items Debug.Log("ShelfInteraction - Player can now drop items!"); PlayerInteractionManager.ChangePlayerState(PlayerInteractionManager.PlayerState.CanDropIngredient); } } }
//if enter shelf trigger and shelf detected is true //player is facing shelf private void OnTriggerEnter(Collider other) { if (other.tag == "ShelfZone") { //player in shelf zone, cannot drop anything here Debug.Log("ShelfInteraction - Player is in the shelf zone!"); if (PlayerInteractionManager.IsInventoryFull()) { //if inventory full, then set state to default PlayerInteractionManager.ChangePlayerState(PlayerInteractionManager.PlayerState.Default); } } }
//Player must be near a table item layer and have nothing in their inventory public void CheckTableItemCriteria() { if (tableItemDetected) { //if inventory not full if (!PlayerInteractionManager.IsInventoryFull()) { //change player state Debug.Log("TableInteraction - Can pick up table item!"); PlayerInteractionManager.ChangePlayerState(PlayerInteractionManager.PlayerState.CanPickUpDirtyPlate); } else { //if inventory is full Debug.Log("TableInteraction - Inventory is full, unable to pick up!"); } } }
//handles all logic for changing the player state //only works if the object detected by radar is an ingredient layer public void CheckIngredientCriteria() { if (ingredientDetected) { //PICK UP CRITERIA //if inventory is not full, able to pick up if (!PlayerInteractionManager.IsInventoryFull()) { print("IngredientInteraction - Can pick up ingredient!"); //Switch the state PlayerInteractionManager.ChangePlayerState(PlayerInteractionManager.PlayerState.CanPickUpIngredient); } //DROP CRITERIA else if (PlayerInteractionManager.IsInventoryFull()) { //if inventory is full, able to drop print("IngredientInteraction - Can drop ingredient"); //set spawned prefab bools false so they are now just like any normal ingredient //removes them from being permanently detected object ShelfInteraction.spawnedEgg = false; ShelfInteraction.spawnedChicken = false; ShelfInteraction.spawnedCucumber = false; ShelfInteraction.spawnedRice = false; //switch the state if (!nearIngredientShelves) { PlayerInteractionManager.ChangePlayerState(PlayerInteractionManager.PlayerState.CanDropIngredient); } } } //if there is no detected object + the player isn't holding a customer, player state returns to default if (!PlayerInteractionManager.detectedObject && !WashInteraction.placedPlateInSink) { PlayerInteractionManager.ChangePlayerState(PlayerInteractionManager.PlayerState.Default); } }
// Update is called once per frame void Update() { //if detected and is drink machine if (PlayerInteractionManager.detectedObject && PlayerInteractionManager.detectedObject.layer == 21) { drinkMachineDetected = true; //PlayerInteractionManager.playerState = PlayerInteractionManager.PlayerState.CanSpawnDrink; } else { drinkMachineDetected = false; } //if drink if (PlayerInteractionManager.detectedObject && PlayerInteractionManager.detectedObject.layer == 22) { drinkDetected = true; if (!PlayerInteractionManager.IsInventoryFull()) { // PlayerInteractionManager.playerState = PlayerInteractionManager.PlayerState.CanPickUpDrink; } } else { drinkDetected = false; } //if cooldown if (isCooldown) { cooldownImg.fillAmount += 1 / cooldown * Time.deltaTime; if (cooldownImg.fillAmount >= 1) { cooldownImg.fillAmount = 1; isCooldown = false; } } }
public void OnTriggerStay(Collider other) { if (shelfDetected) { //if player inventory is not full if (!PlayerInteractionManager.IsInventoryFull()) { var detectedObject = PlayerInteractionManager.detectedObject.tag; if (other.tag == "EggShelfZone") { if (detectedObject == "EggShelf") { PlayerInteractionManager.ChangePlayerState(PlayerInteractionManager.PlayerState.CanSpawnEgg); Debug.Log("ShelfInteraction - Player can spawn an egg!"); } } else if (other.tag == "ChickenShelfZone" && detectedObject == "ChickenShelf") { PlayerInteractionManager.ChangePlayerState(PlayerInteractionManager.PlayerState.CanSpawnChicken); Debug.Log("ShelfInteraction - Player can spawn a chicken!"); } else if (other.tag == "CucumberShelfZone" && detectedObject == "CucumberShelf") { PlayerInteractionManager.ChangePlayerState(PlayerInteractionManager.PlayerState.CanSpawnCucumber); Debug.Log("ShelfInteraction - Player can spawn a cucumber!"); } else if (other.tag == "RiceTubZone" && detectedObject == "RiceTub") { PlayerInteractionManager.ChangePlayerState(PlayerInteractionManager.PlayerState.CanSpawnRice); Debug.Log("ShelfInteraction - Player can spawn some rice!"); } } } }