Esempio n. 1
0
    public void OnTriggerExit(Collider other)
    {
        //if exit sink zone
        if (other.tag == "SinkZone" && PlayerInteractionManager.CanChangePlayerState())
        {
            Debug.Log("SinkInteraction - Exited sink zone");
            showWashIcon = false;

            //if holding a dirty plate
            if (holdingDirtyPlate || platesInSink != 0)
            {
                //DELETE LATER
                Debug.Log("SinkInteraction - You should wash the plate!");
                PlayerInteractionManager.playerState = PlayerInteractionManager.PlayerState.ExitedSink;
                startTimer = false; //stop the timer
            }

            //if was washing a dirty plate
            if (PlayerInteractionManager.playerState == PlayerInteractionManager.PlayerState.WashingPlate)
            {
                //change state to stopped washing plate
                PlayerInteractionManager.playerState = PlayerInteractionManager.PlayerState.StoppedWashingPlate;
                //set bool true
                stoppedWashingPlate = true;
                startTimer          = false; //stop the timer
            }
        }
        else
        {
            Debug.Log("SinkInteraction - Not holding plate, do nothing"); //delete later
        }
    }
Esempio n. 2
0
    public void OnTriggerEnter(Collider other)
    {
        //if it is the sink zone
        if (other.tag == "SinkZone" && PlayerInteractionManager.CanChangePlayerState())
        {
            Debug.Log("SinkInteraction - Player in sink zone!");

            //If player is holding a  plate
            if (holdingDirtyPlate)
            {
                Debug.Log("SinkInteraction - Player able to place plate in sink!");
                PlayerInteractionManager.playerState = PlayerInteractionManager.PlayerState.CanPlacePlateInSink;
            }
            //if player was washing plate, then if they enter the sink zone again they can resume
            //TODO: CHANGE TO ELSE
            else if (stoppedWashingPlate || platesInSink != 0 && PlayerInteractionManager.CanChangePlayerState())
            {
                Debug.Log("SinkInteraction - Player can resume washing plate!");

                //Change state to can wash plate
                PlayerInteractionManager.playerState = PlayerInteractionManager.PlayerState.CanWashPlate;
                showWashIcon = true;
            }
            else
            {
                Debug.Log("SinkInteraction - Not holding plate, do nothing"); //delete later
            }
        }
    }
Esempio n. 3
0
    public void OnTriggerExit(Collider other)
    {
        //if exit sink zone
        if (other.tag == "SinkZone")
        {
            Debug.Log("WashInteraction - Player has exited the sink! Disable wash icon");

            showWashIcon = false; //hide wash icon

            if (holdingDirtyPlate || platesInSinkCount != 0)
            {
                //player exited sink
                PlayerInteractionManager.ChangePlayerState(PlayerInteractionManager.PlayerState.ExitedSink);
                startTimer = false;
            }

            //if player was washing a dirty plate
            if (PlayerInteractionManager.playerState == PlayerInteractionManager.PlayerState.WashingPlate)
            {
                //change state
                PlayerInteractionManager.ChangePlayerState(PlayerInteractionManager.PlayerState.StoppedWashingPlate);

                //set bool true
                stoppedWashingPlate = true;
                startTimer          = false;
            }
        }
    }
 void Awake()
 {
     // Get component references
     animator = GetComponent <Animator>();
     rb2d     = GetComponent <Rigidbody2D>();
     playerIM = GetComponent <PlayerInteractionManager>();
     helpMenu.SetActive(true);
     SetControlsEnabled(false);
 }
Esempio n. 5
0
    //plate plate in sink
    //only if PLACE PLATE IN SINK state
    public void PlacePlateInSink(GameObject heldPlate, List <GameObject> Inventory)
    {
        Transform[] sinkPositions = new Transform[2];

        //if (sinkParentObj.GetComponent<SinkScript_Temp>() != null)
        //{
        //    sinkPositions = sinkParentObj.GetComponent<SinkScript_Temp>().sinkPositions;
        //} else
        //{
        //    Debug.Log("SinkScript not present");
        //}


        //loop through plate in sink array
        //if the gameobject is null, assign heldplate to it
        for (int i = 0; i < platesInSink.Length; i++)
        {
            if (platesInSink[i] == null)
            {
                platesInSink[i] = heldPlate;
                heldPlate.transform.position = sinkPositions[i].position;

                //increase count of plates
                platesInSinkCount += 1;
                Debug.Log("WashInteraction - One more plate in the sink!");

                //Generic functions

                heldPlate.layer = LayerMask.NameToLayer("UnInteractable");

                //Remove detected object
                PlayerInteractionManager.detectedObject = null;

                Debug.Log("Sinkinteraction - Placing plate in sink");

                //unparent
                heldPlate.transform.parent = null;

                //Remove from inventory
                Inventory.Remove(heldPlate);

                //Set rotation back to 0
                heldPlate.transform.rotation = Quaternion.identity;


                placedPlateInSink = true; //player has placed plate in sink
                holdingDirtyPlate = false;

                //change state to can wash
                PlayerInteractionManager.ChangePlayerState(PlayerInteractionManager.PlayerState.CanWashPlate);
                showWashIcon = true;

                return;
            }
        }
    }
