Esempio n. 1
0
 /**
  *  Enable this item- should be called when an item
  *  is unequipped. This will re-enable the BoxCollider2D
  *  and RigiBody2D components. Will set it's parent to
  *  null, and Active to false (so it won't render)
  *
  *  @param EquipmentItem item The item
  **/
 private void EnableItem(EquipmentItem item)
 {
     item.transform.parent = null;
     item.gameObject.SetActive(false);
     item.GetComponent <BoxCollider2D>().enabled   = true;
     item.GetComponent <Rigidbody2D>().isKinematic = false;
 }
Esempio n. 2
0
        /**
         *  Equip an item at a given type. This will disable the item's
         *  RigidBody2D and BoxCollider2D components, and will sync it's animation
         *  with the parent object.
         *
         *  @param EquipmentType type The "slot" to put the item in
         *  @param EquipmentItem item The item
         **/
        public void Equip(EquipmentType type, EquipmentItem item)
        {
            DisableItem(item);
            equipment.Add(type, item.gameObject);
            animationSync.ReloadChildAnimators();

            item.Equip();
        }
Esempio n. 3
0
 /**
  *  Disable this item- should be called when an item is
  *  equipped. This will disable the BoxCollider2D and
  *  RigidBody2D components. It will set the item to Active
  *  and it's parent to the equipment container- as well as
  *  setting it's localPosition to Vector3.zero, relying on
  *  the position of the item in the spritesheet
  *
  *  @param EquipmentItem item The item
  **/
 private void DisableItem(EquipmentItem item)
 {
     item.gameObject.SetActive(true);
     item.gameObject.transform.parent              = equipmentContainer.transform;
     item.transform.localPosition                  = Vector3.zero;
     item.GetComponent <BoxCollider2D>().enabled   = false;
     item.GetComponent <Rigidbody2D>().isKinematic = true;
 }
Esempio n. 4
0
        /**
         *  Unequip an item of a given type (slot). This will re-enable
         *  the item's RigidBody2D and BoxCollider2D components, and
         *  will remove this object from the parent transform.
         *
         *  @param EquipmentType equipmentType the "slot" to remove the item from
         **/
        public EquipmentItem Unequip(EquipmentType type)
        {
            if (equipment.ContainsKey(type))
            {
                EquipmentItem item = equipment[type].GetComponent <EquipmentItem>();
                EnableItem(item);
                equipment.Remove(type);
                animationSync.ReloadChildAnimators();

                item.Unequip();
                return(item);
            }
            return(null);
        }