Example #1
0
        private void PopulateEquipmentGrid()
        {
            EquipmentUpgradeCatalog equipmentUpgradeCatalog = Service.EquipmentUpgradeCatalog;
            CurrentPlayer           currentPlayer           = Service.CurrentPlayer;

            this.FindAllUpgradableEquipment(currentPlayer, equipmentUpgradeCatalog);
            int maxItemsPerLine = (this.equipmentToDisplay.Count + 1) / 2;

            this.equipmentGrid.MaxItemsPerLine = maxItemsPerLine;
            EquipmentTabHelper equipmentTabHelper = this.filterHelper as EquipmentTabHelper;
            EquipmentTab       currentTab         = (EquipmentTab)equipmentTabHelper.CurrentTab;
            List <UXElement>   list = new List <UXElement>();
            int i     = 0;
            int count = this.equipmentToDisplay.Count;

            while (i < count)
            {
                EquipmentVO equipmentVO = this.equipmentToDisplay[i];
                if (equipmentTabHelper.IsEquipmentValidForTab(equipmentVO, currentTab))
                {
                    if (this.contractHidden)
                    {
                        EquipmentVO nextLevel = equipmentUpgradeCatalog.GetNextLevel(equipmentVO);
                        if (nextLevel.Uid == this.activeContract.ProductUid)
                        {
                            this.contractHidden = false;
                        }
                    }
                    UXElement item = this.FetchEquipmentCardGridItem(currentPlayer, equipmentVO, equipmentUpgradeCatalog);
                    list.Add(item);
                }
                i++;
            }
            UXUtils.SortListForTwoRowGrids(list, this.equipmentGrid);
            int j      = 0;
            int count2 = list.Count;

            while (j < count2)
            {
                this.equipmentGrid.AddItem(list[j], j);
                j++;
            }
            list.Clear();
            this.equipmentGrid.RepositionItemsFrameDelayed(new UXDragDelegate(this.FinishEquipmentGridSetup), 1);
            this.CheckActiveContract();
        }
Example #2
0
        protected override void FilterGridBasedOnId(string filterId)
        {
            base.FilterGridBasedOnId(filterId);
            List <UXElement> list = new List <UXElement>(this.perkGrid.GetElementList());

            this.perkGrid.ClearWithoutDestroy();
            list.Sort(new Comparison <UXElement>(this.SortUpgradeList));
            UXUtils.SortListForTwoRowGrids(list, this.perkGrid);
            int count = list.Count;

            for (int i = 0; i < count; i++)
            {
                UXElement uXElement = list[i];
                PerkVO    perkVO    = uXElement.Tag as PerkVO;
                string    rootName  = "PerkItem_" + perkVO.PerkGroup;
                uXElement.SetRootName(rootName);
                this.perkGrid.AddItem(uXElement, i);
            }
            List <UXElement> list2 = this.filterMap[filterId];

            this.gridToFilter.MaxItemsPerLine = (list2.Count + 1) / 2;
            this.perkGrid.RepositionItemsFrameDelayed(new UXDragDelegate(base.OnRepositionComplete));
            list.Clear();
        }
