Ejemplo n.º 1
0
        public void HandExitedInventoryHolster(GameObject hand, Holster holster)
        {
            if (holster.transform.childCount > 0)
            {
                holster.transform.GetChild(0).gameObject.SetActive(false);
            }

            switch (hand.GetComponent <HandController> ().LeftOrRight)
            {
            case HandLeftOrRight.Left:
                leftHandInfo.text = "";
                break;

            case HandLeftOrRight.Right:
                rightHandInfo.text = "";
                break;
            }
        }
Ejemplo n.º 2
0
        public void HandEnteredInventoryHolster(GameObject hand, Holster holster)
        {
            if (hand.tag == "Hand")
            {
                HandController handController = hand.GetComponent <HandController> ();
                //Item i = handController.HeldItem;
                var  itemObj = handController.InteractGrab.GrabbedObject;
                Item i;
                try {
                    i = handController.InteractGrab.GrabbedObject.GetComponent <Item> ();
                } catch (System.Exception e) {
                    i = null;
                }

                //If the user is not holding an item
                if (i == null)
                {
                    if (holster.HolsterSlotName == "Ammo Pouch")
                    {
                        if (ammoObj != null)
                        {
                            switch (handController.LeftOrRight)
                            {
                            case HandLeftOrRight.Left:
                                leftItemToMove    = ammoObj;
                                leftHandInfo.text = ammoObj.GetComponent <Item> ().itemName;
                                break;

                            case HandLeftOrRight.Right:
                                rightItemToMove    = ammoObj;
                                rightHandInfo.text = ammoObj.GetComponent <Item> ().itemName;
                                break;
                            }
                        }
                    }
                    else if (holster.HolsterSlotName == "Charger Holster")
                    {
                        if (handController.LeftOrRight == HandLeftOrRight.Right)
                        {
                            rightHandInfo.text = "Charger";
                            //chargerSlot.transform.GetChild (0).gameObject.SetActive (true);
                        }
                    }
                    else
                    {
                        //We expect there to be only 1 child gameobject so we only grab info from the first
                        if (holster.transform.childCount > 0)
                        {
                            holster.transform.GetChild(0).gameObject.SetActive(true);
                            switch (handController.LeftOrRight)
                            {
                            case HandLeftOrRight.Left:
                                leftItemToMove    = holster.transform.GetChild(0).gameObject;
                                leftHandInfo.text = holster.transform.GetChild(0).gameObject.GetComponent <Item> ().itemName;
                                break;

                            case HandLeftOrRight.Right:
                                rightItemToMove    = holster.transform.GetChild(0).gameObject;
                                rightHandInfo.text = holster.transform.GetChild(0).gameObject.GetComponent <Item> ().itemName;
                                break;
                            }
                        }
                    }
                }
                else
                {
                    //if they're holding an item
                    //check if it is an allowed type for the inventory slot
                    if (i.itemType == ItemTypes.Misc && holster.HolsterSlotName == "Ammo Pouch")
                    {
                        /*var ammoCheck = i.GetComponent<Magazine> ();
                         * if (ammoCheck != null) {
                         *  var remainder = AddAmmo (ammoCheck.AmmoType, ammoCheck.currentAmmo);
                         *  if (remainder == 0) {
                         *      handController.InteractGrab.ForceRelease ();
                         *      Destroy (i.gameObject);
                         *  } else {
                         *      ammoCheck.currentAmmo = remainder;
                         *  }
                         *  audioSource.PlayOneShot (ammoRestockClip);
                         * }*/
                    }
                    else if (i.itemType == holster.allowedTypes)
                    {
                        switch (handController.LeftOrRight)
                        {
                        case HandLeftOrRight.Left:
                            leftItemToMove          = i.gameObject;
                            leftHolsterToMoveItemTo = holster;
                            leftHandInfo.text       = holster.HolsterSlotName;
                            break;

                        case HandLeftOrRight.Right:
                            rightItemToMove          = i.gameObject;
                            rightHolsterToMoveItemTo = holster;
                            rightHandInfo.text       = holster.HolsterSlotName;
                            break;
                        }
                    }
                    else
                    {
                        switch (handController.LeftOrRight)
                        {
                        case HandLeftOrRight.Left:
                            leftHandInfo.text = "Invalid";
                            break;

                        case HandLeftOrRight.Right:
                            rightHandInfo.text = "Invalid";
                            break;
                        }
                    }
                }
            }
        }