Пример #1
0
    /// <summary>
    /// 返回所有与参数匹配的道具信息
    /// </summary>
    /// <param name="ABCs">道具英文名首字母</param>
    /// <returns>所有与参数匹配的道具信息</returns>
    public static ItemInfo[] SelectUnlockedItemInfosByABC(params string[] ABCs)
    {
        ItemInfo[] allUnlockedItemInfos = GetUnlockedItemInfos();
        if (allUnlockedItemInfos == null || allUnlockedItemInfos.Length <= 0)
        {
            return(null);
        }
        if (ABCs.Length <= 0)
        {
            return(allUnlockedItemInfos);
        }

        List <ItemInfo> resultList = new List <ItemInfo>(allUnlockedItemInfos.Length);

        foreach (ItemInfo tempItemInfo in allUnlockedItemInfos)
        {
            foreach (string ABC in ABCs)
            {
                string firstABC = tempItemInfo.englishName.Substring(0, 1).ToUpper();
                if (firstABC.Equals(ABC.ToUpper()))
                {
                    resultList.Add(tempItemInfo);
                    break;
                }
            }
        }
        return(resultList.ToArray());
    }
Пример #2
0
    /// <summary>
    /// 返回所有与参数匹配的道具信息
    /// </summary>
    /// <param name="itemTypes">道具类型</param>
    /// <param name="ABCs">道具英文名首字母</param>
    /// <returns>所有与参数匹配的道具信息</returns>
    public static ItemInfo[] SelectUnlockedItemInfos(string[] itemTypes, string[] ABCs)
    {
        ItemInfo[] allUnlockedItemInfos = GetUnlockedItemInfos();

        if (allUnlockedItemInfos == null || allUnlockedItemInfos.Length <= 0)
        {
            return(null);
        }
        if (itemTypes.Length <= 0 && ABCs.Length <= 0)
        {
            return(allUnlockedItemInfos);
        }

        List <ItemInfo> matchTypeList;

        if (itemTypes.Length > 0)
        {
            matchTypeList = new List <ItemInfo>();
            foreach (ItemInfo tempItemInfo in allUnlockedItemInfos)
            {
                foreach (string itemType in itemTypes)
                {
                    if (tempItemInfo.itemType.Equals(itemType))
                    {
                        matchTypeList.Add(tempItemInfo);
                        break;
                    }
                }
            }
        }
        else
        {
            matchTypeList = new List <ItemInfo>(allUnlockedItemInfos);
        }

        List <ItemInfo> resultList;

        if (ABCs.Length > 0)
        {
            resultList = new List <ItemInfo>();
            foreach (ItemInfo tempItemInfo in matchTypeList)
            {
                foreach (string ABC in ABCs)
                {
                    string firstABC = tempItemInfo.englishName[0].ToString().ToUpper();
                    if (firstABC.Equals(ABC.ToUpper()))
                    {
                        resultList.Add(tempItemInfo);
                        break;
                    }
                }
            }
        }
        else
        {
            resultList = matchTypeList;
        }
        return(resultList.ToArray());
    }