Exemple #1
0
        void Start()
        {
            if (!isInit)
            {
                isInit = true;
                //indexOfEquipedItem = -1;
                inventory = GetComponentInParent <vInventory>();

                if (equipSlots.Count == 0)
                {
                    var equipSlotsArray = GetComponentsInChildren <vEquipSlot>(true);
                    equipSlots = equipSlotsArray.vToList();
                }
                foreach (vEquipSlot slot in equipSlots)
                {
                    slot.onSubmitSlotCallBack   = OnSubmitSlot;
                    slot.onSelectSlotCallBack   = OnSelectSlot;
                    slot.onDeselectSlotCallBack = OnDeselect;

                    if (slot.displayAmountText)
                    {
                        slot.displayAmountText.text = "";
                    }
                    slot.onChangeAmount.Invoke("");
                }
            }
        }
        IEnumerator Start()
        {
            if (instance == null)
            {
                inventory = FindObjectOfType <vInventory>();
                instance  = this;

                var melee = GetComponent <vMeleeCombatInput>();

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

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

                if (inventory)
                {
                    inventory.GetItemsHandler    = GetItems;
                    inventory.GetItemsAllHandler = GetAllItems;
                    if (melee)
                    {
                        inventory.IsLockedEvent = () => { return(melee.lockInventory); }
                    }
                    ;                                                                    //Locking Inventory Input if MeleeInput is lockInventory
                    inventory.onEquipItem.AddListener(EquipItem);
                    inventory.onUnequipItem.AddListener(UnequipItem);
                    inventory.onDropItem.AddListener(DropItem);
                    inventory.onLeaveItem.AddListener(DestroyItem);
                    inventory.onUseItem.AddListener(UseItem);
                    inventory.onOpenCloseInventory.AddListener(OnOpenCloseInventory);
                }
                animator = GetComponent <Animator>();

                if (dropItemsWhenDead)
                {
                    var character = GetComponent <vCharacterController.vICharacter>();
                    if (character != null)
                    {
                        character.onDead.AddListener(DropAllItens);
                    }
                }
                yield return(new WaitForEndOfFrame());

                items = new List <vItem>();
                if (itemListData)
                {
                    for (int i = 0; i < startItems.Count; i++)
                    {
                        AddItem(startItems[i], true);
                    }
                }
            }
        }
Exemple #3
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(DestroyItem);
                    inventory.onUseItem.AddListener(UseItem);
                    inventory.onOpenCloseInventory.AddListener(OnOpenCloseInventory);
                }
                animator = GetComponent <Animator>();

                if (dropItemsWhenDead)
                {
                    var character = GetComponent <vCharacterController.vICharacter>();
                    if (character != null)
                    {
                        character.onDead.AddListener(DropAllItens);
                    }
                }

                var genericAction = GetComponent <vCharacterController.vActions.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);
                    }
                }
            }
        }
Exemple #4
0
        void OnGUI()
        {
            if (!skin)
            {
                skin = Resources.Load("skin") as GUISkin;
            }
            GUI.skin = skin;

            this.minSize      = rect;
            this.titleContent = new GUIContent("Inventory System", null, "ItemManager Creator Window");
            m_Logo            = Resources.Load("icon_v2") as Texture2D;
            GUILayout.BeginVertical("ItemManager Creator Window", "window");
            GUILayout.Label(m_Logo, GUILayout.MaxHeight(25));
            GUILayout.Space(5);

            GUILayout.BeginVertical("box");

            inventoryPrefab = EditorGUILayout.ObjectField("Inventory Prefab: ", inventoryPrefab, typeof(vInventory), false) as vInventory;
            itemListData    = EditorGUILayout.ObjectField("Item List Data: ", itemListData, typeof(vItemListData), false) as vItemListData;

            if (inventoryPrefab != null && inventoryPrefab.GetComponent <vInventory>() == null)
            {
                EditorGUILayout.HelpBox("Please select a Inventory Prefab that contains the vInventory script", MessageType.Warning);
            }

            GUILayout.EndVertical();

            GUILayout.BeginHorizontal("box");
            EditorGUILayout.LabelField("Need to know how it works?");
            if (GUILayout.Button("Video Tutorial"))
            {
                //Application.OpenURL("https://www.youtube.com/watch?v=1aA_PU9-G-0&index=3&list=PLvgXGzhT_qehtuCYl2oyL-LrWoT7fhg9d");
            }
            GUILayout.EndHorizontal();

            GUILayout.BeginHorizontal();
            GUILayout.FlexibleSpace();
            if (inventoryPrefab != null && itemListData != null)
            {
                if (Selection.activeGameObject != null && Selection.activeGameObject.GetComponent <vThirdPersonController>() != null)
                {
                    if (GUILayout.Button("Create"))
                    {
                        Create();
                    }
                }
                else
                {
                    EditorGUILayout.HelpBox("Please select the Player to add this component", MessageType.Warning);
                }
            }
            GUILayout.FlexibleSpace();
            GUILayout.EndHorizontal();

            GUILayout.EndVertical();
        }
        void Start()
        {
            equipAreas = GetComponentsInChildren <vEquipArea>().vToList();
            foreach (vEquipArea area in equipAreas)
            {
                area.onSelectEquipArea.AddListener(OnSelectArea);
            }

            inventory = GetComponentInParent <vInventory>();
        }
