Пример #1
0
        public void ShowGUI(InventoryManager inventoryManager)
        {
            EditorGUILayout.BeginHorizontal();
            EditorGUILayout.LabelField("Item name:", GUILayout.Width(80f));

            string itemName = inventoryManager.GetLabel(linkedID);

            if (string.IsNullOrEmpty(itemName))
            {
                itemName = "(Missing)";
            }
            else
            {
                itemName = "'" + itemName + "'";
            }

            InvItem linkedItem = inventoryManager.GetItem(linkedID);

            if (linkedItem != null && linkedItem.canCarryMultiple)
            {
                EditorGUILayout.LabelField(itemName, EditorStyles.boldLabel, GUILayout.Width(135f));

                EditorGUILayout.LabelField("Count:", GUILayout.Width(50f));
                count = EditorGUILayout.IntField(count, GUILayout.Width(44f));
                if (count <= 0)
                {
                    count = 1;
                }
            }
            else
            {
                EditorGUILayout.LabelField(itemName, EditorStyles.boldLabel);
                count = 1;
            }
        }
        public void ShowGUI()
        {
            SettingsManager settingsManager = KickStarter.settingsManager;

            if (settingsManager == null)
            {
                EditorGUILayout.HelpBox("A Settings Manager must be assigned in the AC Game Window.", MessageType.Warning);
                return;
            }

            InventoryManager inventoryManager = KickStarter.inventoryManager;

            if (inventoryManager == null)
            {
                EditorGUILayout.HelpBox("An Inventory Manager must be assigned in the AC Game Window.", MessageType.Warning);
                return;
            }

            List <string> itemList  = new List <string>();
            int           itemIndex = 0;

            if (inventoryManager.items.Count > 0)
            {
                for (int i = 0; i < inventoryManager.items.Count; i++)
                {
                    itemList.Add(inventoryManager.items[i].label);
                    if (inventoryManager.items[i].id == itemID)
                    {
                        itemIndex = i;
                    }
                }
            }

            if (itemList.Count == 0)
            {
                EditorGUILayout.HelpBox("No inventory items found!", MessageType.Warning);
                return;
            }

            itemIndex = EditorGUILayout.Popup("Inventory item:", itemIndex, itemList.ToArray());

            if (itemIndex >= inventoryManager.items.Count)
            {
                return;
            }

            itemID = inventoryManager.items[itemIndex].id;

            InvItem item = inventoryManager.GetItem(itemID);

            if (item != null)
            {
                if (settingsManager.interactionMethod != AC_InteractionMethod.ContextSensitive && settingsManager.inventoryInteractions == InventoryInteractions.Multiple)
                {
                    // Standard interactions

                    CursorManager cursorManager = KickStarter.cursorManager;
                    if (cursorManager == null)
                    {
                        EditorGUILayout.HelpBox("A Cursor Manager must be assigned in the AC Game Window.", MessageType.Warning);
                        return;
                    }

                    List <string> iconList = new List <string>();
                    foreach (CursorIcon icon in cursorManager.cursorIcons)
                    {
                        iconList.Add(icon.label);
                    }

                    List <string> interactionList = new List <string>();
                    for (int i = 0; i < item.interactions.Count; i++)
                    {
                        int    iconID = item.interactions[i].icon.id;
                        int    index  = GetIconSlot(iconID, cursorManager.cursorIcons.ToArray());
                        string label  = i.ToString() + ": " + cursorManager.cursorIcons[index].label;
                        if (string.IsNullOrEmpty(label))
                        {
                            label = i.ToString() + ": Unnamed";
                        }
                        interactionList.Add(label);
                    }

                    if (interactionList.Count == 0)
                    {
                        EditorGUILayout.HelpBox("No standard interactions found!", MessageType.Warning);
                        return;
                    }

                    cursorIndex = EditorGUILayout.Popup("Interaction:", cursorIndex, interactionList.ToArray());
                    ShowParametersGUI(item.interactions[cursorIndex].actionList);
                }
                else
                {
                    interactionType = (InteractionType)EditorGUILayout.EnumPopup("Interaction type:", interactionType);
                    switch (interactionType)
                    {
                    case InteractionType.Use:
                        ShowParametersGUI(item.useActionList);
                        break;

                    case InteractionType.Examine:
                        ShowParametersGUI(item.lookActionList);
                        break;
                    }
                }
            }
        }
