Пример #1
0
        public CrateInfoModalScreen(string crateUid, string planetID, int hqLevel)
        {
            this.selectedRowIndex = -1;
            base..ctor("gui_modal_crateinfo");
            IDataController dataController = Service.Get <IDataController>();

            this.targetCrateVO = dataController.Get <CrateVO>(crateUid);
            string      text    = null;
            FactionType faction = Service.Get <CurrentPlayer>().Faction;

            if (faction != FactionType.Empire)
            {
                if (faction == FactionType.Rebel)
                {
                    text = this.targetCrateVO.RebelLEIUid;
                }
            }
            else
            {
                text = this.targetCrateVO.EmpireLEIUid;
            }
            if (!string.IsNullOrEmpty(text))
            {
                this.targetLEIVO = dataController.Get <LimitedEditionItemVO>(text);
            }
            this.planetVO            = dataController.GetOptional <PlanetVO>(planetID);
            this.hqLevel             = hqLevel;
            this.filteredFlyoutItems = new List <CrateFlyoutItemVO>();
            CurrentPlayer currentPlayer = Service.Get <CurrentPlayer>();

            string[] array = (currentPlayer.Faction == FactionType.Empire) ? this.targetCrateVO.FlyoutEmpireItems : this.targetCrateVO.FlyoutRebelItems;
            if (array != null)
            {
                int i   = 0;
                int num = array.Length;
                while (i < num)
                {
                    string            text2    = array[i];
                    CrateFlyoutItemVO optional = dataController.GetOptional <CrateFlyoutItemVO>(text2);
                    if (optional == null)
                    {
                        Service.Get <StaRTSLogger>().ErrorFormat("CrateInfoModalScreen: FlyoutItemVO Uid {0} not found", new object[]
                        {
                            text2
                        });
                    }
                    else
                    {
                        bool flag  = UXUtils.IsValidRewardItem(optional, this.planetVO, hqLevel);
                        bool flag2 = UXUtils.ShouldDisplayCrateFlyoutItem(optional, CrateFlyoutDisplayType.Flyout);
                        if ((flag & flag2) && this.filteredFlyoutItems.Count < 4)
                        {
                            this.filteredFlyoutItems.Add(optional);
                        }
                    }
                    i++;
                }
            }
        }
        private void AddTier(TournamentTierVO tierVO, bool isCurrent, int order, Dictionary <string, TournamentRewardsVO> tierRewardMap)
        {
            if (!tierRewardMap.ContainsKey(tierVO.Uid))
            {
                Service.Get <StaRTSLogger>().ErrorFormat("There is no reward found for tier {0}", new object[]
                {
                    tierVO.Uid
                });
                return;
            }
            string    uid        = tierVO.Uid;
            UXElement item       = this.tierGrid.CloneTemplateItem(uid);
            UXElement subElement = this.tierGrid.GetSubElement <UXElement>(uid, "CurrentLeague");

            subElement.Visible = isCurrent;
            if (isCurrent && this.currentPlayerRank != null)
            {
                string  id          = (TimedEventUtils.GetState(this.currentTournamentVO) == TimedEventState.Live) ? "CONFLICT_CURRENT_PERCENTILE" : "CONFLICT_FINAL_PERCENTILE";
                UXLabel subElement2 = this.tierGrid.GetSubElement <UXLabel>(uid, "LabelCurrentLeague");
                subElement2.Text = this.lang.Get(id, new object[]
                {
                    Math.Round(this.currentPlayerRank.Percentile, 2)
                });
            }
            float   percentage  = tierVO.Percentage;
            UXLabel subElement3 = this.tierGrid.GetSubElement <UXLabel>(uid, "LabelRequirements");

            if (percentage < 100f)
            {
                subElement3.Text = this.lang.Get("CONFLICT_TIER_REQ_PERCENTAGE", new object[]
                {
                    percentage
                });
            }
            else
            {
                subElement3.Text = this.lang.Get("CONFLICT_TIER_REQ_ANY", new object[0]);
            }
            UXLabel subElement4 = this.tierGrid.GetSubElement <UXLabel>(uid, "LabelLeagueLevel");

            subElement4.Text = this.lang.Get(tierVO.RankName, new object[0]);
            if (tierVO.Division != null)
            {
                string text = this.lang.Get(tierVO.Division, new object[0]);
                if (!string.IsNullOrEmpty(text) && text.Trim().get_Length() != 0)
                {
                    UXLabel expr_1A0 = subElement4;
                    expr_1A0.Text = expr_1A0.Text + " - " + text;
                }
            }
            UXSprite subElement5 = this.tierGrid.GetSubElement <UXSprite>(uid, "SpriteLeagueIcon");

            subElement5.SpriteName = Service.Get <TournamentController>().GetTierIconName(tierVO);
            TournamentRewardsVO tournamentRewardsVO = tierRewardMap[tierVO.Uid];
            UXGrid        subElement6   = this.tierGrid.GetSubElement <UXGrid>(uid, "GridRewardCards");
            StringBuilder stringBuilder = new StringBuilder(" (");

            stringBuilder.Append(uid);
            stringBuilder.Append(")");
            string text2 = stringBuilder.ToString();

            subElement6.SetTemplateItem("EquipmentItemCard" + text2);
            CrateVO optional = Service.Get <IDataController>().GetOptional <CrateVO>(tournamentRewardsVO.CrateRewardIds[0]);

            if (optional != null)
            {
                IDataController          dataController = Service.Get <IDataController>();
                List <CrateFlyoutItemVO> list           = new List <CrateFlyoutItemVO>();
                CurrentPlayer            currentPlayer  = Service.Get <CurrentPlayer>();
                string[] array = (currentPlayer.Faction == FactionType.Empire) ? optional.FlyoutEmpireItems : optional.FlyoutRebelItems;
                if (array != null)
                {
                    int i   = 0;
                    int num = array.Length;
                    while (i < num)
                    {
                        string            text3     = array[i];
                        CrateFlyoutItemVO optional2 = dataController.GetOptional <CrateFlyoutItemVO>(text3);
                        if (optional2 == null)
                        {
                            Service.Get <StaRTSLogger>().ErrorFormat("CrateInfoModalScreen: FlyoutItemVO Uid {0} not found", new object[]
                            {
                                text3
                            });
                        }
                        else
                        {
                            bool flag = UXUtils.ShouldDisplayCrateFlyoutItem(optional2, CrateFlyoutDisplayType.TournamentTier);
                            if (flag)
                            {
                                PlanetVO optional3      = dataController.GetOptional <PlanetVO>(this.currentTournamentVO.PlanetId);
                                int      currentHqLevel = currentPlayer.Map.FindHighestHqLevel();
                                bool     flag2          = UXUtils.IsValidRewardItem(optional2, optional3, currentHqLevel);
                                if (flag2 && (!optional2.ReqArmory || ArmoryUtils.PlayerHasArmory()) && list.Count <= 5)
                                {
                                    list.Add(optional2);
                                    string    uid2      = optional2.Uid;
                                    UXElement uXElement = subElement6.CloneTemplateItem(uid2);
                                    this.SetupCrateReward(uid2, tournamentRewardsVO, subElement6, uXElement, text2, optional2);
                                    subElement6.AddItem(uXElement, i);
                                }
                            }
                        }
                        i++;
                    }
                }
                else
                {
                    Service.Get <StaRTSLogger>().ErrorFormat("There is no crate data for {0}", new object[]
                    {
                        tournamentRewardsVO.CrateRewardIds[0]
                    });
                }
                UXSprite subElement7 = subElement6.GetSubElement <UXSprite>(uid, "SpriteSupplyPrize");
                RewardUtils.SetCrateIcon(subElement7, optional, AnimState.Closed);
                UXButton subElement8 = subElement6.GetSubElement <UXButton>(uid, "BtnConflictPrize");
                subElement8.OnClicked = new UXButtonClickedDelegate(this.OnCrateClicked);
                subElement8.Tag       = optional.Uid;
                UXLabel subElement9 = subElement6.GetSubElement <UXLabel>(uid, "LabelPrize");
                subElement9.Text = this.lang.Get("CONFLICT_PRIZE_CRATE", new object[]
                {
                    LangUtils.GetCrateDisplayName(optional)
                });
                UXLabel subElement10 = subElement6.GetSubElement <UXLabel>(uid, "LabelPrizeNumber");
                if (tournamentRewardsVO.CrateRewardIds.Length > 1)
                {
                    subElement10.Text = this.lang.Get("CONFLICT_PRIZE_CRATE_MULTIPLIER", new object[]
                    {
                        tournamentRewardsVO.CrateRewardIds.Length
                    });
                }
                else
                {
                    subElement10.Visible = false;
                    subElement6.GetSubElement <UXElement>(uid, "SpritePrizeNumberShadow").Visible = false;
                }
            }
            this.tierGrid.AddItem(item, order);
        }