Exemple #1
0
        private void SetSlot(UI_Container _container)
        {
            ClearSlot();

            DataArea db = Management.MenuGameManager.Instance.DataArea;

            // 덱이없다면 생성한다.(저장은 하지않는다.)
            if (db.OwnedData.DecData.Count <= curOwnedDecIndex)
            {
                decData = new SettingDecData(0, "새로운 덱 " + curOwnedDecIndex, new List <DecInfo>());
            }
            else
            {
                decData = new SettingDecData(db.OwnedData.DecData[curOwnedDecIndex]);
            }

            // 현재 뷰 타입에 맞게 슬롯을 생성
            int countMax = 0;

            if (curType == DecType.Minion)
            {
                countMax = db.OwnedData.MinionData.Count;
            }
            else
            {
                countMax = db.OwnedData.SkillData.Count;
            }

            for (int i = 0; i < countMax; ++i)
            {
                UI_SlotModule newSlot = Instantiate(slotPrefab, slotParent.transform).GetComponent <UI_SlotModule>();

                int    curDefaultIndex = -1;
                string imagePath       = string.Empty;
                string name            = string.Empty;
                string lv = string.Empty;
                if (curType == DecType.Minion)
                {
                    curDefaultIndex = db.OwnedData.MinionData[i].IndexOfMinion;
                    imagePath       = db.DefaultMinionData[curDefaultIndex].MainImagePath;
                    name            = db.DefaultMinionData[curDefaultIndex].MinionName;
                    lv = db.OwnedData.MinionData[i].Lv.ToString();
                }
                else
                {
                    curDefaultIndex = db.OwnedData.SkillData[i].IndexOfType;
                    imagePath       = db.DefaultSkillData[curDefaultIndex].MainImagePath;
                    name            = db.DefaultSkillData[curDefaultIndex].SkillName;
                    lv = db.OwnedData.SkillData[i].Lv.ToString();
                }

                newSlot.IndexOfViewType  = i;
                newSlot.IndexOfSlot      = i;
                newSlot.SlotImage.sprite = Resources.Load <Sprite>(imagePath);
                newSlot.nameText.text    = name;
                newSlot.lvText.text      = lv;

                if (SearchSame(i) != null)
                {
                    newSlot.selectedImage.SetActive(true);
                }


                if (newSlot.clickFunc == null)
                {
                    newSlot.clickFunc = () => { SelectSlot(newSlot.IndexOfViewType); }
                }
                ;

                //EventTrigger.Entry entry = new EventTrigger.Entry();
                //entry.eventID = EventTriggerType.PointerDown;
                //entry.callback.AddListener((eventData)=> { SelectSlot(newSlot.IndexOfViewType); });
                //newSlot.EventTrigger.triggers.Add(entry);

                slotList.Add(newSlot);
            }
        }
        public override void SetUI(UI_Container _container)
        {
            curSelectedCount = selectMatList.Count;
            DataArea db        = Management.MenuGameManager.Instance.DataArea;
            int      slotIndex = 0;
            int      count     = 0;

            switch (curViewType)
            {
            case ViewType.Minion:
                count = db.OwnedData.MinionData.Count;
                break;

            case ViewType.Item:
                count = db.OwnedData.ItemData.Count;
                break;

            case ViewType.Skill:
                count = db.OwnedData.SkillData.Count;
                break;
            }
            for (int i = 0; i < count; ++i)
            {
                if (curType == StrengthSubType.Material && i == targetIndex)
                {
                    continue;
                }

                if (curType == StrengthSubType.Target && prevSelectMatList.Contains(i))
                {
                    continue;
                }
                UI_SlotModule newSlot = null;
                switch (curViewType)
                {
                case ViewType.Minion:
                    newSlot = Instantiate(slotPrefab, slotParent.transform).GetComponent <UI_SlotModule>();
                    newSlot.nameText.text    = db.DefaultMinionData[db.OwnedData.MinionData[i].IndexOfMinion].MinionName;
                    newSlot.lvText.text      = db.OwnedData.MinionData[i].Lv.ToString();
                    newSlot.SlotImage.sprite = Resources.Load <Sprite>(db.DefaultMinionData[db.OwnedData.MinionData[i].IndexOfMinion].MainImagePath);

                    break;

                case ViewType.Item:
                    if (curType == StrengthSubType.Material && db.OwnedData.ItemData[i].UseItem)
                    {
                        continue;
                    }
                    newSlot = Instantiate(slotPrefab, slotParent.transform).GetComponent <UI_SlotModule>();
                    newSlot.nameText.text    = db.DefaultItemData[db.OwnedData.ItemData[i].IndexOfType].ItemName;
                    newSlot.lvText.text      = db.OwnedData.ItemData[i].Lv.ToString();
                    newSlot.SlotImage.sprite = Resources.Load <Sprite>(db.DefaultItemData[db.OwnedData.ItemData[i].IndexOfType].IconPath);

                    break;

                case ViewType.Skill:
                    newSlot = Instantiate(slotPrefab, slotParent.transform).GetComponent <UI_SlotModule>();
                    newSlot.nameText.text    = db.DefaultSkillData[db.OwnedData.SkillData[i].IndexOfType].SkillName;
                    newSlot.lvText.text      = db.OwnedData.SkillData[i].Lv.ToString();
                    newSlot.SlotImage.sprite = Resources.Load <Sprite>(db.DefaultSkillData[db.OwnedData.SkillData[i].IndexOfType].MainImagePath);

                    break;
                }
                newSlot.IndexOfSlot     = slotIndex++;
                newSlot.IndexOfViewType = i;
                //EventTrigger.Entry entry = new EventTrigger.Entry();
                //entry.eventID = EventTriggerType.PointerDown;
                //entry.callback.AddListener((eventData)=> { SelectMat(newSlot.IndexOfSlot, newSlot.IndexOfViewType); });
                //newSlot.EventTrigger.triggers.Add(entry);
                if (newSlot.clickFunc == null)
                {
                    newSlot.clickFunc = () => { SelectMat(newSlot.IndexOfSlot, newSlot.IndexOfViewType); }
                }
                ;


                if (curType == StrengthSubType.Target && targetIndex == i)
                {
                    newSlot.selectedImage.SetActive(true);
                    ++curSelectedCount;
                    selectMatList.Add(i);
                }
                if (prevSelectMatList != null && prevSelectMatList.Contains(newSlot.IndexOfViewType))
                {
                    newSlot.selectedImage.SetActive(true);
                }

                slotList.Add(newSlot);
            }

            if (closeButton.triggers.Count <= 0)
            {
                EventTrigger.Entry entry = new EventTrigger.Entry();
                entry.eventID = EventTriggerType.PointerUp;
                entry.callback.AddListener((eventData) => { CloseButtonClick(_container, closeModuleIndex); });

                closeButton.triggers.Add(entry);
            }
        }