Example #3
0
        public override void RefreshPerkStates()
        {
            Lang lang = Service.Lang;

            this.perkBadgeMap.Clear();
            List <UXElement>     list                 = new List <UXElement>();
            PerkManager          perkManager          = Service.PerkManager;
            PerkViewController   perkViewController   = Service.PerkViewController;
            StaticDataController staticDataController = Service.StaticDataController;
            Squad squad = Service.CurrentPlayer.Squad;

            if (squad == null)
            {
                return;
            }
            Dictionary <string, string> available  = squad.Perks.Available;
            Dictionary <string, int>    inProgress = squad.Perks.InProgress;

            foreach (PerkVO current in staticDataController.GetAll <PerkVO>())
            {
                string uid   = current.Uid;
                bool   flag  = perkManager.IsPerkMaxTier(current) && available.ContainsValue(uid);
                bool   flag2 = perkManager.IsPerkLevelLocked(current, squad.Level);
                if (perkManager.HasPrerequistesUnlocked(current, available))
                {
                    if (flag || !available.ContainsValue(uid))
                    {
                        string    perkGroup = current.PerkGroup;
                        string    text      = "PerkItem_" + perkGroup;
                        UXElement uXElement = base.FetchPerkGridItem(this.perkGrid, text);
                        uXElement.Tag = current;
                        UXElement subElement  = this.perkGrid.GetSubElement <UXElement>(text, "LockedGroupUpCardPerks");
                        UXElement subElement2 = this.perkGrid.GetSubElement <UXElement>(text, "MaxLvlGroupUpCardPerks");
                        UXButton  subElement3 = this.perkGrid.GetSubElement <UXButton>(text, "BtnUpCardPerks");
                        subElement3.Tag       = current;
                        subElement3.OnClicked = new UXButtonClickedDelegate(this.OnPerkClicked);
                        int     reputationCost       = current.ReputationCost;
                        int     squadLevelUnlock     = current.SquadLevelUnlock;
                        int     perkInvestedProgress = perkManager.GetPerkInvestedProgress(current, inProgress);
                        string  text2       = reputationCost.ToString();
                        UXLabel subElement4 = this.perkGrid.GetSubElement <UXLabel>(text, "LabelPerkTitleUpCardPerks");
                        subElement4.Text = perkViewController.GetPerkNameForGroup(current.PerkGroup);
                        UXLabel subElement5 = this.perkGrid.GetSubElement <UXLabel>(text, "LabelCostUpPerk");
                        subElement5.Text = text2;
                        UXSprite subElement6 = this.perkGrid.GetSubElement <UXSprite>(text, "CostUpPerkReputationIcon");
                        string   str         = perkInvestedProgress.ToString();
                        UXLabel  subElement7 = this.perkGrid.GetSubElement <UXLabel>(text, "LabelpBarUpInvestAmtPerks");
                        subElement7.Text = str + "/" + text2;
                        UXSlider subElement8 = this.perkGrid.GetSubElement <UXSlider>(text, "pBarUpInvestAmtPerks");
                        subElement8.Value = (float)perkInvestedProgress / (float)reputationCost;
                        UXLabel subElement9 = this.perkGrid.GetSubElement <UXLabel>(text, "LabelPerkLvlUpCardPerks");
                        string  text3       = string.Empty;
                        if (current.PerkTier > 1)
                        {
                            text3 = StringUtils.GetRomanNumeral(current.PerkTier - 1);
                        }
                        else
                        {
                            text3 = lang.Get("PERK_UPGRADE_CARD_UNLOCK_TIER", new object[0]);
                        }
                        subElement9.Text = text3;
                        UXTexture subElement10 = this.perkGrid.GetSubElement <UXTexture>(text, "TexturePerkArtUpCardPerks");
                        perkViewController.SetPerkImage(subElement10, current);
                        bool visible = !flag2 && !flag;
                        subElement8.Visible = visible;
                        subElement7.Visible = visible;
                        subElement5.Visible = visible;
                        subElement6.Visible = visible;
                        subElement9.Visible = visible;
                        subElement2.Visible = flag;
                        subElement.Visible  = (flag2 && !flag);
                        if (flag2)
                        {
                            UXLabel subElement11 = this.perkGrid.GetSubElement <UXLabel>(text, "LabelSquadLvlLockedUpCardPerks");
                            subElement11.Text = current.SquadLevelUnlock.ToString();
                            UXLabel subElement12 = this.perkGrid.GetSubElement <UXLabel>(text, "LabelSquadLvlLockedUpCardPerks");
                            subElement12.Text = lang.Get("PERK_ACTIVATE_UPGRADE_CARD_LVL_REQ", new object[]
                            {
                                squadLevelUnlock
                            });
                        }
                        else if (flag)
                        {
                            UXLabel subElement13 = this.perkGrid.GetSubElement <UXLabel>(text, "LabelMaxLvlUpCardPerks");
                            subElement13.Text = lang.Get("PERK_UPGRADE_MAX_TIER", new object[0]);
                        }
                        base.SetupPerkBadge(current, text, "UpCardPerks");
                        list.Add(uXElement);
                    }
                }
            }
            list.Sort(new Comparison <UXElement>(this.SortUpgradeList));
            UXUtils.SortListForTwoRowGrids(list, this.perkGrid);
            int count = list.Count;

            this.perkGrid.ClearWithoutDestroy();
            for (int i = 0; i < count; i++)
            {
                this.perkGrid.AddItem(list[i], i);
            }
            this.perkGrid.RepositionItemsFrameDelayed(new UXDragDelegate(base.OnRepositionComplete));
            base.RefreshPerkStates();
        }
