Example #1
0
        /// <summary>
        /// Applies a sorting method for the collectibles list
        /// </summary>
        /// <param name="list"></param>
        /// <param name="mode"></param>
        public static void ApplySort(ref UIList list, CollectibleSortingMode mode)
        {
            switch (mode)
            {
            default:
            case CollectibleSortingMode.Normal:
                list.UpdateOrder();
                break;

            case CollectibleSortingMode.NamesAsc:
                list._items.Sort((x, y) => (x as CollectibleUIPanel).itemPanel.item.name.CompareTo((y as CollectibleUIPanel).itemPanel.item.name));
                break;

            case CollectibleSortingMode.NamesDesc:
                list._items.Sort((x, y) => (y as CollectibleUIPanel).itemPanel.item.name.CompareTo((x as CollectibleUIPanel).itemPanel.item.name));
                break;

            case CollectibleSortingMode.UnitAsc:
                list._items.Sort((x, y) => (x as CollectibleUIPanel)._stack.CompareTo((y as CollectibleUIPanel)._stack));
                break;

            case CollectibleSortingMode.UnitDesc:
                list._items.Sort((x, y) => (y as CollectibleUIPanel)._stack.CompareTo((x as CollectibleUIPanel)._stack));
                break;
            }
            CurrentCollectibleSortMode = mode;
        }
Example #2
0
 /// <summary>
 /// Gets the next sort mode based on the type of sort mode passed
 /// </summary>
 /// <param name="type"></param>
 /// <returns></returns>
 public static int GetNewSort(Type type)
 {
     if (type == typeof(CollectibleSortingMode))
     {
         if ((int)CurrentCollectibleSortMode + 1 > CollectibleSortCount)
         {
             CurrentCollectibleSortMode = CollectibleSortingMode.Normal;
             return((int)CurrentCollectibleSortMode);
         }
         else
         {
             CurrentCollectibleSortMode = CurrentCollectibleSortMode + 1;
             return((int)CurrentCollectibleSortMode);
         }
     }
     else
     {
         if ((int)CurrentShopSortMode + 1 > ShopSortCount)
         {
             CurrentShopSortMode = ShopSortingMode.Normal;
             return((int)CurrentShopSortMode);
         }
         else
         {
             CurrentShopSortMode = CurrentShopSortMode + 1;
             return((int)CurrentShopSortMode);
         }
     }
 }