protected override void InitUI() { base.InitUI(); Lang lang = Service.Get <Lang>(); PerkViewController perkViewController = Service.Get <PerkViewController>(); PerkManager perkManager = Service.Get <PerkManager>(); Squad currentSquad = Service.Get <SquadController>().StateManager.GetCurrentSquad(); if (currentSquad == null) { return; } Dictionary <string, string> available = currentSquad.Perks.Available; int level = currentSquad.Level; int squadLevelUnlock = this.targetPerkVO.SquadLevelUnlock; UXButton element = this.squadScreen.GetElement <UXButton>("BtnContinuePerkUpgradeCeleb"); element.Visible = false; UXLabel element2 = this.squadScreen.GetElement <UXLabel>("LabelModalTitlePerks"); element2.Text = lang.Get("PERK_ACTIVATE_POPUP_TITLE", new object[] { perkViewController.GetPerkNameForGroup(this.targetPerkVO.PerkGroup), this.targetPerkVO.PerkTier }); UXLabel element3 = this.squadScreen.GetElement <UXLabel>("LabelModalStoryPerks"); element3.Text = perkViewController.GetPerkDescForGroup(this.targetPerkVO.PerkGroup); perkViewController.SetupStatGridForPerk(this.targetPerkVO, this.statGrid, "TemplateModalStatsPerks", "LabelModalStatsInfoPerks", "LabelModalStatsValuePerks", false); UXTexture element4 = this.squadScreen.GetElement <UXTexture>("TexturePerkArtModalCardPerks"); perkViewController.SetPerkImage(element4, this.targetPerkVO); this.activationTimerLabel = this.squadScreen.GetElement <UXLabel>("LabelTickerModalPerks"); UXButton element5 = this.squadScreen.GetElement <UXButton>("BtnModalOneCurrencyPerks"); UXButton element6 = this.squadScreen.GetElement <UXButton>("BtnModalTwoCurrencyPerks"); this.activationTimerLabel.Visible = false; element5.Visible = false; element6.Visible = false; bool flag = !available.ContainsKey(this.targetPerkVO.PerkGroup); if (flag) { bool flag2 = perkManager.IsPerkLevelLocked(this.targetPerkVO, level); if (flag2) { UXLabel element7 = this.squadScreen.GetElement <UXLabel>("LabelPrimaryLvlLockedModalPerks"); UXLabel element8 = this.squadScreen.GetElement <UXLabel>("LabelSquadLvlLockedModalPerks"); UXLabel element9 = this.squadScreen.GetElement <UXLabel>("LabelSecondaryLvlLockedModalPerks"); element7.Text = lang.Get("PERK_UPGRADE_POPUP_LVL_REQ", new object[0]); element8.Text = squadLevelUnlock.ToString(); element9.Text = lang.Get("PERK_UPGRADE_POPUP_LVL_REQ2", new object[0]); this.levelLockedGroup.Visible = true; } else { UXLabel element10 = this.squadScreen.GetElement <UXLabel>("LabelPrimaryRepLockedModalPerks"); this.repLockedGroup.Visible = true; element10.Text = lang.Get("PERK_ACTIVATE_POPUP_REP_REQ", new object[0]); } } if (this.isActivation && !flag) { Dictionary <string, int> hQScaledCostForPlayer = GameUtils.GetHQScaledCostForPlayer(this.targetPerkVO.ActivationCost); int count = hQScaledCostForPlayer.Count; bool flag3 = count == 2; element5.Visible = !flag3; element6.Visible = flag3; UXButton uXButton = flag3 ? element6 : element5; uXButton.OnClicked = new UXButtonClickedDelegate(this.OnActivateButtonClicked); this.rootInfoView.Visible = true; string[] costElementNames = flag3 ? SquadScreenActivationInfoView.dualCostElementNames : SquadScreenActivationInfoView.singleCostElementNames; UXUtils.SetupMultiCostElements(this.squadScreen, costElementNames, null, this.targetPerkVO.ActivationCost, count); this.rootInfoView.Visible = false; } if (perkManager.IsPerkActive(this.targetPerkVO.Uid)) { this.activatedPerkData = Service.Get <PerkManager>().GetPlayerPerk(this.targetPerkVO.Uid); if (this.activatedPerkData != null) { this.activationTimerLabel.Visible = true; this.UpdateActivationTimeRemaining(); Service.Get <ViewTimeEngine>().RegisterClockTimeObserver(this, 1f); } } }
private void RefreshAvailablePerksGrid() { this.cooldownTimerLabels.Clear(); this.cooldownCostLabels.Clear(); this.perkBadgeMap.Clear(); IDataController dataController = Service.Get <IDataController>(); Lang lang = Service.Get <Lang>(); PerkManager perkManager = Service.Get <PerkManager>(); PerkViewController perkViewController = Service.Get <PerkViewController>(); Squad currentSquad = Service.Get <SquadController>().StateManager.GetCurrentSquad(); if (currentSquad == null) { return; } Dictionary <string, string> available = currentSquad.Perks.Available; int level = currentSquad.Level; List <UXElement> list = new List <UXElement>(); foreach (PerkVO current in dataController.GetAll <PerkVO>()) { string uid = current.Uid; string perkGroup = current.PerkGroup; int perkTier = current.PerkTier; int squadLevelUnlock = current.SquadLevelUnlock; bool flag = perkManager.IsPerkLevelLocked(current, level); bool flag2 = perkManager.IsPerkReputationLocked(current, level, available); bool flag3 = flag | flag2; bool flag4 = perkManager.IsPerkGroupActive(perkGroup); bool flag5 = perkManager.IsPerkGroupInCooldown(perkGroup); if ((!available.ContainsKey(perkGroup) || !(available[perkGroup] != current.Uid)) && (!flag3 || perkTier == 1)) { string text = "PerkItem_" + perkGroup; UXElement uXElement = base.FetchPerkGridItem(this.perksGrid, text); uXElement.Tag = current; UXElement subElement = this.perksGrid.GetSubElement <UXElement>(text, "CoolDownGroupAvActCardPerks"); UXElement subElement2 = this.perksGrid.GetSubElement <UXElement>(text, "LockedGroupAvActCardPerks"); UXElement subElement3 = this.perksGrid.GetSubElement <UXElement>(text, "CostAvActPerkTop"); subElement3.Visible = false; UXElement subElement4 = this.perksGrid.GetSubElement <UXElement>(text, "CostAvActPerkBot"); subElement4.Visible = false; UXLabel subElement5 = this.perksGrid.GetSubElement <UXLabel>(text, "LabelPerkTitleAvActCardPerks"); subElement5.Text = perkViewController.GetPerkNameForGroup(perkGroup); UXLabel subElement6 = this.perksGrid.GetSubElement <UXLabel>(text, "LabelPerkLvlAvActCardPerks"); subElement6.Text = StringUtils.GetRomanNumeral(current.PerkTier); subElement6.Visible = !flag3; UXTexture subElement7 = this.perksGrid.GetSubElement <UXTexture>(text, "TexturePerkArtAvActCardPerks"); perkViewController.SetPerkImage(subElement7, current); UXButton subElement8 = this.perksGrid.GetSubElement <UXButton>(text, "BtnAvActCardPerks"); subElement8.Tag = current; subElement8.OnClicked = new UXButtonClickedDelegate(this.OnPerkButtonClicked); uXElement.Visible = true; if (flag3) { subElement.Visible = false; subElement2.Visible = true; UXLabel subElement9 = this.perksGrid.GetSubElement <UXLabel>(text, "LabelSquadLvlLockedAvActCardPerks"); if (flag) { subElement9.Text = lang.Get("PERK_ACTIVATE_UPGRADE_CARD_LVL_REQ", new object[] { squadLevelUnlock }); } else { subElement9.Text = lang.Get("PERK_ACTIVATE_POPUP_REP_REQ", new object[0]); } } else if (flag4) { uXElement.Visible = false; } else if (flag5) { subElement.Visible = true; subElement2.Visible = false; UXLabel subElement10 = this.activePerksGrid.GetSubElement <UXLabel>(text, "LabelReadyNowAvActCardPerks"); subElement10.Text = lang.Get("PERK_ACTIVE_CARD_COOLDOWN_CTA", new object[0]); UXLabel subElement11 = this.activePerksGrid.GetSubElement <UXLabel>(text, "LabelCoolDownAvActCardPerks"); uint num = perkManager.GetPlayerPerkGroupCooldowns()[perkGroup]; this.UpdateLabelTimeRemaining(subElement11, lang, "PERK_ACTIVE_CARD_COOLDOWN_TIMER", num); subElement11.Tag = num; this.cooldownTimerLabels.Add(subElement11); UXLabel subElement12 = this.activePerksGrid.GetSubElement <UXLabel>(text, "CostReadyNowPerksLabel"); subElement12.Tag = uid; this.cooldownCostLabels.Add(subElement12); this.UpdateGridItemCooldownSkipCost(subElement12, uid); subElement8.OnClicked = new UXButtonClickedDelegate(this.OnCooldownButtonClicked); } else if (!flag4 && !flag5) { subElement.Visible = false; subElement2.Visible = false; Dictionary <string, int> hQScaledCostForPlayer = GameUtils.GetHQScaledCostForPlayer(current.ActivationCost); int count = hQScaledCostForPlayer.Count; string[] costElementNames = (count == 2) ? SquadAdvancementActivateTab.dualCostElementNames : SquadAdvancementActivateTab.singleCostElementName; UXUtils.SetupMultiCostElements(this.screen, costElementNames, text, current.ActivationCost, count); } base.SetupPerkBadge(current, text, "ActCardPerks"); list.Add(uXElement); } } list.Sort(new Comparison <UXElement>(this.SortAvailableList)); this.perksGrid.ClearWithoutDestroy(); int i = 0; int count2 = list.Count; while (i < count2) { this.perksGrid.AddItem(list[i], i); i++; } this.perksGrid.RepositionItemsFrameDelayed(new UXDragDelegate(base.OnRepositionComplete)); list.Clear(); list = null; }