示例#1
0
    private void RefreshUi()
    {
        bool refresh = false;

        Dictionary <int, int> unitPool;

        Dictionary <int, Unit> heroPool;

        Dictionary <int, Dictionary <int, UnitCommandData> > unitCommandPool;

        Dictionary <int, HeroCommandData> heroCommandPool;

        Dictionary <int, SkillCommandData> skillCommandPool;

        if (battle.clientIsMine)
        {
            unitPool = battle.mUnitPool;

            heroPool = battle.mHeroPool;

            unitCommandPool = battle.mUnitCommandPool;

            heroCommandPool = battle.mHeroCommandPool;

            skillCommandPool = battle.mSkillCommandPool;
        }
        else
        {
            unitPool = battle.oUnitPool;

            heroPool = battle.oHeroPool;

            unitCommandPool = battle.oUnitCommandPool;

            heroCommandPool = battle.oHeroCommandPool;

            skillCommandPool = battle.oSkillCommandPool;
        }

        Dictionary <int, UnitCellData> .ValueCollection.Enumerator enumerator = unitDic.Values.GetEnumerator();

        while (enumerator.MoveNext())
        {
            UnitCellData cellData = enumerator.Current;

            int num;

            if (unitPool.ContainsKey(cellData.id))
            {
                num = unitPool [cellData.id];
            }
            else
            {
                num = 0;
            }

            Dictionary <int, Dictionary <int, UnitCommandData> > .ValueCollection.Enumerator enumerator3 = unitCommandPool.Values.GetEnumerator();

            while (enumerator3.MoveNext())
            {
                Dictionary <int, UnitCommandData> .ValueCollection.Enumerator enumerator4 = enumerator3.Current.Values.GetEnumerator();

                while (enumerator4.MoveNext())
                {
                    if (enumerator4.Current.id == cellData.id)
                    {
                        num++;
                    }
                }
            }

            if (cellData.num != num)
            {
                cellData.num = num;

                refresh = true;
            }
        }

        if (refresh)
        {
            unitSuperList.SetDataAndKeepLocation(unitList);

            refresh = false;
        }

        Dictionary <int, HeroCellData> .ValueCollection.Enumerator enumerator2 = heroDic.Values.GetEnumerator();

        while (enumerator2.MoveNext())
        {
            HeroCellData cellData = enumerator2.Current;

            bool added = heroPool.ContainsKey(cellData.id);

            int cd = 0;

            bool selectable = true;

            if (!added)
            {
                if (heroCommandPool.ContainsKey(cellData.id))
                {
                    added = true;

                    selectable = false;
                }
            }
            else
            {
                Unit hero = heroPool[cellData.id];

                if (hero.sds.GetSkill() != 0)
                {
                    cd = hero.skillCd;
                }
            }

            if (selectable && added)
            {
                if (cd > 0)
                {
                    selectable = false;
                }
                else
                {
                    if (skillCommandPool.ContainsKey(cellData.id))
                    {
                        selectable = false;
                    }
                }
            }

            if (cellData.added != added)
            {
                cellData.added = added;

                refresh = true;
            }

            if (cellData.cd != cd)
            {
                cellData.cd = cd;

                refresh = true;
            }

            if (cellData.selectable != selectable)
            {
                cellData.selectable = selectable;

                refresh = true;
            }
        }

        if (refresh)
        {
            heroSuperList.SetDataAndKeepLocation(heroList);
        }

        moneyTf.text = battle.clientIsMine ? battle.mMoney.ToString() : battle.oMoney.ToString();
    }