コード例 #1
0
        protected ItemSlotManager CreateManager(ItemSlot slot)
        {
            ItemSlotManager clone = Instantiate(SlotPrefab, slotHolder);

            clone.transform.localRotation = Quaternion.identity;
            clone.transform.localScale    = Vector3.one;
            clone.GetComponent <RectTransform> ().anchoredPosition3D = Vector3.zero;

            clone.Setup(slot);
            managers.Add(clone);

            OnSlotAdd(clone);

            return(clone);
        }
コード例 #2
0
ファイル: EquipmentBinder.cs プロジェクト: xJayLee/RPGCore
        public void FireSetup()
        {
            if (!setup)
            {
                manager.Setup(character.equipment.Items[EquipmentSlot.Index]);

                if (selector != null)
                {
                    manager.onMainAction += () =>
                    {
                        /*selector.DisplaySelector (manager.slot, (ItemSlot returnedSlot) =>
                         * {
                         *      manager.slot.Swap (returnedSlot);
                         * });*/
                    };
                }
                setup = true;
            }
        }
コード例 #3
0
        public override void Setup(Inventory inventory)
        {
            if (current != null)
            {
                return;
            }

            current = inventory;

            managers = new List <ItemSlotManager> (current.Size);

            for (int i = 0; i < current.Items.Count; i++)
            {
                ItemSlot        slot    = current.Items[i];
                ItemSlotManager manager = Slots[i];

                manager.Setup(slot);
                OnSlotAdd(manager);
            }
        }
コード例 #4
0
ファイル: EquipmentBinder.cs プロジェクト: gkjolin/RPGCore
        public void FireSetup()
        {
            if (!setup)
            {
#pragma warning disable
                var entry = EquipmentInformationDatabase.Instance.EquipmentInfos[EquipmentSlot];
#pragma warning restore

                manager.Setup(character.equipment.Items[EquipmentSlot.entryIndex]);

                if (selector != null)
                {
                    manager.onMainAction += () =>
                    {
                        /*selector.DisplaySelector (manager.slot, (ItemSlot returnedSlot) =>
                         * {
                         *      manager.slot.Swap (returnedSlot);
                         * });*/
                    };
                }
                setup = true;
            }
        }
コード例 #5
0
        public void Filter(SortingMode mode, ItemCondition[] Filters)
        {
            lastSorting = mode;
            LastFilters = Filters;

            sorted = new List <ItemSlot> ();

            for (int i = 0; i < current.Items.Count; i++)
            {
                ItemSlot slot = current.Items[i];

                if (HideEmpty && slot.Item == null)
                {
                    continue;
                }

                if (Filters == null)
                {
                    sorted.Add(slot);
                    continue;
                }

                if (Filters.IsValid(slot.Item))
                {
                    sorted.Add(slot);
                }
            }

            if (mode == SortingMode.Name)
            {
                sorted.Sort(NameComparison);
            }
            else if (mode == SortingMode.Type)
            {
                sorted.Sort(TypeComparison);
            }

            for (int i = 0; i < managers.Count; i++)
            {
                ItemSlotManager manager = managers[i];

                if (EventSystem.current.currentSelectedGameObject == manager.gameObject)
                {
                    EventSystem.current.SetSelectedGameObject(null);
                }
                manager.Detatch();
                manager.gameObject.SetActive(false);
            }

            for (int i = 0; i < sorted.Count; i++)
            {
                ItemSlotManager manager = managers[i];

                manager.gameObject.SetActive(true);

                manager.Setup(sorted[i]);

                /*if (i == 0)
                 * {
                 * EventSystem.current.SetSelectedGameObject(manager.gameObject);
                 * var pointer = new PointerEventData(EventSystem.current);
                 * //ExecuteEvents.Execute(manager.gameObject, pointer, ExecuteEvents.pointerEnterHandler);
                 * //ExecuteEvents.Execute(manager.gameObject, pointer, ExecuteEvents.selectHandler);
                 * }*/
            }

            filterDirty = false;
        }