Ejemplo n.º 1
0
        public void OnTriggerStay(Collider hit)
        {
            // if we collided a second object while we are interacting don't
            // interact with it
            if (this._currentInteractionObject != hit)
            {
                return;
            }

            // we hit something
            bool interact = CrossPlatformInputManager.GetButtonDown(GlobalUtilities.INTERACT);

            //was it a pickup item?
            if (hit.tag == GlobalUtilities.PICKUP_TAG)
            {
                //we want to first check the type
                ItemPickup pickUp = hit.GetComponent <ItemPickup>();

                //if the pickup doesn't require interaction the pickup script handles using the item
                if (!pickUp.RequiresInteraction())
                {
                    return;
                }

                if ((interact && !this._isInteracting))
                {
                    this._isInteracting = true;
                    GameObject currentWeapon = this.CurrentActiveWeapon();

                    switch (pickUp.GetPickupType())
                    {
                    case ItemPickup.RIGHT_HAND_WEAPON:

                        if (this._hasWeapon && currentWeapon != null)
                        {
                            BaseWeapon weaponScript = currentWeapon.GetComponent <BaseWeapon> ();
                            weaponScript.Drop();
                        }

                        this._rightHandWeapon = pickUp.PickUp(this._rightHandWeaponHold);
                        this._hasWeapon       = true;
                        this.GetRightHandWeaponScript().IsBeingHeld = true;
                        GlobalUtilities.ClearInteractText();

                        break;

                    case ItemPickup.RIGHT_HAND_SHIELD:
                        break;

                    case ItemPickup.LEFT_HAND_WEAPON:

                        if (this._hasWeapon && currentWeapon != null)
                        {
                            BaseWeapon weaponScript = currentWeapon.GetComponent <BaseWeapon> ();
                            weaponScript.Drop();
                        }

                        this._leftHandWeapon = pickUp.PickUp(this._leftHandWeaponHold);
                        this._hasWeapon      = true;
                        this.GetLeftHandWeaponScript().IsBeingHeld = true;
                        GlobalUtilities.ClearInteractText();

                        break;

                    case ItemPickup.LEFT_HAND_SHIELD:
                        break;

                    default:
                        break;
                    }

                    this._isInteracting = false;
                }
                else
                {
                    GlobalUtilities.ShowButtonInteract("X", pickUp.GetIdentifier());
                }
            }
        }