Esempio n. 1
0
        public static object[] FilterArtifacts(object[] artifacts, string[] filter)
        {
            if (filter == null)
            {
                return(artifacts);
            }
            int           num1       = 0;
            int           num2       = 0;
            bool          flag1      = false;
            List <string> stringList = new List <string>();
            string        s          = (string)null;

            for (int index = 0; index < filter.Length; ++index)
            {
                if (ArtifactList.GetValue(filter[index], "RARE:", ref s))
                {
                    int result;
                    if (int.TryParse(s, out result))
                    {
                        num1 |= 1 << result;
                    }
                }
                else if (ArtifactList.GetValue(filter[index], "TYPE:", ref s))
                {
                    try
                    {
                        ArtifactTypes artifactTypes = (ArtifactTypes)Enum.Parse(typeof(ArtifactTypes), s, true);
                        num2 |= 1 << (int)(artifactTypes & (ArtifactTypes)31 & (ArtifactTypes)31);
                    }
                    catch
                    {
                        if (GameUtility.IsDebugBuild)
                        {
                            Debug.LogError((object)("Unknown element type: " + s));
                        }
                    }
                }
                else if (ArtifactList.GetValue(filter[index], "FAV:", ref s))
                {
                    flag1 = true;
                }
                else if (ArtifactList.GetValue(filter[index], "SAME:", ref s))
                {
                    stringList.Add(s);
                }
            }
            List <ArtifactData> artifactDataList = new List <ArtifactData>();

            for (int index = 0; index < artifacts.Length; ++index)
            {
                artifactDataList.Add(artifacts[index] as ArtifactData);
            }
            for (int index1 = artifactDataList.Count - 1; index1 >= 0; --index1)
            {
                ArtifactData artifactData = artifactDataList[index1];
                if (flag1 && !artifactData.IsFavorite)
                {
                    artifactDataList.RemoveAt(index1);
                }
                else
                {
                    bool flag2 = false;
                    for (int index2 = 0; index2 < stringList.Count; ++index2)
                    {
                        if (artifactData.ArtifactParam.iname == stringList[index2])
                        {
                            flag2 = true;
                            break;
                        }
                    }
                    if (flag2 || (1 << (int)artifactData.Rarity & num1) == 0 || (1 << (int)(artifactData.ArtifactParam.type & (ArtifactTypes)31) & num2) == 0)
                    {
                        artifactDataList.RemoveAt(index1);
                    }
                }
            }
            return(artifactDataList.ConvertAll <object>((Converter <ArtifactData, object>)(o => (object)o)).ToArray());
        }
