Example #1
0
    IEnumerator Start()
    {
        isInitialized = false;

        while (!SceneLobby.Instance)
        {
            yield return(null);
        }

        SceneLobby.Instance.OnChangedMenu += OnChangedMenu;

        //tabType = DictionaryTapType.Battle;

        while (!DictionaryManager.isInitialized)
        {
            yield return(null);
        }

        yield return(StartCoroutine(DictionaryManager.Instance.InitDictionaryLevelData()));

        List <HeroBaseData> heroList = DictionaryManager.heroBaseDataDic.Values.ToList();

        for (int i = 0; i < heroList.Count; i++)
        {
            string    id     = heroList[i].id;
            Transform parent = id.EndsWith("_Hero") ? battleScrollViewContent.transform : territoryScrollViewContent.transform;

            GameObject go = Instantiate(heroSlotPrefab, parent) as GameObject;
            go.transform.localPosition = Vector3.zero;
            go.transform.localScale    = Vector3.one;

            UIDictionarySlot heroSlot = go.GetComponent <UIDictionarySlot>();

            heroSlot.id = heroList[i].id;

            heroSlot.SlotDataInit(heroList[i].id, DicionaryState.Default);
            heroSlotDic.Add(heroSlot.id, heroSlot);
            heroSlotList.Add(heroSlot);

            continue;
        }

        yield return(StartCoroutine(SortHeroListA()));

        tabType = DictionaryTapType.Battle;
        SizeControl();


        isInitialized = true;
    }
Example #2
0
    int SortDelegate(UIDictionarySlot a, UIDictionarySlot b)
    {
        DictionaryManager.HeroDictionaryData heroDataA = DictionaryManager.heroDictionaryDataDic[a.id];
        DictionaryManager.HeroDictionaryData heroDataB = DictionaryManager.heroDictionaryDataDic[b.id];
        int gradeA = heroDataA.heroData.heroGrade;
        int gradeB = heroDataB.heroData.heroGrade;

        int result = gradeB.CompareTo(gradeA);

        if (result == 0)
        {
            result = heroDataA.heroData.heroName.CompareTo(heroDataB.heroData.heroName);
        }

        return(result);
    }