示例#1
0
    void OnChangedRoleType(RoleType rt)
    {
        Clear();
        bool bResetSelectIndex = true;

        switch (rt)
        {
        case RoleType.ROLE_SELF:
        {
            // 装备点的最大个数.
            int nBeginIndex = mCurrentEquipIndex * MAX_EQUIPGRID;
            int nCount      = 0;    //总装备数量
            for (int i = 0; i < (int)HUMAN_EQUIP.HEQUIP_NUMBER; i++)
            {
                if (i == (int)HUMAN_EQUIP.HEQUIP_RIDER)
                {
                    continue;
                }
                //取得玩家身上的装备
                CObject_Item pItem = CDataPool.Instance.UserEquip_GetItem((HUMAN_EQUIP)i);
                if (pItem != null)
                {
                    if (nCount < nBeginIndex || nCount - nBeginIndex >= MAX_EQUIPGRID)
                    {
                        nCount++;
                        continue;
                    }
                    //不重置当前选择的索引
                    if (nCount - nBeginIndex >= mCurrentSelectedEquip)
                    {
                        bResetSelectIndex = false;
                    }

                    mEquips[nCount - nBeginIndex].SetActionItem(pItem.GetID());
                    mEquipsText[nCount - nBeginIndex].Text = pItem.GetName() + "\n" + "强化 " + pItem.GetStrengthLevel() + "级";

                    nCount++;
                }
            }
            mMaxPage = nCount / MAX_EQUIPGRID;
            if (nCount % MAX_EQUIPGRID != 0)
            {
                mMaxPage++;
            }
            UpatePageNum();
        }
        break;

        case RoleType.ROLE_PACKET:
        {
            int nCount      = 0;
            int nBeginIndex = mCurrentEquipIndex * MAX_EQUIPGRID;
            for (int i = GAMEDEFINE.EQUIP_BAG_BEGIN; i < GAMEDEFINE.EQUIP_BAG_END; i++)
            {
                CObject_Item_Equip item = CDataPool.Instance.UserBag_GetItem(i) as CObject_Item_Equip;

                if (item != null && item.GetItemType() != HUMAN_EQUIP.HEQUIP_RIDER)
                {
                    if (nCount < nBeginIndex || nCount - nBeginIndex >= MAX_EQUIPGRID)
                    {
                        nCount++;
                        continue;
                    }
                    //不重置当前选择的索引
                    if (nCount - nBeginIndex >= mCurrentSelectedEquip)
                    {
                        bResetSelectIndex = false;
                    }

                    mEquips[nCount - nBeginIndex].SetActionItem(item.GetID());
                    mEquipsText[nCount - nBeginIndex].Text = item.GetName() + "\n" + "强化 " + item.GetStrengthLevel() + "级";

                    nCount++;
                }
            }
            mMaxPage = nCount / MAX_EQUIPGRID;
            if (nCount % MAX_EQUIPGRID != 0)
            {
                mMaxPage++;
            }
            UpatePageNum();
        }
        break;

        case RoleType.ROLE_PET1:
        {
            RefreshRolePetPage(0, ref bResetSelectIndex);
        }
        break;

        case RoleType.ROLE_PET2:
        {
            RefreshRolePetPage(1, ref bResetSelectIndex);
        }
        break;

        case RoleType.ROLE_PET3:
        {
            RefreshRolePetPage(2, ref bResetSelectIndex);
        }
        break;

        case RoleType.ROLE_PET4:
        {
            RefreshRolePetPage(3, ref bResetSelectIndex);
        }
        break;

        case RoleType.ROLE_PET5:
        {
            RefreshRolePetPage(4, ref bResetSelectIndex);
        }
        break;

        case RoleType.ROLE_PET6:
        {
            RefreshRolePetPage(5, ref bResetSelectIndex);
        }
        break;

        default:
            break;
        }

        //切换回归第一件装备
        if (bResetSelectIndex)
        {
            mCurrentSelectedEquip = 0;
            mEquipMenus[mCurrentSelectedEquip].Value = true;
        }
        SelectedEquipChanged(mCurrentSelectedEquip);
    }