Example #4
0
        private void SetupCurTabElements()
        {
            this.itemGrid.Clear();
            this.labelBuildings.TextColor = UXUtils.COLOR_NAV_TAB_DISABLED;
            this.labelCurrency.TextColor  = UXUtils.COLOR_NAV_TAB_DISABLED;
            this.labelTroops.TextColor    = UXUtils.COLOR_NAV_TAB_DISABLED;
            this.labelCrates.TextColor    = UXUtils.COLOR_NAV_TAB_DISABLED;
            List <UXElement> list = new List <UXElement>();

            Service.ViewTimeEngine.UnregisterClockTimeObserver(this);
            Service.EventManager.UnregisterObserver(this, EventId.InventoryCrateOpenedAndGranted);
            Service.EventManager.UnregisterObserver(this, EventId.InventoryCrateCollectionClosed);
            Service.EventManager.UnregisterObserver(this, EventId.CrateInventoryUpdated);
            ServerPlayerPrefs serverPlayerPrefs = Service.ServerPlayerPrefs;

            switch (this.curTab)
            {
            case InventoryTab.Crate:
                Service.ViewTimeEngine.RegisterClockTimeObserver(this, 1f);
                Service.EventManager.RegisterObserver(this, EventId.InventoryCrateOpenedAndGranted);
                Service.EventManager.RegisterObserver(this, EventId.InventoryCrateCollectionClosed);
                Service.EventManager.RegisterObserver(this, EventId.CrateInventoryUpdated);
                this.AddCrates(list);
                this.AddGoToStoreItem(list);
                this.emptyCategoryLabel.Text = this.lang.Get("INVENTORY_NO_ITEM", new object[]
                {
                    this.lang.Get("INVENTORY_TAB_CRATES", new object[0])
                });
                this.labelCrates.TextColor = UXUtils.COLOR_NAV_TAB_ENABLED;
                serverPlayerPrefs.SetPref(ServerPref.NumInventoryCratesNotViewed, "0");
                break;

            case InventoryTab.Treasure:
                this.AddCurrencyItems(list);
                this.emptyCategoryLabel.Text = this.lang.Get("INVENTORY_NO_ITEM", new object[]
                {
                    this.lang.Get("INVENTORY_TAB_CURRENCY", new object[0])
                });
                this.labelCurrency.TextColor = UXUtils.COLOR_NAV_TAB_ENABLED;
                serverPlayerPrefs.SetPref(ServerPref.NumInventoryCurrencyNotViewed, "0");
                break;

            case InventoryTab.Building:
                this.AddBuildings(list);
                this.emptyCategoryLabel.Text = this.lang.Get("INVENTORY_NO_ITEM", new object[]
                {
                    this.lang.Get("INVENTORY_TAB_BUILDINGS", new object[0])
                });
                this.labelBuildings.TextColor = UXUtils.COLOR_NAV_TAB_ENABLED;
                break;

            case InventoryTab.Troop:
                this.AddTroops(list);
                this.emptyCategoryLabel.Text = this.lang.Get("INVENTORY_NO_ITEM", new object[]
                {
                    this.lang.Get("INVENTORY_TAB_TROOPS", new object[0])
                });
                this.labelTroops.TextColor = UXUtils.COLOR_NAV_TAB_ENABLED;
                serverPlayerPrefs.SetPref(ServerPref.NumInventoryTroopsNotViewed, "0");
                break;
            }
            Service.ServerAPI.Enqueue(new SetPrefsCommand(false));
            this.UpdateTabJewels();
            UXUtils.SortListForTwoRowGrids(list, this.itemGrid);
            int i     = 0;
            int count = list.Count;

            while (i < count)
            {
                this.itemGrid.AddItem(list[i], i);
                i++;
            }
            this.itemGrid.RepositionItemsFrameDelayed(new UXDragDelegate(this.OnGridRepositioned), 2);
            this.ToggleEmptyTabMessage();
            Service.EventManager.SendEvent(EventId.StoreScreenReady, this);
        }