Exemplo n.º 1
0
    /// <summary>
    /// 显示背包中的装备
    /// </summary>
    /// <param name="itemDic">装备列表</param>
    /// <param name="needCheckFirst">If set to <c>true</c> 是否需要选中第一个装备</param>
    void ShowBagItems(Dictionary <int, EquipmentInfo> itemDic, bool needCheckFirst = true)
    {
        HideAllGoItems();
        int                  index    = 0;
        DecomposeItemUI      firstOne = null;
        List <EquipmentInfo> itemList = new List <EquipmentInfo>(itemDic.Values);

        itemList.Sort(CompareEquip);
        for (int i = 0, count = itemList.Count; i < count; i++)
        {
            EquipmentInfo info = itemList[i];
            if (info == null)
            {
                continue;
            }
            EquipmentInfo selectOne = GameCenter.equipmentTrainingMng.CurSelectEquipmentInfo;
            if (GameCenter.equipmentTrainingMng.CurSlot != EquipSlot.None && (GameCenter.equipmentTrainingMng.CurSlot != info.Slot || (selectOne != null && (selectOne.NeedProf != info.NeedProf || info.InstanceID == selectOne.InstanceID))))
            {
                continue;
            }
            //选中了副装备就隐藏副装备
            if (GameCenter.equipmentTrainingMng.CurViceEquipmentInfo != null && GameCenter.equipmentTrainingMng.CurViceEquipmentInfo.InstanceID == info.InstanceID)
            {
                continue;
            }
            DecomposeItemUI itemUI = null;
            if (!allGoItems.ContainsKey(index))
            {
                if (equipGo != null)
                {
                    itemUI = equipGo.CreateNew(itemParent.transform);
                }
                allGoItems[index] = itemUI;
            }
            itemUI = allGoItems[index];
            itemUI.gameObject.SetActive(true);
            itemUI.SetData(info, ChooseBagItem, initSubGUIType);
            if (index == 0 && needCheckFirst)
            {
                firstOne = itemUI;
            }
            index++;
        }
        if (firstOne != null && needCheckFirst)
        {
            firstOne.SetChecked();
        }
        if (scrollView != null)
        {
            scrollView.SetDragAmount(0, 0, false);
        }
        if (itemParent != null)
        {
            itemParent.repositionNow = true;
        }
        if (itemDic.Count == 0)
        {
            GameCenter.equipmentTrainingMng.CurSelectEquipmentInfo = null;
        }
    }
Exemplo n.º 2
0
    /// <summary>
    /// 显示坐骑身上的装备
    /// </summary>
    void ShowEquipItems()
    {
        HideAllGoItems();
        int                  index     = 0;
        DecomposeItemUI      checkOne  = null;
        EquipmentInfo        selectOne = GameCenter.newMountMng.CurSelectEquipmentInfo;
        List <EquipmentInfo> itemList  = new List <EquipmentInfo>(GameCenter.newMountMng.MountEquipDic.Values);

        //Debug.Log("itemList:" + itemList.Count);
        for (int i = 0, count = itemList.Count; i < count; i++)
        {
            EquipmentInfo info = itemList[i];
            if (info == null)
            {
                continue;
            }
            DecomposeItemUI itemUI = null;
            if (!allGoItems.ContainsKey(index))
            {
                if (equipGo != null)
                {
                    itemUI = equipGo.CreateNew(itemParent.transform);
                }
                allGoItems[index] = itemUI;
            }
            itemUI = allGoItems[index];
            itemUI.gameObject.SetActive(true);
            itemUI.SetData(info, ChooseItem, SubGUIType.MOUNTEQUIP);
            if (selectOne != null)
            {
                if (selectOne.InstanceID == info.InstanceID)
                {
                    checkOne = itemUI;
                }
            }
            else
            {
                if (index == 0)
                {
                    checkOne = itemUI;
                }
            }
            index++;
        }
        if (scrollView != null)
        {
            scrollView.SetDragAmount(0, 0, false);
        }
        if (itemParent != null)
        {
            itemParent.repositionNow = true;
        }
        if (checkOne != null)
        {
            checkOne.SetChecked();
        }
        if (itemList.Count == 0)
        {
            GameCenter.newMountMng.CurSelectEquipmentInfo = null;
        }
    }