Exemple #3
0
        public override void SetUI(UI_Container _container)
        {
            curSelectSlot = -1;

            DataArea db             = Management.MenuGameManager.Instance.DataArea;
            int      ownedItemCount = db.OwnedData.ItemData.Count;
            int      curSlotIndex   = 0;

            for (int i = 0; i < ownedItemCount; ++i)
            {
                if (db.OwnedData.ItemData[i].UseItem && db.OwnedData.ItemData[i].OwnerMinionIndexOfSerializeCode != db.OwnedData.MinionData[curOwnerMinionIndex].IndexOfSerializeCode)
                {
                    continue;
                }


                var slot = Instantiate(slotPrefab, slotParent.transform).GetComponent <UI_SlotModule>();

                slot.IndexOfSlot      = curSlotIndex;
                slot.IndexOfViewType  = i;
                slot.nameText.text    = db.DefaultItemData[db.OwnedData.ItemData[i].IndexOfType].ItemName;
                slot.lvText.text      = db.OwnedData.ItemData[i].Lv.ToString();
                slot.SlotImage.sprite = Resources.Load <Sprite>(db.DefaultItemData[db.OwnedData.ItemData[i].IndexOfType].IconPath);


                if (slot.clickFunc == null)
                {
                    slot.clickFunc = () => { SelectSlot(slot.IndexOfSlot); }
                }
                ;

                //EventTrigger.Entry entry = new EventTrigger.Entry();
                //entry.eventID = EventTriggerType.PointerDown;
                //entry.callback.AddListener((eventData)=> { SelectSlot(slot.IndexOfSlot); });
                //slot.EventTrigger.triggers.Add(entry);

                slotList.Add(slot);
                if (db.OwnedData.ItemData[i].UseItem && db.OwnedData.ItemData[i].OwnerMinionIndexOfSerializeCode == db.OwnedData.MinionData[curOwnerMinionIndex].IndexOfSerializeCode)
                {
                    SelectSlot(curSlotIndex);
                }
                ++curSlotIndex;
            }

            if (closeButton.clickedFunc == null)
            {
                closeButton.clickedFunc = () => { CloseButton(_container); }
            }
            ;
        }

        void ClearList()
        {
            while (slotList.Count > 0)
            {
                UI_SlotModule slot = slotList[0];
                DestroyImmediate(slot.gameObject);
                slotList.RemoveAt(0);
            }
            slotList.Clear();
        }