Exemple #1
0
    void Update()
    {
        // Add some delay

        /*if (button_cooldown > 0.0f)
         * {
         *      button_cooldown -= Time.deltaTime;
         *      return;
         * }*/


        // Handle possible interactions first
        InteractionController interactions = this.gameObject.GetComponent <InteractionController>();

        interactions.UpdateInteractions();
        foreach (InteractionType type in Enum.GetValues(typeof(InteractionType)))
        {
            if (GetButtonDown(type))
            {
                Debug.Log("Checking interaction: " + type);
                foreach (Interactable obj in interactions.GetInteractions(type))
                {
                    Debug.Log(">   " + obj.gameObject.name);
                    if (obj.RequestInteraction(this.gameObject))
                    {
                        Debug.Log("Interacting with: " + obj);
                        return;
                    }
                }
            }
        }

        // Handle inventory stuff
        HumanoidInventoryController inventory = this.gameObject.GetComponent <HumanoidInventoryController>();

        if (GetButtonDown(InteractionType.Place))
        {
            inventory.ExecutePlace();
            return;
        }
        if (GetButtonDown(InteractionType.Holster))
        {
            inventory.ExecuteHolster();
            return;
        }
        if (GetButtonDown(InteractionType.Aim))
        {
            // TODO
        }
        if (CanThrow(inventory.GetItemInHands()))
        {
            if (GetButtonUp(InteractionType.Throw))
            {
                DoThrowExecute(inventory.GetItemInHands(), inventory);
            }
            else if (GetButtonPressed(InteractionType.Throw))
            {
                trajectory_renderer.enabled = DoThrowAiming(inventory.GetItemInHands());
                if (trajectory_renderer.enabled)
                {
                    return;
                }
            }
        }
    }