Esempio n. 6
0
    //------------------------------------------------------TAKING / SERVING CUSTOMERS' ORDERS----------------------------------------------------------------------
    #region Picking orders up
    public void PickOrderUp(GameObject dishObj, List <GameObject> playerInventory, Transform pointAboveHead)
    {
        //Parent to attachment point and transform
        dishObj.transform.parent   = pointAboveHead.transform;
        dishObj.transform.position = pointAboveHead.position;

        //add the customer to the inventory
        playerInventory.Add(dishObj);

        //change player state
        PlayerInteractionManager.ChangePlayerState(PlayerInteractionManager.PlayerState.HoldingOrder);
    }
Esempio n. 7
0
 //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);
         }
     }
 }
Esempio n. 8
0
 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);
         }
     }
 }
Esempio n. 9
0
    //when done washing plate, reset timer and spawn clean plate
    public void FinishWashingPlate()
    {
        //if starttimer is true, destroy the dirty plate in the sink (washed)
        if (startTimer)
        {
            for (int i = platesInSink.Length - 1; i >= 0; i--)
            {
                if (platesInSink[i] != null)
                {
                    Destroy(platesInSink[i].gameObject);
                    platesInSink[i] = null;
                    //reduce number of plates in sink
                    platesInSinkCount -= 1;

                    for (int x = 0; x < cleanPlatesOnTable.Length; x++)
                    {
                        //if there is no clean plate in that position, instantiate one
                        if (cleanPlatesOnTable[x] == null)
                        {
                            var cleanPlate = Instantiate(cleanPlatePrefab, cleanPlateSpawnPositions[x].position, Quaternion.identity);
                            cleanPlatesOnTable[x] = cleanPlate;
                            cleanPlatesCount     += 1;

                            //set all bools to false
                            startTimer = false;

                            //if there are still plates in the sink
                            if (platesInSinkCount != 0)
                            {
                                showWashIcon      = true;
                                placedPlateInSink = true;

                                //continue washing plate
                                PlayerInteractionManager.ChangePlayerState(PlayerInteractionManager.PlayerState.CanWashPlate);
                                return;
                            }
                            else
                            {
                                showWashIcon      = false;
                                placedPlateInSink = false;
                            }
                            return;
                        }
                    }
                }
            }
        }
    }
Esempio n. 10
0
    //function to wash the plate
    //only if CAN WASH PLATE state
    public void WashDirtyPlate()
    {
        if (cleanPlatesCount == 2)
        {
            Debug.Log("WashInteraction - Too many clean plates");
            return;
        }

        //set bool to start the timer on UI manager
        startTimer = true;

        //set stoppedwashing plate false
        stoppedWashingPlate = false;

        //set state to washing plate
        PlayerInteractionManager.ChangePlayerState(PlayerInteractionManager.PlayerState.WashingPlate);
    }
Esempio n. 11
0
 //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!");
         }
     }
 }
Esempio n. 12
0
    //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);
        }
    }
Esempio n. 13
0
    // 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;
            }
        }
    }
Esempio n. 14
0
    public void CheckCanPutDownOrder(List <GameObject> _playerInventory, GameObject _detectedObj, Transform _dropOffPoint)
    {
        GameObject heldDish = FindDishInInventory(_playerInventory);

        if (_detectedObj != null)
        {
            //if the player is looking at a customer
            if (_detectedObj.GetComponent <CustomerBehaviour_Seated>() != null || _detectedObj.transform.parent.gameObject.GetComponent <CustomerBehaviour_Seated>() != null)
            {
                //Debug.Log("PlayerCustomerInteraction - Looking at customer");
                if (ServingCustomer(heldDish, _detectedObj))
                {
                    _playerInventory.Remove(heldDish);
                    PlayerInteractionManager.ChangePlayerState(PlayerInteractionManager.PlayerState.Default, true);
                }
            }
            else
            {
                //Debug.Log("not looking at a customer that can be served");
            }
        }
    }
