protected BothHandsCarriable bothHandsObject; // The object held by both hands (A long weapon for example) protected void Start() { inventory = new List <Carriable>(); leftHandObject = null; rightHandObject = null; bothHandsObject = null; }
private void DropBothHandsObject() { BothHandsCarriable carriable = bothHandsObject; carriable.carried = false; carriable.transform.parent = null; carriable.GetComponent <Rigidbody>().isKinematic = false; carriable.GetComponent <Rigidbody>().velocity = this.GetComponent <CharacterController>().velocity; bothHandsObject = null; }
/* Pick un an object * toInventory : Is the object put in the inventory ? * hand : the hand in which the Carriable will go, if the object isn't going into the Inventory or isn't a Both Hand Held Carriable */ protected void PickUpObject(Carriable carriable, bool toInventory = false, MyEnum.Hand hand = MyEnum.Hand.None) { if (toInventory) { if (inventory.Count < 8 && carriable.hideable) { carriable.carried = true; inventory.Add(carriable); } } else { if (carriable is BothHandsCarriable) { BothHandsCarriable cast = (BothHandsCarriable)carriable; if (!bothHandsObject && !rightHandObject && !leftHandObject) { carriable.carried = true; carriable.transform.parent = this.gameObject.transform; carriable.GetComponent <Rigidbody>().isKinematic = true; carriable.transform.localPosition = new Vector3(0f, 0f, 1f); bothHandsObject = cast; } } else { if (hand == MyEnum.Hand.Left) { if (!leftHandObject && !bothHandsObject) { carriable.carried = true; carriable.transform.parent = this.gameObject.transform; carriable.GetComponent <Rigidbody>().isKinematic = true; carriable.transform.localPosition = new Vector3(-1f, 0f, 0f); leftHandObject = carriable; } } else if (hand == MyEnum.Hand.Right) { if (!rightHandObject && !bothHandsObject) { carriable.carried = true; carriable.transform.parent = this.gameObject.transform; carriable.GetComponent <Rigidbody>().isKinematic = true; carriable.transform.localPosition = new Vector3(1f, 0f, 0f); rightHandObject = carriable; } } } } }