Exemplo n.º 1
0
        // Use this for initialization
        public bool Init()
        {
            lbDesp.text = null;

            SetPlayer(GameControl.GetPlayer());

            if (progress == null || playerPerk == null)
            {
                return(false);
            }

            if (progress != null)
            {
                List <PerkUnlockingAtLevel> unlockList = progress.stats.perkUnlockingAtLevelList;

                int count = 0;

                for (int i = 0; i < unlockList.Count; i++)
                {
                    int level = unlockList[i].level;
                    for (int n = 0; n < unlockList[i].perkIDList.Count; n++)
                    {
                        if (count == 0)
                        {
                            itemList[0].Init();
                        }
                        else if (count > 0)
                        {
                            itemList.Add(UIPerkItem.Clone(itemList[0].rootObj, "Item" + (i + 1)));
                        }

                        int  perkIndex = playerPerk.GetPerkIndex(unlockList[i].perkIDList[n]);
                        Perk perk      = playerPerk.GetPerkFromIndex(perkIndex);

                        itemList[i].perkID = perkIndex;

                        itemList[i].imgIcon.sprite = perk.icon;
                        itemList[i].label.text     = perk.name;
                        itemList[i].labelAlt.text  = "- Unlocked at level " + level;
                        itemList[i].purchasedHighlight.SetActive(perk.purchased > 0);

                        itemList[i].SetCallback(this.OnHoverItem, this.OnExitItem, null, null);

                        count += 1;
                    }
                }

                Debug.Log(itemList[0].rectT + "  " + unlockList.Count);
                contentRect           = itemList[0].rectT.parent.GetComponent <RectTransform>();
                contentRect.sizeDelta = new Vector2(contentRect.sizeDelta.x, itemList.Count * 55 + 5);
            }

            if (progress == null || playerPerk == null)
            {
                return(false);
            }

            return(true);
        }
Exemplo n.º 2
0
        public void Init()
        {
            SetPlayer(GameControl.GetPlayer());

            if (!manualSetup)
            {
                layoutGroup.enabled = true;

                int count = 0;

                List <Perk> perkList = playerPerk.GetPerkList();
                for (int i = 0; i < perkList.Count; i++)
                {
                    if (unAvaiPerkIDList.Contains(perkList[i].ID))
                    {
                        continue;
                    }

                    if (count == 0)
                    {
                        perkItemList[0].Init();
                    }
                    else if (count > 0)
                    {
                        perkItemList.Add(UIPerkItem.Clone(perkItemList[0].rootObj, "PerkButton" + (count + 1)));
                    }

                    perkItemList[count].imgIcon.sprite = perkList[i].icon;
                    perkItemList[count].perkID         = perkList[i].ID;
                    perkItemList[count].selectHighlight.SetActive(count == 0);

                    perkItemList[count].SetCallback(null, null, this.OnPerkItem, null);

                    count += 1;
                }

                UpdateContentRectSize();
            }
            else
            {
                for (int i = 0; i < perkItemList.Count; i++)
                {
                    perkItemList[i].Init();
                    perkItemList[i].selectHighlight.SetActive(i == 0);
                    perkItemList[i].SetCallback(null, null, this.OnPerkItem, null);
                }
            }

            butPurchase.Init();
            if (butClose.rootObj != null)
            {
                butClose.Init();
            }

            UpdatePerkItemList();
            UpdateDisplay();
        }
Exemplo n.º 3
0
        // Use this for initialization
        public void Init()
        {
            SetPlayer(GameControl.GetPlayer());


            if (playerPerk != null)
            {
                List <Perk> perkList = playerPerk.GetPerkList();

                int count = 0;

                for (int i = 0; i < perkIDList.Count; i++)
                {
                    for (int n = 0; n < perkList.Count; n++)
                    {
                        if (perkList[n].ID != perkIDList[i])
                        {
                            continue;
                        }

                        Perk perk = perkList[n];

                        if (count == 0)
                        {
                            itemList[0].Init();
                        }
                        else if (count > 0)
                        {
                            itemList.Add(UIPerkItem.Clone(itemList[0].rootObj, "Item" + (i + 1)));
                        }

                        itemList[i].perkID = n;                                 //perk index in perkList

                        itemList[i].imgIcon.sprite = perk.icon;
                        itemList[i].label.text     = perk.name;

                        //if(showCost) itemList[i].labelAlt2.text=perk.cost.ToString();
                        //else itemList[i].labelAlt2.text="";

                        //itemList[i].labelAlt.text=perk.purchased+"/"+perk.limit;

                        itemList[i].SetCallback(this.OnHoverItem, this.OnExitItem, null, null);

                        foreach (Transform child in itemList[i].rootObj.transform)
                        {
                            if (child.name == "ButtonUnlock")
                            {
                                UIButton button = new UIButton(child.gameObject);
                                button.SetCallback(this.OnHoverButton, this.OnExitButton, this.OnUnlockButton, null);
                                unlockButtonList.Add(button);
                            }
                        }

                        count += 1;

                        break;
                    }
                }
            }

            if (perkIDList.Count == 0)
            {
                if (itemList.Count > 0)
                {
                    for (int i = 0; i < itemList.Count; i++)
                    {
                        if (itemList[i].rootObj != null)
                        {
                            itemList[i].rootObj.SetActive(false);
                        }
                    }
                }
                itemList = new List <UIPerkItem>();
            }

            UpdateDisplay();

            lbDesp.text = "";
        }