Пример #3
0
        public override void OnInspectorGUI()
        {
            if (_target == null)
            {
                OnEnable();
                return;
            }

            inventoryManager = AdvGame.GetReferences().inventoryManager;

            ShowCategoriesUI(_target);
            EditorGUILayout.Space();

            EditorGUILayout.LabelField("Stored Inventory items", EditorStyles.boldLabel);
            if (Application.isPlaying)
            {
                if (_target.InvCollection.InvInstances.Count > 0)
                {
                    CustomGUILayout.BeginVertical();
                    foreach (InvInstance invInstance in _target.InvCollection.InvInstances)
                    {
                        if (!InvInstance.IsValid(invInstance))
                        {
                            continue;
                        }

                        EditorGUILayout.BeginHorizontal();

                        if (invInstance.InvItem.canCarryMultiple)
                        {
                            EditorGUILayout.LabelField(invInstance.InvItem.label, EditorStyles.boldLabel, GUILayout.Width(235f));
                            EditorGUILayout.LabelField("Count: " + invInstance.Count.ToString());
                        }
                        else
                        {
                            EditorGUILayout.LabelField(invInstance.InvItem.label, EditorStyles.boldLabel);
                        }

                        EditorGUILayout.EndHorizontal();

                        CustomGUILayout.DrawUILine();
                    }
                    CustomGUILayout.EndVertical();
                }
                else
                {
                    EditorGUILayout.HelpBox("This Container has no items", MessageType.Info);
                }
            }
            else
            {
                if (_target.items.Count > 0)
                {
                    CustomGUILayout.BeginVertical();
                    for (int i = 0; i < _target.items.Count; i++)
                    {
                        _target.items[i].ShowGUI(inventoryManager);

                        if (GUILayout.Button(string.Empty, CustomStyles.IconCog))
                        {
                            SideMenu(_target.items[i]);
                        }

                        EditorGUILayout.EndHorizontal();

                        if (_target.limitToCategory && _target.categoryIDs != null && _target.categoryIDs.Count > 0)
                        {
                            InvItem listedItem = inventoryManager.GetItem(_target.items[i].ItemID);
                            if (listedItem != null && !_target.categoryIDs.Contains(listedItem.binID))
                            {
                                EditorGUILayout.HelpBox("This item is not in the categories checked above and will not be displayed.", MessageType.Warning);
                            }
                        }

                        CustomGUILayout.DrawUILine();
                    }
                    CustomGUILayout.EndVertical();
                }
                else
                {
                    EditorGUILayout.HelpBox("This Container has no items", MessageType.Info);
                }
            }

            EditorGUILayout.Space();

            EditorGUILayout.BeginHorizontal();
            EditorGUILayout.LabelField("New item to store:", GUILayout.MaxWidth(130f));
            itemNumber = EditorGUILayout.Popup(itemNumber, CreateItemList());
            if (GUILayout.Button("Add new item"))
            {
                _target.items.Add(new ContainerItem(CreateItemID(itemNumber), _target.items.ToArray()));
            }
            EditorGUILayout.EndHorizontal();

            if (_target.maxSlots > 0 && _target.items.Count > _target.maxSlots)
            {
                EditorGUILayout.HelpBox("The Container is full! Excess slots will be discarded.", MessageType.Warning);
            }

            UnityVersionHandler.CustomSetDirty(_target);
        }
        public override void OnInspectorGUI()
        {
            if (_target == null || inventoryManager == null)
            {
                OnEnable();
                return;
            }

            ShowCategoriesUI(_target);
            EditorGUILayout.Space();

            EditorGUILayout.LabelField("Stored Inventory items", EditorStyles.boldLabel);
            if (_target.items.Count > 0)
            {
                EditorGUILayout.BeginVertical("Button");
                for (int i = 0; i < _target.items.Count; i++)
                {
                    EditorGUILayout.BeginHorizontal();
                    EditorGUILayout.LabelField("Item name:", GUILayout.Width(80f));
                    if (inventoryManager.CanCarryMultiple(_target.items[i].linkedID))
                    {
                        EditorGUILayout.LabelField(inventoryManager.GetLabel(_target.items[i].linkedID), EditorStyles.boldLabel, GUILayout.Width(135f));
                        EditorGUILayout.LabelField("Count:", GUILayout.Width(50f));
                        _target.items[i].count = EditorGUILayout.IntField(_target.items[i].count, GUILayout.Width(44f));
                    }
                    else
                    {
                        EditorGUILayout.LabelField(inventoryManager.GetLabel(_target.items[i].linkedID), EditorStyles.boldLabel);
                        _target.items[i].count = 1;
                    }

                    if (GUILayout.Button(Resource.CogIcon, GUILayout.Width(20f), GUILayout.Height(15f)))
                    {
                        SideMenu(_target.items[i]);
                    }

                    EditorGUILayout.EndHorizontal();

                    if (_target.limitToCategory && _target.categoryIDs != null && _target.categoryIDs.Count > 0)
                    {
                        InvItem listedItem = inventoryManager.GetItem(_target.items[i].linkedID);
                        if (listedItem != null && !_target.categoryIDs.Contains(listedItem.binID))
                        {
                            EditorGUILayout.HelpBox("This item is not in the categories checked above and will not be displayed.", MessageType.Warning);
                        }
                    }

                    GUILayout.Box("", GUILayout.ExpandWidth(true), GUILayout.Height(1));
                }
                EditorGUILayout.EndVertical();
            }
            else
            {
                EditorGUILayout.HelpBox("This Container has no items", MessageType.Info);
            }

            EditorGUILayout.Space();

            EditorGUILayout.BeginHorizontal();
            EditorGUILayout.LabelField("Item to create:", GUILayout.MaxWidth(130f));
            itemNumber = EditorGUILayout.Popup(itemNumber, CreateItemList());
            if (GUILayout.Button("Add new item"))
            {
                ContainerItem newItem = new ContainerItem(CreateItemID(itemNumber), _target.GetIDArray());
                _target.items.Add(newItem);
            }
            EditorGUILayout.EndHorizontal();
            EditorGUILayout.Space();

            UnityVersionHandler.CustomSetDirty(_target);
        }