Пример #1
0
        public void SetDec()
        {
            ClearSlot();

            // dec Setting
            int      maxDec   = (int)DecMax.OwnedMax;
            DataArea db       = Management.MenuGameManager.Instance.DataArea;
            int      decIndex = db.LoginData.Free_DecSlotCount + db.LoginData.Event_DecSlotCount + db.LoginData.Pay_DecSlotCount;

            for (int i = 0; i < maxDec; ++i)
            {
                UI_DecSlotModule newDecSlot = Instantiate(slotPrefab, slotParent.transform).GetComponent <UI_DecSlotModule>();

                newDecSlot.indexOfSlot = i;

                decList.Add(newDecSlot);

                // 소유 가능한 덱보다 작으면 세팅
                if (i >= decIndex)
                {
                    continue;
                }

                Sprite image   = null;
                string decName = "덱을 세팅하세요";
                // slot Setting
                // 세팅된 덱의 데이터 가 있다면 세팅
                if (db.OwnedData.DecData.Count > i)
                {
                    newDecSlot.indexOfType = i;
                    int     unitIndex = db.OwnedData.DecData[i].decList[0].ownedIndex;
                    DecType type      = db.OwnedData.DecData[i].decList[0].type;
                    string  path      = "";
                    if (type == DecType.Minion)
                    {
                        path = db.DefaultMinionData[db.OwnedData.MinionData[unitIndex].IndexOfMinion].MainImagePath;
                    }
                    else
                    {
                        path = db.DefaultSkillData[db.OwnedData.SkillData[unitIndex].IndexOfType].MainImagePath;
                    }
                    image   = Resources.Load <Sprite>(path);
                    decName = db.OwnedData.DecData[i].decName;
                    newDecSlot.decCountText.text = db.OwnedData.DecData[i].decCount + "/" + (int)DecMax.UnitMax;
                }

                newDecSlot.decNameText.text = decName;
                newDecSlot.slotImage.sprite = image;

                // trigger set
                if (newDecSlot.clickFunc == null)
                {
                    newDecSlot.clickFunc = () => { ClickedButton(ownerContainer, openSubContainerModuleIndex, new OpenSubContainerData(openSubContainerModuleIndex, newDecSlot.indexOfSlot)); };
                }
            }
        }
        public override void SetUI(UI_Container _container)
        {
            ClearSlot();

            DataArea db = Management.MenuGameManager.Instance.DataArea;

            // set background image
            backgroundImage.sprite = backgroundSprite;

            // set scroll background image
            scrollBackgroundImage.sprite = scrollBackgroundSprite;

            // set dec slot
            int curDecIndex = 0;
            int decIndex    = db.LoginData.Free_DecSlotCount + db.LoginData.Event_DecSlotCount + db.LoginData.Pay_DecSlotCount;

            for (int i = 0; i < decIndex; ++i)
            {
                if (db.OwnedData.DecData.Count <= i)
                {
                    break;
                }
                UI_DecSlotModule newDecSlot = Instantiate(slotPrefab, slotParent.transform).GetComponent <UI_DecSlotModule>();

                newDecSlot.indexOfSlot = i;

                decList.Add(newDecSlot);

                Sprite image   = null;
                string decName = "덱을 세팅하세요";
                // slot Setting
                // 세팅된 덱의 데이터 가 있다면 세팅
                newDecSlot.indexOfType = i;
                int     unitIndex = db.OwnedData.DecData[i].decList[0].ownedIndex;
                DecType type      = db.OwnedData.DecData[i].decList[0].type;
                string  path      = "";
                if (type == DecType.Minion)
                {
                    path = db.DefaultMinionData[db.OwnedData.MinionData[unitIndex].IndexOfMinion].MainImagePath;
                }
                else
                {
                    path = db.DefaultSkillData[db.OwnedData.SkillData[unitIndex].IndexOfType].MainImagePath;
                }
                image   = Resources.Load <Sprite>(path);
                decName = db.OwnedData.DecData[i].decName;
                newDecSlot.decCountText.text = db.OwnedData.DecData[i].decCount + "/" + (int)DecMax.UnitMax;

                newDecSlot.decNameText.text = decName;
                newDecSlot.slotImage.sprite = image;

                // trigger set
                if (newDecSlot.clickFunc == null)
                {
                    newDecSlot.clickFunc = () => { SelectDecSlot(newDecSlot.indexOfSlot); };
                }
            }

            // set buttons function
            if (closeButton.clickedFunc == null)
            {
                closeButton.clickedFunc = () => { ClickedButton(_container, indexOfCloseModule); }
            }
            ;
            if (startBattleButton.clickedFunc == null)
            {
                startBattleButton.clickedFunc = () => { ClickedButton(_container, indexOfStartBattleButton); };
                Debug.LogError("게임시작할때 보낼 데이터를 세팅해줘!!!!!!!!!!!");
            }
        }