コード例 #1
0
    void RefreshUI()
    {
        foreach (Transform child in ScrollContentView.transform)
        {
            Destroy(child.gameObject);
        }
        for (int i = 0; i < 2; i++)
        {
            if (SelectSkillPanel.transform.GetChild(i).childCount > 0)
            {
                Destroy(SelectSkillPanel.transform.GetChild(i).GetChild(0).gameObject);
            }
        }

        for (var i = 0; i < playerSkillList.Count; i++)
        {
            GameObject slot = Instantiate(slotPrefab, ScrollContentView.transform);
            skillImage  = slot.transform.GetChild(0).GetComponent <Image>();
            skillButton = slot.GetComponent <Button>();

            skillImage.sprite = SkillSystem.GetSkillImage(playerSkillList[i].id);
            skillButton.onClick.RemoveAllListeners();
            int index = i;
            skillButton.onClick.AddListener(delegate
            {
                OnSelectSkill(playerSkillList[index]);
            });
            if (SkillSystem.isPlayerSkillAble(playerSkillList[i].id))
            {
                skillButton.enabled = true;
                slot.transform.GetChild(2).gameObject.SetActive(false);
            }
            else
            {
                skillButton.enabled = false;
                slot.transform.GetChild(2).gameObject.SetActive(true);
            }
        }

        for (var i = 0; i < selectedSkillList.Count && i < 2; i++)
        {
            if (selectedSkillList[i] != null)
            {
                GameObject slot = Instantiate(slotPrefab, SelectSkillPanel.transform.GetChild(i).transform);
                slot.transform.localPosition = Vector3.zero;
                slot.GetComponent <RectTransform>().anchoredPosition = new Vector2(0.5f, 0.5f);
                skillImage  = slot.transform.GetChild(0).GetComponent <Image>();
                skillButton = slot.GetComponent <Button>();

                skillImage.sprite = SkillSystem.GetSkillImage(selectedSkillList[i].id);
                skillButton.onClick.RemoveAllListeners();
                int index = i;
                skillButton.onClick.AddListener(delegate
                {
                    OnCancleSelectedSkill(selectedSkillList[index]);
                });

                SelectSkillInformationPanel.transform.GetChild(i).gameObject.SetActive(true);
                SelectSkillInformationPanel.transform.GetChild(i).GetChild(0).GetComponent <Text>().text = SkillSystem.GetSkillName(selectedSkillList[i].id);
                SelectSkillInformationPanel.transform.GetChild(i).GetChild(1).GetComponent <Text>().text = SkillSystem.GetSkillDescription(selectedSkillList[i].id);
            }
        }
        for (var i = selectedSkillList.Count; i < SelectSkillInformationPanel.transform.childCount; i++)
        {
            SelectSkillInformationPanel.transform.GetChild(i).gameObject.SetActive(false);
        }
    }
コード例 #2
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);
                }
            }
        }
    }