Esempio n. 15
0
    //When player is looking at a queueing customer and presses the interaction button,
    public void PickCustomerUp(GameObject customerGameobj, List <GameObject> playerInventory, Transform pointAboveHead)
    {
        //refer to the parent holding the customer collider
        customerGameobj   = customerGameobj.transform.parent.gameObject;
        customerBeingHeld = customerGameobj;
        //Debug.Log("Customer being held");

        //animate the customer curling up + stop the patience meter
        customerGameobj.GetComponent <CustomerBehaviour_Queueing>().CustomerPickedUp(pointAboveHead);

        //Parent to attachment point and transform
        customerGameobj.transform.parent   = pointAboveHead.transform;
        customerGameobj.transform.position = pointAboveHead.position;

        //add the customer to the inventory
        playerInventory.Add(customerGameobj);

        //allow tables to be detected
        TableColliderManager.Instance.ToggleTableDetection(true);

        PlayerInteractionManager.ChangePlayerState(PlayerInteractionManager.PlayerState.HoldingCustomer);
    }
Esempio n. 16
0
    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!");
                }
            }
        }
    }
Esempio n. 17
0
    //When the player is looking at a table and is carrying a customer,
    public void SeatCustomer(List <GameObject> playerInventory, GameObject tableGameobj)
    {
        // Debug.Log("Seat customer method called");

        if (!tableGameobj.GetComponent <TableScript>())
        {
            //Debug.Log("player is not looking at table");
            return;
        }

        if (!playerInventory.Contains(customerBeingHeld))
        {
            //Debug.Log("player is not holding customer??");
            return;
        }

        TableScript tableScript = tableGameobj.GetComponent <TableScript>();

        //If the table has enough seats for the group of customers,
        if (tableScript.CheckSufficientSeats(customerBeingHeld.GetComponent <CustomerBehaviour_Queueing>().GroupSizeNum))
        {
            //Debug.Log("Enough seats for customers");

            //disallow tables from being detected
            TableColliderManager.Instance.ToggleTableDetection(false);

            //remove the customer from the inventory
            playerInventory.Remove(customerBeingHeld);

            //stop holding the customer + activate the customers at the table
            Destroy(customerBeingHeld.gameObject);

            customerBeingHeld = null;

            PlayerInteractionManager.ChangePlayerState(PlayerInteractionManager.PlayerState.Default, true);
        }
    }
Esempio n. 18
0
    public void OnTriggerEnter(Collider other)
    {
        //if player is in sink zone
        if (other.tag == "SinkZone")
        {
            //if player is holding a plate
            if (holdingDirtyPlate)
            {
                sinkParentObj = other.gameObject;

                //player can place plate in the sink
                PlayerInteractionManager.ChangePlayerState(PlayerInteractionManager.PlayerState.CanPlacePlateInSink);
            }

            //if player was washing plate, if they enter the sink zone again they can immediately wash
            //or if there are still plates in the sink
            else if (stoppedWashingPlate || platesInSinkCount != 0)
            {
                PlayerInteractionManager.ChangePlayerState(PlayerInteractionManager.PlayerState.CanWashPlate);

                showWashIcon = true;
            }
        }
    }
Esempio n. 19
0
    public void CheckHandsEmpty(List <GameObject> playerInventory, GameObject tableGameobj)
    {
        //check if the player is looking at a table
        if (tableGameobj.GetComponent <TableScript>() == null)
        {
            //Debug.Log("player is not looking at table");
            return;
        }

        //get the table script
        TableScript tableScript = tableGameobj.GetComponent <TableScript>();

        //if the player's hands are full, don't take their order
        if (playerInventory.Count > 0)
        {
            //Debug.Log("player's hands are full");
            tableScript.TableFeedbackScript.HandsFullFeedback();
            return;
        }

        //else, take the order of the customers at the table
        //tableScript.TakeOrder();
        PlayerInteractionManager.ChangePlayerState(PlayerInteractionManager.PlayerState.Default);
    }