コード例 #1
0
    /// <summary>
    /// 点击圣魂融合选择
    /// </summary>
    private void OnSelectBlendMuhon()
    {
        if (DataManager.Manager <UIPanelManager>().IsShowPanel(PanelID.ItemChoosePanel))
        {
            return;
        }
        Muhon itemData = Data;

        if (null == itemData)
        {
            TipsManager.Instance.ShowTips(LocalTextType.Local_TXT_Soul_ChooseBlendMuhonTips);
            return;
        }

        if (!emgr.IsItemHaveAdditiveAttrOrGemHole(itemData.QWThisID, false))
        {
            TipsManager.Instance.ShowTips(LocalTextType.Local_TXT_Soul_ActiveTips);
            return;
        }

        //筛选满足条件的圣魂
        List <uint> data        = new List <uint>();
        List <uint> filterTypes = new List <uint>();

        filterTypes.Add((uint)GameCmd.EquipType.EquipType_SoulOne);
        List <uint> muhonList = imgr.GetItemByType(GameCmd.ItemBaseType.ItemBaseType_Equip, filterTypes, GameCmd.PACKAGETYPE.PACKAGETYPE_MAIN);

        //过滤
        if (null != muhonList && muhonList.Count != 0)
        {
            Muhon tempData = null;

            for (int i = 0; i < muhonList.Count; i++)
            {
                if (itemData.IsMatchBlend(muhonList[i], false))
                {
                    data.Add(muhonList[i]);
                }
            }
        }
        if (data.Count == 0)
        {
            TipsManager.Instance.ShowTips(string.Format("背包中未找到消耗所需{0}{1}"
                                                        , ColorManager.GetNGUIColorOfType(ColorType.Red), itemData.Name));
            return;
        }

        data.Sort((left, right) =>
        {
            Muhon leftM  = imgr.GetBaseItemByQwThisId <Muhon>(left);
            Muhon rightM = imgr.GetBaseItemByQwThisId <Muhon>(right);
            if (rightM.IsActive)
            {
                if (leftM.IsActive)
                {
                    return(rightM.Level - leftM.Level);
                }
                return(1);
            }
            else if (leftM.IsActive)
            {
                return(-1);
            }
            else
            {
                return(rightM.Level - leftM.Level);
            }
            return(0);
        });

        UILabel          desLabel     = null;
        Action <UILabel> desLabAction = (des) =>
        {
            desLabel = des;
            if (null != desLabel)
            {
                desLabel.text = DataManager.Manager <TextManager>()
                                .GetLocalText(LocalTextType.Local_TXT_Soul_ChooseActiveMuhonNotice);
            }
        };
        uint tempSelectMuhonId = blendSelectMuhonId;
        UIWeaponSoulInfoSelectGrid tempSelectWeaponSoulGrid = null;
        UIEventDelegate            eventDlg = (eventTye, grid, param) =>
        {
            if (eventTye == UIEventType.Click)
            {
                UIWeaponSoulInfoSelectGrid tempGrid = grid as UIWeaponSoulInfoSelectGrid;
                if (tempSelectMuhonId == tempGrid.QWThisId)
                {
                    tempSelectMuhonId = 0;
                    tempGrid.SetHightLight(false);
                }
                else if (itemData.IsMatchBlend(tempGrid.QWThisId))
                {
                    tempSelectMuhonId = tempGrid.QWThisId;
                    if (null != tempSelectWeaponSoulGrid)
                    {
                        tempSelectWeaponSoulGrid.SetHightLight(false);
                    }
                    tempGrid.SetHightLight(true);
                    tempSelectWeaponSoulGrid = tempGrid;
                }
                else
                {
                    TipsManager.Instance.ShowTips(LocalTextType.Local_TXT_Soul_UnactiveNotice);
                }
            }
        };

        ItemChoosePanel.ItemChooseShowData showData = new ItemChoosePanel.ItemChooseShowData()
        {
            createNum        = data.Count,
            title            = "选择圣魂",
            cloneTemp        = UIManager.GetResGameObj(GridID.Uiweaponsoulinfoselectgrid) as GameObject,
            onChooseCallback = () =>
            {
                if (tempSelectMuhonId != blendSelectMuhonId)
                {
                    blendSelectMuhonId = tempSelectMuhonId;
                    UpdateBlend(Data);
                }
            },
            gridCreateCallback = (obj, index) =>
            {
                if (index >= data.Count)
                {
                    Engine.Utility.Log.Error("OnSelectBlendMuhon error,index out of range");
                }
                else
                {
                    Muhon tempItemData = imgr.GetBaseItemByQwThisId <Muhon>(data[index]);
                    if (null == tempItemData)
                    {
                        Engine.Utility.Log.Error("OnSelectBlendMuhon error,get itemData qwThisId:{0}", data[index]);
                    }
                    else
                    {
                        UIWeaponSoulInfoSelectGrid weaponsoulInfoGrid = obj.GetComponent <UIWeaponSoulInfoSelectGrid>();
                        if (null == weaponsoulInfoGrid)
                        {
                            weaponsoulInfoGrid = obj.AddComponent <UIWeaponSoulInfoSelectGrid>();
                        }
                        weaponsoulInfoGrid.RegisterUIEventDelegate(eventDlg);
                        if (!itemData.IsMatchBlend(tempSelectMuhonId))
                        {
                            tempSelectMuhonId = 0;
                        }
                        bool select = (data[index] == tempSelectMuhonId);
                        weaponsoulInfoGrid.SetGridViewData(tempItemData.QWThisID, select, itemData.IsMatchBlend(data[index]), true);
                        if (select)
                        {
                            tempSelectWeaponSoulGrid = weaponsoulInfoGrid;
                            tempSelectMuhonId        = data[index];
                        }
                    }
                }
            },
            desPassCallback = desLabAction,
        };
        DataManager.Manager <UIPanelManager>().ShowPanel(PanelID.ItemChoosePanel, data: showData);
    }