Esempio n. 2
0
        private void _Refresh()
        {
            if (this.Source == ArtifactList.ListSource.Normal)
            {
                this.mDataType = typeof(ArtifactData);
            }
            else if (this.Source == ArtifactList.ListSource.Kakera)
            {
                this.mDataType = typeof(ArtifactParam);
            }
            if (UnityEngine.Object.op_Equality((UnityEngine.Object) this.ListItem, (UnityEngine.Object)null))
            {
                return;
            }
            this.mPageSize = this.CellCount;
            Transform transform = ((Component)this).get_transform();

            while (this.mItems.Count < this.mPageSize)
            {
                GameObject gameObject = (GameObject)UnityEngine.Object.Instantiate <GameObject>((M0)this.ListItem);
                gameObject.get_transform().SetParent(transform, false);
                this.mItems.Add(gameObject);
                ListItemEvents component = (ListItemEvents)gameObject.GetComponent <ListItemEvents>();
                if (UnityEngine.Object.op_Inequality((UnityEngine.Object)component, (UnityEngine.Object)null))
                {
                    component.OnSelect     = new ListItemEvents.ListItemEvent(this.OnItemSelect);
                    component.OnOpenDetail = new ListItemEvents.ListItemEvent(this.OnItemDetail);
                }
            }
            if (this.mItems.Count == 0)
            {
                return;
            }
            GameManager instance = MonoSingleton <GameManager> .Instance;

            object[] artifacts = (object[])null;
            if (this.Source == ArtifactList.ListSource.Normal)
            {
                List <ArtifactData> artifactDataList = new List <ArtifactData>((IEnumerable <ArtifactData>)instance.Player.Artifacts);
                if (this.OnlyEquippable && this.TestOwner != null)
                {
                    for (int index = 0; index < artifactDataList.Count; ++index)
                    {
                        if (!artifactDataList[index].CheckEnableEquip(this.TestOwner, -1))
                        {
                            artifactDataList.RemoveAt(index--);
                        }
                    }
                }
                artifacts = (object[])artifactDataList.ToArray();
            }
            else if (this.Source == ArtifactList.ListSource.Kakera)
            {
                List <ArtifactParam> artifactParamList = new List <ArtifactParam>();
                if (instance.MasterParam.Artifacts != null)
                {
                    ArtifactParam[] array = instance.MasterParam.Artifacts.ToArray();
                    for (int index = 0; index < array.Length; ++index)
                    {
                        if (array[index].is_create)
                        {
                            artifactParamList.Add(array[index]);
                        }
                    }
                }
                if (this.KakeraFlags != (ArtifactList.KakeraHideFlags) 0)
                {
                    for (int index = 0; index < artifactParamList.Count; ++index)
                    {
                        if (!ArtifactList.ShouldShowKakera(artifactParamList[index], instance, this.KakeraFlags))
                        {
                            artifactParamList.RemoveAt(index--);
                        }
                    }
                }
                artifacts = (object[])artifactParamList.ToArray();
            }
            object[] objArray = this.mFiltersPriority == null || this.mFiltersPriority.Length <= 0 ? ArtifactList.FilterArtifacts(artifacts, this.mFilters) : ArtifactList.FilterArtifacts(artifacts, this.mFiltersPriority);
            if (UnityEngine.Object.op_Inequality((UnityEngine.Object) this.EmptyMessage, (UnityEngine.Object)null))
            {
                this.mEmptyMessageChanged = true;
                this.EmptyMessage.SetActive(objArray == null || objArray.Length == 0);
            }
            if (objArray == null)
            {
                return;
            }
            int length;

            if (!string.IsNullOrEmpty(this.mSortMethod) && (length = this.mSortMethod.IndexOf(':')) > 0)
            {
                string     name   = this.mSortMethod.Substring(0, length);
                string     str    = this.mSortMethod.Substring(length + 1);
                MethodInfo method = ((object)this).GetType().GetMethod(name, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
                if ((object)method != null)
                {
                    try
                    {
                        method.Invoke((object)this, new object[2]
                        {
                            (object)objArray,
                            (object)str
                        });
                    }
                    catch (Exception ex)
                    {
                        DebugUtility.LogException(ex);
                    }
                }
                else
                {
                    DebugUtility.LogWarning("SortMethod Not Found: " + name);
                }
            }
            if (this.mDescending)
            {
                Array.Reverse((Array)objArray);
            }
            this.mData = new object[objArray.Length];
            Array.Copy((Array)objArray, (Array)this.mData, objArray.Length);
            if (this.mPageSize > 0)
            {
                this.mMaxPages = (objArray.Length + this.ExtraItems.Length + this.mPageSize - 1) / this.mPageSize;
                this.mPage     = Mathf.Max(0, Mathf.Min(this.mPage, this.mMaxPages - 1));
            }
            if (this.mFocusSelection)
            {
                this.mFocusSelection = false;
                if (this.mSelection != null && this.mSelection.Count > 0)
                {
                    int num = Array.IndexOf <object>(this.mData, this.mSelection[0]) + this.ExtraItems.Length;
                    if (num >= 0)
                    {
                        this.mPage = num / this.mPageSize;
                    }
                }
            }
            for (int index1 = 0; index1 < this.mItems.Count; ++index1)
            {
                int index2 = this.mPage * this.mPageSize + index1 - this.ExtraItems.Length;
                if (0 <= index2 && index2 < this.mData.Length)
                {
                    DataSource.Bind(this.mItems[index1], this.mDataType, this.mData[index2]);
                    this.mItems[index1].SetActive(index1 < this.mPageSize);
                    GameParameter.UpdateAll(this.mItems[index1]);
                }
                else
                {
                    this.mItems[index1].SetActive(false);
                }
            }
            for (int index = 0; index < this.ExtraItems.Length; ++index)
            {
                int num = this.mPage * this.mPageSize + index;
                if (UnityEngine.Object.op_Inequality((UnityEngine.Object) this.ExtraItems[index], (UnityEngine.Object)null))
                {
                    this.ExtraItems[index].SetActive(0 <= num && num < this.ExtraItems.Length);
                }
            }
            if (objArray.Length == 0 && this.ExtraItems.Length > 0)
            {
                this.ExtraItems[0].SetActive(false);
            }
            this.UpdateSelection();
            this.UpdatePage();
            if (!this.mInvokeSelChange)
            {
                return;
            }
            this.mInvokeSelChange = false;
            this.TriggerSelectionChange();
        }