Пример #1
0
 public void Init(System.Action callback, eCreatureSort sortType = eCreatureSort.Grade, bool is_ascending = false)
 {
     OnSortCallback    = callback;
     SortType          = sortType;
     IsAscending       = is_ascending;
     m_PopupLabel.text = Localization.Get("HeroSort" + SortType);
 }
Пример #2
0
    public void OnClickSort(GameObject obj)
    {
        m_PopupState.value = false;

        eCreatureSort sort_type = eCreatureSort.Grade;

        switch (obj.name)
        {
        case "btn_grade":       sort_type = eCreatureSort.Grade;    break;

        case "btn_level":       sort_type = eCreatureSort.Level;    break;

        case "btn_enchant":     sort_type = eCreatureSort.Enchant;  break;

        case "btn_idn":         sort_type = eCreatureSort.IDN;      break;

        case "btn_power":       sort_type = eCreatureSort.Power;    break;

        case "btn_hp":          sort_type = eCreatureSort.HP;       break;

        case "btn_attack":      sort_type = eCreatureSort.Attack;   break;

        case "btn_defense":     sort_type = eCreatureSort.Defense;  break;
        }

        if (IsSaleMode)
        {
            if (SortTypeSaleMode == sort_type)
            {
                IsAscendingSaleMode = !IsAscendingSaleMode;
            }
            else
            {
                IsAscendingSaleMode = false;
            }
            SortTypeSaleMode  = sort_type;
            m_PopupLabel.text = Localization.Get("HeroSort" + SortTypeSaleMode);
            m_SortDirection.SetSpriteActive(IsAscendingSaleMode);
        }
        else
        {
            if (SortType == sort_type)
            {
                IsAscending = !IsAscending;
            }
            else
            {
                IsAscending = false;
            }
            SortType          = sort_type;
            m_PopupLabel.text = Localization.Get("HeroSort" + SortType);
            m_SortDirection.SetSpriteActive(IsAscending);
        }

        OnSortCallback();
    }
Пример #3
0
    public List <Creature> GetSortedList(eCreatureSort sort, bool is_ascending = false, List <Creature> creatures = null)
    {
        if (creatures == null)
        {
            creatures = Creatures;
        }

        IOrderedEnumerable <Creature> list = null;

        if (is_ascending == true)
        {
            switch (sort)
            {
            case eCreatureSort.Grade: list = creatures.OrderBy(c => c.Grade); break;

            case eCreatureSort.Level: list = creatures.OrderBy(c => c.Level); break;

            case eCreatureSort.Enchant: list = creatures.OrderBy(c => c.Enchant); break;

            case eCreatureSort.IDN: list = creatures.OrderBy(c => c.Info.IDN); break;

            case eCreatureSort.Power: list = creatures.OrderBy(c => c.Power); break;

            case eCreatureSort.HP: list = creatures.OrderBy(c => c.StatTotal.MaxHP); break;

            case eCreatureSort.Attack: list = creatures.OrderBy(c => c.StatTotal.GetAttack()); break;

            case eCreatureSort.Defense: list = creatures.OrderBy(c => c.StatTotal.GetDefense()); break;
            }
        }
        else
        {
            switch (sort)
            {
            case eCreatureSort.Grade: list = creatures.OrderByDescending(c => c.Grade); break;

            case eCreatureSort.Level: list = creatures.OrderByDescending(c => c.Level); break;

            case eCreatureSort.Enchant: list = creatures.OrderByDescending(c => c.Enchant); break;

            case eCreatureSort.IDN: list = creatures.OrderByDescending(c => c.Info.IDN); break;

            case eCreatureSort.Power: list = creatures.OrderByDescending(c => c.Power); break;

            case eCreatureSort.HP: list = creatures.OrderByDescending(c => c.StatTotal.MaxHP); break;

            case eCreatureSort.Attack: list = creatures.OrderByDescending(c => c.StatTotal.GetAttack()); break;

            case eCreatureSort.Defense: list = creatures.OrderByDescending(c => c.StatTotal.GetDefense()); break;
            }
        }
        if (list == null)
        {
            return(creatures);
        }

        if (is_ascending == true)
        {
            return(list.ThenBy(c => c.Grade).ThenBy(c => c.Level).ThenBy(c => c.Enchant).ThenBy(c => c.Power).ThenBy(c => c.Info.IDN).ToList());
        }
        return(list.ThenByDescending(c => c.Grade).ThenByDescending(c => c.Level).ThenByDescending(c => c.Enchant).ThenByDescending(c => c.Power).ThenByDescending(c => c.Info.IDN).ToList());
    }