Example #1
0
    IEnumerator PerformASpotTimer(TaskEnviromentSpot spot)
    {
        if (spot.kind == TaskKind.FloorMop)
        {
            playerBroom.SetActive(true);
        }
        playerAnimator.SetTrigger("SweepFloor");
        yield return(new WaitForSeconds(3f));

        performingAction = false;
        playerBroom.SetActive(false);
        spot.FinishTask();
    }
Example #2
0
    private void Interaction()
    {
        if (Input.GetKeyDown(KeyCode.F))
        {
            if (visibleObject != null && visibleObject.tag != "Door")
            {
                Item  visibleItem              = visibleObject.GetComponent <Item>();
                Table visibleTable             = visibleObject.GetComponent <Table>();
                TaskEnviromentSpot visibleSpot = visibleObject.GetComponent <TaskEnviromentSpot>();
                Pot           visiblePot       = visibleObject.GetComponentInChildren <Pot>();
                RecipieMixPot rMP              = visibleObject.GetComponent <RecipieMixPot>();

                if (visibleItem == null && visibleSpot == null && visiblePot == null && visibleTable != null)
                {
                    visibleItem = visibleTable.item;
                }

                if (item == null && visibleItem != null && !potInHand)
                {
                    item = visibleItem;
                    item.transform.SetParent(hands.transform);
                    item.transform.position = hands.transform.position;
                    playerAnimator.SetTrigger("PickItem");
                    visibleItem = null;
                    if (visibleTable != null)
                    {
                        visibleTable.item = null;
                    }
                    return;
                }

                if (item != null && visibleTable != null && visibleTable.item == null && !potInHand)
                {
                    item.transform.SetParent(visibleTable.itemSlot.transform);
                    item.transform.position = visibleTable.itemSlot.transform.position;
                    playerAnimator.SetTrigger("PlaceItem");
                    visibleTable.TakeItem(item);
                    item = null;
                    return;
                }

                if (visibleTable != null && item == null && visiblePot != null)
                {
                    visiblePot.gameObject.transform.SetParent(hands.transform);
                    visiblePot.gameObject.transform.position = visiblePot.startingLocation;
                    visiblePot.ingredients = visibleTable.GetComponent <RecipieMixPot>().ingredients;
                    playerAnimator.SetTrigger("PickItem");
                    potInHand = true;
                    return;
                }

                if (potInHand && item == null && rMP != null)
                {
                    Pot newPot = hands.GetComponentInChildren <Pot>();
                    newPot.gameObject.transform.SetParent(rMP.itemSlot.transform);
                    newPot.gameObject.transform.position = newPot.startingLocation;
                    newPot.gameObject.transform.rotation = newPot.startingRotation;
                    newPot.ingredients = rMP.ingredients;
                    playerAnimator.SetTrigger("PlaceItem");
                    potInHand = false;
                }

                if (item == null && visibleSpot != null && !potInHand)
                {
                    if (visibleSpot.taskId < 0)
                    {
                        return;
                    }
                    performingAction = true;
                    StartCoroutine(PerformASpotTimer(visibleSpot));
                }
            }
        }
    }