Exemple #6
0
        void Start()
        {
            inventory = GetComponentInParent <vInventory>();

            for (int i = 0; i < slotsSelectors.Count; i++)
            {
                onSelectSlot += slotsSelectors[i].Select;
            }

            onSelectSlot?.Invoke(0);
        }
Exemple #7
0
        public void OnEnable()
        {
            if (inventory == null)
            {
                inventory = GetComponentInParent <vInventory>();
            }

            if (inventory && itemWindow)
            {
                itemWindow.CreateEquipmentWindow(inventory.items, OnSubmit, OnSelectSlot);
            }
        }
        public void OnEnable()
        {
            if (inventory == null)
            {
                inventory = GetComponentInParent <vInventory>();
            }

            if (inventory && itemWindow)
            {
                inventory.onLeaveItem.RemoveListener(OnDestroyItem);
                inventory.onLeaveItem.AddListener(OnDestroyItem);
                itemWindow.CreateEquipmentWindow(inventory.items, OnSubmit, OnSelectSlot);
            }
        }
        void Start()
        {
            equipAreas = GetComponentsInChildren <vEquipArea>().vToList();
            foreach (vEquipArea area in equipAreas)
            {
                area.onPickUpItemCallBack = OnPickUpItemCallBack;
            }

            vInventory inventory = GetComponentInParent <vInventory>();

            if (inventory)
            {
                inventory.onOpenCloseInventory.AddListener(OnOpen);
            }
        }
        public virtual void OnEnable()
        {
            if (inventory == null)
            {
                inventory = GetComponentInParent <vInventory>();
            }

            if (inventory && itemWindow)
            {
                inventory.onDestroyItem.RemoveListener(OnDestroyItem);
                inventory.onDestroyItem.AddListener(OnDestroyItem);
                itemWindow.CreateEquipmentWindow(inventory.items, OnSubmit, OnSelectSlot);
                inventory.OnUpdateInventory -= CheckItemExits;
                inventory.OnUpdateInventory += CheckItemExits;
            }
        }
Exemple #11
0
        void Start()
        {
            inventory = GetComponentInParent <vInventory>();

            if (equipSlots.Count == 0)
            {
                var equipSlotsArray = GetComponentsInChildren <vEquipSlot>(true);
                equipSlots = equipSlotsArray.vToList();
            }
            rootWindow = GetComponentInParent <vInventoryWindow>();
            foreach (vEquipSlot slot in equipSlots)
            {
                slot.onSubmitSlotCallBack   = OnSubmitSlot;
                slot.onSelectSlotCallBack   = OnSelectSlot;
                slot.onDeselectSlotCallBack = OnDeselect;
                slot.amountText.text        = "";
            }
        }
        protected virtual IEnumerator Start()
        {
            inventory = getComponentsInParent ? GetComponentInParent <vInventory>() : GetComponent <vInventory>();
            if (!inventory)
            {
                yield return(new WaitForEndOfFrame());

                itemManager = getComponentsInParent ? GetComponentInParent <vItemManager>() : GetComponent <vItemManager>();
                if (itemManager)
                {
                    inventory = itemManager.inventory;
                }
            }

            if (inventory)
            {
                inventory.onOpenCloseInventory.AddListener(OpenCloseInventory);
            }
        }
        void OnEnable()
        {
            try
            {
                pop_ups = new List <vWindowPop_up>();
                if (inventory == null)
                {
                    inventory = GetComponentInParent <vInventory>();
                }

                if (lastSelected)
                {
                    StartCoroutine(SetSelectableHandle(lastSelected));
                }
                inventory.SetCurrentWindow(this);
                isOpen = true;
            }
            catch { }
        }
 void Start()
 {
     inventory = GetComponentInParent <vInventory>();
 }