Esempio n. 1
0
        private void RefreshDeployableData()
        {
            this.eligibleDeployables.Clear();
            CurrentPlayer currentPlayer = Service.CurrentPlayer;

            foreach (string current in this.troopUpgradeCatalog.AllUpgradeGroups())
            {
                int         nextLevel   = currentPlayer.UnlockedLevels.Troops.GetNextLevel(current);
                TroopTypeVO troopTypeVO = this.troopUpgradeCatalog.GetByLevel(current, nextLevel);
                TroopTypeVO byLevel     = this.troopUpgradeCatalog.GetByLevel(current, nextLevel - 1);
                if (troopTypeVO == null)
                {
                    troopTypeVO = this.troopUpgradeCatalog.GetMaxLevel(current);
                }
                if (troopTypeVO.PlayerFacing || (byLevel != null && byLevel.PlayerFacing))
                {
                    if (troopTypeVO.Type != TroopType.Champion)
                    {
                        if (troopTypeVO.Faction == this.buildingInfo.Faction)
                        {
                            TroopUpgradeScreen.DeployableUpgradeData deployableUpgradeData = new TroopUpgradeScreen.DeployableUpgradeData();
                            deployableUpgradeData.UpgradeType = troopTypeVO;
                            deployableUpgradeData.CurrentType = byLevel;
                            this.eligibleDeployables.Add(deployableUpgradeData);
                            if (!this.eligibleTroopTypes.Contains(troopTypeVO.Type))
                            {
                                this.eligibleTroopTypes.Add(troopTypeVO.Type);
                            }
                        }
                    }
                }
            }
            foreach (string current2 in this.starshipUpgradeCatalog.AllUpgradeGroups())
            {
                int nextLevel2 = currentPlayer.UnlockedLevels.Starships.GetNextLevel(current2);
                SpecialAttackTypeVO specialAttackTypeVO = this.starshipUpgradeCatalog.GetByLevel(current2, nextLevel2);
                SpecialAttackTypeVO byLevel2            = this.starshipUpgradeCatalog.GetByLevel(current2, nextLevel2 - 1);
                if (specialAttackTypeVO == null)
                {
                    specialAttackTypeVO = this.starshipUpgradeCatalog.GetMaxLevel(current2);
                }
                if (specialAttackTypeVO.PlayerFacing || (byLevel2 != null && byLevel2.PlayerFacing))
                {
                    if (specialAttackTypeVO.Faction == this.buildingInfo.Faction)
                    {
                        TroopUpgradeScreen.DeployableUpgradeData deployableUpgradeData2 = new TroopUpgradeScreen.DeployableUpgradeData();
                        deployableUpgradeData2.UpgradeType = specialAttackTypeVO;
                        deployableUpgradeData2.CurrentType = byLevel2;
                        this.eligibleDeployables.Add(deployableUpgradeData2);
                        this.hasStarships = true;
                    }
                }
            }
        }
Esempio n. 2
0
 private int CompareUpgradeDataBySortOrder(TroopUpgradeScreen.DeployableUpgradeData a, TroopUpgradeScreen.DeployableUpgradeData b)
 {
     return(this.CompareBySortOrder(a.UpgradeType, b.UpgradeType));
 }
Esempio n. 3
0
        private void PopulateTroopGrid()
        {
            List <TroopUpgradeScreen.DeployableUpgradeData> list = new List <TroopUpgradeScreen.DeployableUpgradeData>();

            this.contractHidden = (this.activeContract != null);
            string a     = string.Empty;
            int    i     = 0;
            int    count = this.eligibleDeployables.Count;

            while (i < count)
            {
                TroopUpgradeScreen.DeployableUpgradeData deployableUpgradeData = this.eligibleDeployables[i];
                TroopTab currentTab = (TroopTab)this.filterHelper.CurrentTab;
                if (deployableUpgradeData.CurrentType is SpecialAttackTypeVO)
                {
                    if (currentTab == TroopTab.All || currentTab == TroopTab.Starship)
                    {
                        if (this.contractHidden)
                        {
                            SpecialAttackTypeVO nextLevel = Service.StarshipUpgradeCatalog.GetNextLevel((SpecialAttackTypeVO)deployableUpgradeData.CurrentType);
                            if (nextLevel != null && nextLevel.PlayerFacing)
                            {
                                a = nextLevel.Uid;
                            }
                        }
                        goto IL_13F;
                    }
                }
                else if (currentTab != TroopTab.Starship)
                {
                    if (currentTab != TroopTab.All)
                    {
                        TroopType      type           = ((TroopTypeVO)deployableUpgradeData.CurrentType).Type;
                        TroopTabHelper troopTabHelper = this.filterHelper as TroopTabHelper;
                        TroopTab       troopTab       = troopTabHelper.ConvertTroopTypeToTab(type);
                        if (currentTab != troopTab)
                        {
                            goto IL_16F;
                        }
                    }
                    if (!this.contractHidden)
                    {
                        goto IL_13F;
                    }
                    TroopTypeVO nextLevel2 = Service.TroopUpgradeCatalog.GetNextLevel((TroopTypeVO)deployableUpgradeData.CurrentType);
                    if (nextLevel2 != null && nextLevel2.PlayerFacing)
                    {
                        a = nextLevel2.Uid;
                        goto IL_13F;
                    }
                    goto IL_13F;
                }
IL_16F:
                i++;
                continue;
IL_13F:
                if (this.contractHidden && a == this.activeContract.ProductUid)
                {
                    this.contractHidden = false;
                }
                list.Add(deployableUpgradeData);
                goto IL_16F;
            }
            list.Sort(new Comparison <TroopUpgradeScreen.DeployableUpgradeData>(this.CompareUpgradeDataBySortOrder));
            int num    = 2;
            int count2 = list.Count;
            int num2   = (count2 % num != 0) ? (count2 / num + 1) : (count2 / num);

            this.troopGrid.MaxItemsPerLine = num2;
            if (count2 % num == 1)
            {
                int sortOrder = 2 * num2 - 1;
                this.AddSpacerElement(sortOrder, this.troopGrid);
            }
            int j      = 0;
            int count3 = list.Count;

            while (j < count3)
            {
                int num3       = j % num;
                int sortOrder2 = num3 * num2 + j / num;
                TroopUpgradeScreen.DeployableUpgradeData deployableUpgradeData2 = list[j];
                this.AddUpgradeableItemToTroopGrid(deployableUpgradeData2.UpgradeType, deployableUpgradeData2.CurrentType, sortOrder2);
                j++;
            }
            this.troopGrid.RepositionItemsFrameDelayed(new UXDragDelegate(this.FinishTroopGridSetup), 1);
            this.CheckActiveContract();
        }