Exemple #1
0
        void Start()
        {
            itemManager = GetComponent <vItemManager>();
            if (itemManager)
            {
                itemManager.onEquipItem.AddListener(EquipWeapon);
                itemManager.onUnequipItem.AddListener(UnequipWeapon);

                holders = GetComponentsInChildren <vWeaponHolder>(true);
                if (holders != null)
                {
                    foreach (vWeaponHolder holder in holders)
                    {
                        if (!holderAreas.ContainsKey(holder.equipPointName))
                        {
                            holderAreas.Add(holder.equipPointName, new List <vWeaponHolder>());
                            holderAreas[holder.equipPointName].Add(holder);
                        }
                        else
                        {
                            holderAreas[holder.equipPointName].Add(holder);
                        }

                        holder.SetActiveHolder(false);
                        holder.SetActiveWeapon(false);
                    }
                }
            }
        }
Exemple #2
0
 protected virtual void CheckItem(vItemManager itemManager)
 {
     if (getItemByName)
     {
         if (itemManager.ContainItem(itemName))
         {
             onContains.Invoke();
         }
         else
         {
             onNotContains.Invoke();
         }
     }
     else
     {
         if (itemManager.ContainItem(itemID))
         {
             onContains.Invoke();
         }
         else
         {
             onNotContains.Invoke();
         }
     }
 }
        IEnumerator SetItemsToItemManager(vItemManager itemManager)
        {
            yield return(new WaitForSeconds(onCollectDelay));

            itemManager.CollectItem(items, immediate);
            items.Clear();
        }
 public void CollectItems(vItemManager itemManager)
 {
     if (items.Count > 0)
     {
         StartCoroutine(SetItemsToItemManager(itemManager));
     }
 }
Exemple #5
0
        IEnumerator Start()
        {
            if (instance == null)
            {
                inventory = FindObjectOfType <vInventory>();
                instance  = this;

                if (!inventory && inventoryPrefab)
                {
                    inventory = Instantiate(inventoryPrefab);
                }

                if (!inventory)
                {
                    Debug.LogError("No vInventory assigned!");
                }

                if (inventory)
                {
                    inventory.GetItemsHandler = GetItems;
                    inventory.onEquipItem.AddListener(EquipItem);
                    inventory.onUnequipItem.AddListener(UnequipItem);
                    inventory.onDropItem.AddListener(DropItem);
                    inventory.onLeaveItem.AddListener(LeaveItem);
                    inventory.onUseItem.AddListener(UseItem);
                    inventory.onOpenCloseInventory.AddListener(OnOpenCloseInventory);
                }
                animator = GetComponent <Animator>();

                if (dropItemsWhenDead)
                {
                    var character = GetComponent <vCharacter>();
                    if (character)
                    {
                        character.onDead.AddListener(DropAllItens);
                    }
                }

                var genericAction = GetComponent <vGenericAction>();
                if (genericAction != null)
                {
                    genericAction.OnDoAction.AddListener(CollectItem);
                }

                yield return(new WaitForEndOfFrame());

                items = new List <vItem>();
                if (itemListData)
                {
                    for (int i = 0; i < startItems.Count; i++)
                    {
                        AddItem(startItems[i], true);
                    }
                }
            }
        }
        protected override void OnEnable()
        {
            base.OnEnable();
            m_Logo            = (Texture2D)Resources.Load("itemManagerIcon", typeof(Texture2D));
            manager           = (vItemManager)target;
            itemReferenceList = serializedObject.FindProperty("startItems");
            skin = Resources.Load("skin") as GUISkin;
            var meleeManager = manager.GetComponent <vMeleeManager>();

            vItemManagerUtilities.CreateDefaultEquipPoints(manager, meleeManager);
            animator = manager.GetComponent <Animator>();
            if (manager.equipPoints != null)
            {
                inEdition     = new bool[manager.equipPoints.Count];
                newPointNames = new string[manager.equipPoints.Count];
            }

            else
            {
                manager.equipPoints = new List <EquipPoint>();
            }
        }