Exemplo n.º 1
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);
         }
     }
 }
Exemplo n.º 2
0
        /// <summary>
        /// Applies a sorting method for the shop list
        /// </summary>
        /// <param name="list"></param>
        /// <param name="mode"></param>
        public static void ApplySort(ref UIList list, ShopSortingMode mode)
        {
            switch (mode)
            {
            default:
            case ShopSortingMode.Normal:
                list.UpdateOrder();
                break;

            case ShopSortingMode.ResultNameAsc:
                list._items.Sort((x, y) => (x as ShopUIPanel).resultPanel.item.name.CompareTo((y as ShopUIPanel).resultPanel.item.name));
                break;

            case ShopSortingMode.ResultNameDesc:
                list._items.Sort((x, y) => (y as ShopUIPanel).resultPanel.item.name.CompareTo((x as ShopUIPanel).resultPanel.item.name));
                break;

            case ShopSortingMode.GoldAsc:
                list._items.ForEach(x => (x as ShopUIPanel).UpdateValue());
                list._items.Sort((x, y) => (x as ShopUIPanel).totalGoldValue.CompareTo((y as ShopUIPanel).totalGoldValue));
                break;

            case ShopSortingMode.GoldDesc:
                list._items.ForEach(x => (x as ShopUIPanel).UpdateValue());
                list._items.Sort((x, y) => (y as ShopUIPanel).totalGoldValue.CompareTo((x as ShopUIPanel).totalGoldValue));
                break;

            case ShopSortingMode.ArtifactAsc:
                list._items.Sort((x, y) => (x as ShopUIPanel).specialPanel.item.stack.CompareTo((y as ShopUIPanel).specialPanel.item.stack));
                break;

            case ShopSortingMode.ArtifactDesc:
                list._items.Sort((x, y) => (y as ShopUIPanel).specialPanel.item.stack.CompareTo((x as ShopUIPanel).specialPanel.item.stack));
                break;
            }
            CurrentShopSortMode = mode;
        }