public void OpenUI(HeroData data)
    {
        heroData    = data;
        showHeroObj = Instantiate(PrefabsDatabaseManager.instance.GetHeroPrefab(heroData.id), ShowPoint.transform);
        showHeroObj.transform.localScale    = new Vector3(200, 200, 200);
        showHeroObj.transform.localPosition = Vector3.zero;

        if (showHeroObj.GetComponent <Hero>() != null)
        {
            Destroy(showHeroObj.GetComponent <Hero>());
        }
        if (showHeroObj.GetComponent <Rigidbody2D>() != null)
        {
            Destroy(showHeroObj.GetComponent <Rigidbody2D>());
        }
        foreach (var sp in showHeroObj.GetComponentsInChildren <SpriteRenderer>())
        {
            sp.sortingLayerName = "ShowObject";
            sp.gameObject.layer = 16;
        }
        showHeroObj.gameObject.SetActive(true);

        nameText.text        = HeroSystem.GetHeroName(data.id);
        descriptionText.text = HeroSystem.GetHeroDescription(data.id);

        //Status 정보
        if (statusInfoPanel != null)
        {
            statusInfoPanel.transform.GetChild(0).GetComponentInChildren <Text>().text = HeroSystem.GetHeroStatusAttack(ref heroData).ToString();
            statusInfoPanel.transform.GetChild(1).GetComponentInChildren <Text>().text = HeroSystem.GetHeroStatusDefence(ref heroData).ToString();
            statusInfoPanel.transform.GetChild(2).GetComponentInChildren <Text>().text = HeroSystem.GetHeroStatusMaxHp(ref heroData).ToString();
            statusInfoPanel.transform.GetChild(3).GetComponentInChildren <Text>().text = HeroSystem.GetHeroStatusCriticalPercent(ref heroData).ToString();
            statusInfoPanel.transform.GetChild(4).GetComponentInChildren <Text>().text = HeroSystem.GetHeroStatusAttackSpeed(ref heroData).ToString();
            statusInfoPanel.transform.GetChild(5).GetComponentInChildren <Text>().text = HeroSystem.GetHeroStatusMoveSpeed(ref heroData).ToString();
            statusInfoPanel.transform.GetChild(6).GetComponentInChildren <Text>().text = HeroSystem.GetHeroStatusKnockbackResist(ref heroData).ToString("N1");
            statusInfoPanel.transform.GetChild(7).GetComponentInChildren <Text>().text = HeroSystem.GetHeroStatusSkillEnergy(ref heroData).ToString();
        }

        // 스킬정보
        Skill heroSkill = SkillSystem.GetSkill(heroData.skill);

        if (skillInfoPanel != null && heroSkill != null)
        {
            var skillImage = skillInfoPanel.transform.GetChild(0).GetChild(0).GetComponent <Image>();
            skillImage.sprite = SkillSystem.GetSkillImage(heroSkill.id);
            skillInfoPanel.transform.GetComponentInChildren <Text>().text = string.Format("<size='27'>{0} : {1}  {2}</size>\r\n\r\n<color='grey'>{3}</color>", LocalizationManager.GetText("SkillLevel"), 1, SkillSystem.GetSkillName(heroSkill.id), SkillSystem.GetSkillDescription(heroSkill.id));
        }
    }
Exemple #2
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);
        }
    }