Ejemplo n.º 1
0
    private void OnControllerColliderHit(ControllerColliderHit hit)
    {
        IInventoryItem item = hit.collider.GetComponent <IInventoryItem>();

        if (item != null)
        {
            inventory.AddItem(item);
        }
    }
Ejemplo n.º 2
0
    void Update()
    {
        if (flag == true)
        {
            if (Time.time <= last_time)
            {
                if (armComp.animation.isPlaying)
                {
                    armComp.animation.Stop("stop");
                    armComp.animation.Stop("walk");
                }
                armComp.animation.Play("makeSMT", 0);
                stop_boy = true;
            }
            else
            {
                stop_boy = false;
                armComp.animation.Play("stop");
                if (currentInterObjScript.inventory)
                {
                    inventory.AddItem(currentIntObj);
                }
                else
                {
                    currentInterObjScript.isAlreadyUsed = true;
                    currentInterObjScript.changed();
                    inventory.RemoveItem(currentInterObjScript.ItemNeeded);
                }
                flag = false;
            }
        }
        if (Input.GetButtonDown("Interact") && currentIntObj && gameObject.activeSelf)
        {
            if (!currentInterObjScript.hide)
            {
                if (currentInterObjScript.inventory)
                {
                    if (!flag)
                    {
                        last_time = Time.time + 0.5f;
                        flag      = true;
                    }
                }

                if (!currentInterObjScript.isAlreadyUsed && !currentInterObjScript.inventory)
                {
                    if (inventory.FindItem(currentInterObjScript.ItemNeeded))
                    {
                        if (!flag)
                        {
                            last_time = Time.time + 0.5f;
                            flag      = true;
                        }
                    }
                    else
                    {
                        if (currentInterObjScript.have_message)
                        {
                            currentInterObjScript.say();
                            message = "У нас нет специального предмета для взаимодействия";
                            StartCoroutine(Sometime(message));
                        }
                    }
                }
                else
                {
                    //IIs alredy used
                    if (!currentInterObjScript.inventory)
                    {
                        message = "Мы уже испортили его!";
                        StartCoroutine(Sometime(message));
                    }
                }
            }
            else
            {
                //Мальчик спрятался
                gameObject.SetActive(false);
            }
        }
    }