Esempio n. 1
0
    void registerWidgets()
    {
        for (int i = 0; i < mRoleMenus.Count; i++)
        {
            mRoleTypes.Add(mRoleMenus[i].gameObject.name, i);
            mRoleMenus[i].SetValueChangedDelegate(RoleMenuValueChanged);
            if (mRoleMenus[i].defaultValue)
            {
                mCurrentRoleType = (RoleType)i;
            }
        }
        mPacketMenuPos = mRoleMenus[(int)RoleType.ROLE_PACKET].gameObject.transform.localPosition;
        for (int i = 0; i < mOperateMenus.Count; i++)
        {
            mOperateTypes.Add(mOperateMenus[i].gameObject.name, i);
            mOperateMenus[i].SetValueChangedDelegate(OperateMenuValueChanged);
            if (mOperateMenus[i].defaultValue)
            {
                mCurrentOperate = (OperateType)i;
            }
        }
        for (int i = 0; i < mEquipMenus.Count; i++)
        {
            mEquipIndexs.Add(mEquipMenus[i].gameObject.name, i);
            mEquipMenus[i].SetValueChangedDelegate(OnEquipSelectedChanged);
            if (mEquipMenus[i].defaultValue)
            {
                mCurrentSelectedEquip = i;
            }
        }
        foreach (ActionButton equip in mEquips)
        {
            equip.AddInputDelegate(OnEquipActionButtonClicked);
            equip.EnableDoAction = false;
            equip.DisableDrag();
        }
        mSDSelectedAction.DisableDrag();
        mSDPreviewAction.DisableDrag();
        foreach (ActionButton action in mSDMaterials)
        {
            action.DisableDrag();
        }
        mEnchanceSelectedAction.DisableDrag();

        int index = 0;

        foreach (ActionButton gemAction in mCombineContainer)
        {
            gemAction.AddInputDelegate(OnGemActionClicked);
            gemAction.DisableDrag();
            gemAction.EnableDoAction = false;
            mCombineGemIndexs.Add(gemAction.Name(), index++);
        }
        index = 0;
        foreach (ActionButton matAction in mGemCombineMaterials)
        {
            matAction.DisableDrag();
            matAction.AddInputDelegate(OnGemCombineMatRelease);
            mCombineGemMatsIndex.Add(matAction.Name(), index++);
            matAction.EnableDoAction = false;
        }

        //宝石镶嵌
        for (int i = 0; i < mEnchanseContainer.Count; i++)
        {
            mEnchanseGemIndexs.Add(mEnchanseContainer[i].Name(), i);
            mEnchanseContainer[i].AddInputDelegate(OnGemEnchanseActionClicked);
            mEnchanseContainer[i].DisableDrag();
            mEnchanseContainer[i].EnableDoAction = false;
        }
        index = 0;
        foreach (ActionButton gemAction in mEnchanseGems)
        {
            gemAction.DisableDrag();
            gemAction.EnableDoAction = false;
            gemAction.AddInputDelegate(OnEnchanseTakeOff);
            mEnchanseGemInfo[index++].enchanseGem = gemAction;
        }
    }
Esempio n. 2
0
    void UpdateSkill()
    {
        if (!gameObject.active)
        {
            return;
        }

        ResetUI();

        if (tabMode == TAB_MODE.TAB_SELFXINFA)
        {
            int           num         = CActionSystem.Instance.GetSkillActionNum();
            int           nXinfaIndex = -1;
            IUIListObject listItem    = null;
            for (int i = 0; i < num; i++)
            {
                CActionItem_Skill skill = CActionSystem.Instance.EnumAction(i, ActionNameType.Skill) as CActionItem_Skill;
                if (skill != null && (skill.GetXinfaID() >= SCLIENT_SKILLCLASS.XINFATYPE_JINGJIEBEGIN && skill.GetXinfaID() < SCLIENT_SKILLCLASS.XINFATYPE_SKILLBENGIN))
                {
                    nXinfaIndex++;
                    int nOffset = nXinfaIndex % 3;
                    if (nOffset == 0)
                    {
                        listItem = list.CreateItem(itemPrefab);
                        listItem.gameObject.name = "XinfaListItem" + nXinfaIndex;
                        for (int j = 0; j < 3; j++)
                        {
                            listItem.gameObject.transform.FindChild("Item" + j).gameObject.SetActiveRecursively(false);
                        }
                    }
                    GameObject item = listItem.gameObject.transform.FindChild("Item" + nOffset).gameObject;
                    item.SetActiveRecursively(true);
                    ActionButton skillAction = item.GetComponentInChildren <ActionButton>();
                    if (skillAction != null)
                    {
                        skillAction.SetActionItemByActionId(skill.GetID());
                        skillAction.DisableDrag();
                        skillAction.EnableDoAction = false;
                    }
                    UIButton bg = item.transform.FindChild("Bg").gameObject.GetComponent <UIButton>();
                    if (bg != null)
                    {
                        bg.SetInputDelegate(handlerInput);
                    }

                    SpriteText txt = item.transform.FindChild("NameLabel").gameObject.GetComponent <SpriteText>();
                    if (txt != null)
                    {
                        txt.Text = skill.GetName() + "\n" + "等级:" + skill.GetSkillLevel();
                    }

                    UIButton levelBtn = item.transform.FindChild("LevelUp").gameObject.GetComponent <UIButton>();
                    if (levelBtn != null)
                    {
                        levelBtn.SetInputDelegate(levelUpInputDelegate);
                        //LogManager.LogWarning("Set Delegate : " + levelBtn.gameObject.name);
                    }


                    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))
                    {
                        item.transform.FindChild("LevelUp").gameObject.GetComponent <UIButton>().controlIsEnabled = false;
                        //toolText[showIndex] = UIString.Instance.ParserString_Runtime(error);
                    }
                    else
                    {
                        item.transform.FindChild("LevelUp").gameObject.GetComponent <UIButton>().controlIsEnabled = true;
                        //toolText[showIndex] = null;
                    }
                }
            }
        }
        else if (tabMode == TAB_MODE.TAB_PETXINFA)
        {
            //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++;
            //    }
            //}
        }
        if (list.UnviewableArea > 0)
        {
            list.slider.Hide(false);
        }
        else
        {
            list.slider.Hide(true);
        }
    }