Ejemplo n.º 1
0
    /// <summary>
    /// 刷新技能说明处显示信息;
    /// </summary>
    void UpdateDetails(bool needTypeWriterEffect)
    {
        SkillLearnTableItem learnItem = MySkillModule.GetDetailBySkillId(CurSkillId);

        if (learnItem == null)
        {
            return;
        }

        SkillLevelTableItem levelItem = null;
        int levelId = 0;

        int lv = MySkillModule.GetSkillLvBySkillID(CurSkillId);

        if (lv < 0)
        {
            return;
        }

        skillName.text = learnItem.skill_name;

        if (lv == 0)                                //锁定状态/可解锁状态;
        {
            if (!MySkillModule.canOpen(CurSkillId)) //锁定;
            {
                skillLV.text = StringHelper.StringWithColor(FontColor.Red, "未解锁");
            }
            else
            {
                skillLV.text = "[079d6a]可解锁[-]";
            }

            levelId   = SkillModule.SkillLearnToLevel(CurSkillId, 1);
            levelItem = MySkillModule.GetDetailByLevelID(levelId);
            if (levelItem == null)
            {
                Debug.LogError("SkillLevel表格缺少ID为" + levelId.ToString() + "的数据!");
                return;
            }
            detail1.text = learnItem.skill_desc + "\n" + levelItem.skill_desc.Replace("\\n", "\n");

            levelId   = SkillModule.SkillLearnToLevel(CurSkillId, 2);
            levelItem = MySkillModule.GetDetailByLevelID(levelId);
            if (levelItem == null)
            {
                Debug.LogError("SkillLevel表格缺少ID为" + levelId.ToString() + "的数据!");
                return;
            }
            detail2.text = levelItem.skill_desc.Replace("\\n", "\n");

            needLvLb.gameObject.SetActive(true);
            int lvUpLv = SkillModule.GetPlayerLvBySkillLevelId(levelId);
            if (lvUpLv > 0)
            {
                PlayerDataModule pdm = ModuleManager.Instance.FindModule <PlayerDataModule>();
                if (pdm == null)
                {
                    GameDebug.LogError("f**k");
                    return;
                }

                if (pdm.GetLevel() < lvUpLv)
                {
                    needLvLb.text = string.Format(StringHelper.GetString("skill_open_lv", FontColor.Red), lvUpLv);
                }
                else
                {
                    needLvLb.text = string.Format(StringHelper.GetString("skill_open_lv", FontColor.Green), lvUpLv);
                }
            }
            else
            {
                needLvLb.text = "";
            }
        }

        else
        {
            skillLV.text = "Lv. " + lv.ToString();

            //levelItem = MySkillModule.GetDetailByCurLvSkillID(CurSkillId, MySkillModule.GetSkillLvBySkillID(CurSkillId) - 1);
            levelId   = SkillModule.SkillLearnToLevel(CurSkillId, lv);
            levelItem = MySkillModule.GetDetailByLevelID(levelId);

            if (levelItem == null)
            {
                Debug.LogError("error le");
                return;
            }

            detail1.text = learnItem.skill_desc + "\n" + levelItem.skill_desc.Replace("\\n", "\n");

            if (MySkillModule.IsFullLv(CurSkillId))
            {
                detail2.text = StringHelper.GetString("skill_full_lv");
                needLvLb.gameObject.SetActive(false);
            }

            else
            {
                levelId   = SkillModule.SkillLearnToLevel(CurSkillId, lv + 1);
                levelItem = MySkillModule.GetDetailByLevelID(levelId);

                if (levelItem == null)
                {
                    Debug.LogError("SkillLevel表格缺少ID为" + levelId.ToString() + "的数据!");
                    return;
                }

                needLvLb.gameObject.SetActive(true);
                int lvUpLv = SkillModule.GetPlayerLvBySkillLevelId(levelId);
                if (lvUpLv > 0)
                {
                    PlayerDataModule pdm = ModuleManager.Instance.FindModule <PlayerDataModule>();
                    if (pdm == null)
                    {
                        GameDebug.LogError("f**k");
                        return;
                    }

                    if (pdm.GetLevel() < lvUpLv)
                    {
                        needLvLb.text = string.Format(StringHelper.GetString("skill_open_lv", FontColor.Red), lvUpLv);
                    }
                    else
                    {
                        needLvLb.text = string.Format(StringHelper.GetString("skill_open_lv", FontColor.Green), lvUpLv);
                    }
                }
                else
                {
                    needLvLb.text = "";
                }

                detail2.text = levelItem.skill_desc.Replace("\\n", "\n");
            }
        }


        TypewriterEffect te1 = null, te2 = null;

        if (UIEffectManager.IsUIEffectActive <TypewriterEffect>(detail1.gameObject, ref te1))
        {
            if (needTypeWriterEffect)
            {
                te1.ReStart();
            }
            else
            {
                te1.SetProcessText();
            }
        }
        else
        {
            if (needTypeWriterEffect)
            {
                detail1.gameObject.AddMissingComponent <TypewriterEffect>();
            }
        }
        if (UIEffectManager.IsUIEffectActive <TypewriterEffect>(detail2.gameObject, ref te2))
        {
            if (needTypeWriterEffect)
            {
                te2.ReStart();
            }
            else
            {
                te2.SetProcessText();
            }
        }
        else
        {
            if (needTypeWriterEffect)
            {
                detail2.gameObject.AddMissingComponent <TypewriterEffect>();
            }
        }
    }