Example #1
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");

            GUILayout.BeginVertical("ItemManager Creator Window", "window");
            EditorGUILayout.Space();
            EditorGUILayout.Space();
            EditorGUILayout.Space();
            EditorGUILayout.Space();

            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();
        }
Example #2
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);
                    }
                }
            }
        }
        public void OnEnable()
        {
            if (inventory == null)
            {
                inventory = GetComponentInParent <vInventory>();
            }

            if (inventory && itemWindow)
            {
                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);
            }
        }
Example #5
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        = "";
            }
        }
        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 { }
        }
Example #7
0
 void Start()
 {
     inventory = GetComponentInParent <vInventory>();
 }