Esempio n. 1
0
    void UpdateSkill()
    {
        if (!gameObject.active)
        {
            return;
        }

        ResetUI();
        if (tabMode == TAB_MODE.TAB_SKILL)
        {
            int num       = CActionSystem.Instance.GetSkillActionNum();
            int showIndex = 0;
            for (int i = 0; i < num; i++)
            {
                if (showIndex >= buttons.Count)
                {
                    break;
                }
                CActionItem_Skill skill = CActionSystem.Instance.EnumAction(i, ActionNameType.Skill) as CActionItem_Skill;
                if (skill != null && skill.GetXinfaID() >= SCLIENT_SKILLCLASS.XINFATYPE_SKILLBENGIN)
                {
                    //LogManager.LogWarning("Xinfa = " + skill.GetXinfaID() + " skill = " + skill.GetDefineID());
                    //这里可能有问题
                    items[showIndex].SetActiveRecursively(true);
                    SCLIENT_SKILL skillData = skill.GetImpl() as SCLIENT_SKILL;
                    buttons[showIndex].UpdateItemFromAction(skill);
                    if (skillData != null && skillData.IsCanUse_CheckLevel(CObjectManager.Instance.getPlayerMySelf().ID, (int)skillData.m_nLevel) == OPERATE_RESULT.OR_OK)
                    {
                        buttons[showIndex].EnableDrag();
                        txtLevels[showIndex].Text = "等级:" + skill.GetSkillLevel();
                    }
                    else
                    {
                        buttons[showIndex].DisableDrag();
                        txtLevels[showIndex].Text = "未学习";
                    }

                    buttons[showIndex].EnableDoAction = true;

                    //update text
                    txtNames[showIndex].Text = skill.GetName();


                    SCLIENT_SKILLCLASS skillClass = CObjectManager.Instance.getPlayerMySelf().GetCharacterData().Get_SkillClass(skill.GetXinfaID());
                    //升级可操作
                    string error;
                    if (!CDataPool.Instance.isCanSkillLevelUp(skillClass.m_pDefine.nID, skillClass.m_nLevel + 1, out error))
                    {
                        levelUpBtns[showIndex].Hide(true);
                        //levelUpBtns[showIndex].controlIsEnabled = false;
                        toolText[showIndex] = UIString.Instance.ParserString_Runtime(error);
                    }
                    else
                    {
                        // levelUpBtns[showIndex].controlIsEnabled = true;
                        levelUpBtns[showIndex].Hide(false);
                        toolText[showIndex] = null;
                    }

                    showIndex++;
                }
            }
        }
        else if (tabMode == TAB_MODE.TAB_JINGJIE)
        {
            int num       = CActionSystem.Instance.GetSkillActionNum();
            int showIndex = 0;
            for (int i = 0; i < num; i++)
            {
                if (showIndex >= buttons.Count)
                {
                    break;
                }
                CActionItem_Skill skill = CActionSystem.Instance.EnumAction(i, ActionNameType.Skill) as CActionItem_Skill;
                //LogManager.LogWarning("Xinfa = " + skill.GetXinfaID() + " skill = " + skill.GetDefineID());
                if (skill != null && (skill.GetXinfaID() >= SCLIENT_SKILLCLASS.XINFATYPE_JINGJIEBEGIN && skill.GetXinfaID() < SCLIENT_SKILLCLASS.XINFATYPE_SKILLBENGIN))
                {
                    //这里可能有问题
                    items[showIndex].SetActiveRecursively(true);

                    buttons[showIndex].UpdateItemFromAction(skill);
                    buttons[showIndex].DisableDrag();
                    buttons[showIndex].EnableDoAction = false;

                    //update text
                    txtNames[showIndex].Text  = skill.GetName();
                    txtLevels[showIndex].Text = "等级:" + skill.GetSkillLevel();

                    SCLIENT_SKILLCLASS skillClass = CObjectManager.Instance.getPlayerMySelf().GetCharacterData().Get_SkillClass(skill.GetXinfaID());
                    //升级可操作
                    string error;
                    if (!CDataPool.Instance.isCanSkillLevelUp(skillClass.m_pDefine.nID, skillClass.m_nLevel + 1, out error))
                    {
                        levelUpBtns[showIndex].controlIsEnabled = false;
                        toolText[showIndex] = UIString.Instance.ParserString_Runtime(error);
                    }
                    else
                    {
                        levelUpBtns[showIndex].controlIsEnabled = true;
                        toolText[showIndex] = null;
                    }
                    showIndex++;
                }
            }
        }
        else if (tabMode == TAB_MODE.TAB_USUALSKILL)
        {
            int num = CActionSystem.Instance.GetSkillActionNum();
            //LogManager.LogWarning("Skill count = " + num);
            int showIndex = 0;
            for (int i = 0; i < num; i++)
            {
                CActionItem_Skill skill = CActionSystem.Instance.EnumAction(i, ActionNameType.Skill) as CActionItem_Skill;


                if (showIndex >= buttons.Count)
                {
                    break;
                }

                //超过51不属于普通技能
                if (skill != null && (skill.GetXinfaID() == -1 && skill.GetIDTable() < 51))
                {
                    // LogManager.LogWarning("Xinfa = " + skill.GetXinfaID() + "skill = " + skill.GetDefineID() + "index=" + i);
                    //这里可能有问题
                    items[showIndex].SetActiveRecursively(true);

                    buttons[showIndex].UpdateItemFromAction(skill);
                    buttons[showIndex].EnableDrag();
                    buttons[showIndex].EnableDoAction = true;

                    //update text
                    txtNames[showIndex].Text  = skill.GetName();
                    txtLevels[showIndex].Text = "等级:" + skill.GetSkillLevel();

                    levelUpBtns[showIndex].gameObject.SetActiveRecursively(false);

                    showIndex++;
                }
            }
        }
    }