예제 #1
0
    void RefreshUI()
    {
        if (ScrollContentView != null)
        {
            foreach (Transform child in ScrollContentView.transform)
            {
                Destroy(child.gameObject);
            }

            playerSkillList.Clear();
            playerSkillList = SkillSystem.GetPlayerSkillList();

            for (var i = 0; i < playerSkillList.Count; i++)
            {
                GameObject slot = Instantiate(slotPrefab, ScrollContentView.transform);
                skillImage           = slot.transform.GetChild(0).GetChild(0).GetComponent <Image>();
                skillDescriptionText = slot.transform.GetChild(1).GetComponent <Text>();
                skillUpgradeButton   = slot.transform.GetComponentInChildren <Button>();
                skillNeedCrystalText = skillUpgradeButton.GetComponentInChildren <Text>();


                skillImage.sprite         = SkillSystem.GetSkillImage(playerSkillList[i].id);
                skillDescriptionText.text = SkillSystem.GetPlayerSkillDescription(playerSkillList[i]);

                int upgradePayment = 100;
                skillNeedCrystalText.text = Common.GetThousandCommaText(upgradePayment);
                skillUpgradeButton.onClick.RemoveAllListeners();
                int index = i;
                skillUpgradeButton.onClick.AddListener(delegate
                {
                    OnClickSkillUpgrate(index, playerSkillList[index].id, upgradePayment);
                });
                if (Common.PaymentAbleCheck(ref User.blackCrystal, upgradePayment))
                {
                    skillUpgradeButton.enabled = true;
                }
                else
                {
                    skillUpgradeButton.enabled = false;
                }

                if (SkillSystem.isPlayerSkillAble(playerSkillList[i].id))
                {
                    slot.transform.GetChild(3).gameObject.SetActive(false);
                    if (SkillSystem.isPlayerSkillUpgradeAble(playerSkillList[i].id))
                    {
                        skillUpgradeButton.enabled = true;
                        skillUpgradeButton.transform.GetChild(2).gameObject.SetActive(false);
                    }
                    else
                    {
                        skillUpgradeButton.enabled = false;
                        skillUpgradeButton.transform.GetChild(2).gameObject.SetActive(true);
                        skillUpgradeButton.transform.GetChild(2).GetComponentInChildren <Text>().text = string.Format("! {0} : {1}", LocalizationManager.GetText("UserLevel"), SkillSystem.GetUserSkillLevel(playerSkillList[i].id) + 1);
                    }
                }
                else
                {
                    slot.transform.GetChild(3).gameObject.SetActive(true);
                    slot.transform.GetChild(3).GetComponentInChildren <Text>().text = string.Format("! {0} : {1}", LocalizationManager.GetText("UnlockLevel"), playerSkillList[i].level);
                }
            }
        }
    }