Beispiel #1
0
        public static void TrySetupConflictItemRewardView(TournamentRewardsVO rewardGroup, UXLabel prizeLabel, UXSprite iconSprite, UXSprite crateSprite, UXElement basicElement, UXElement advancedElement, UXElement eliteElement, UXLabel crateCountLabel, UXSprite dataFragIcon, UXLabel optionalUnitName)
        {
            IDataController dataController = Service.Get <IDataController>();
            CurrentPlayer   currentPlayer  = Service.Get <CurrentPlayer>();
            string          text           = string.Empty;
            FactionType     faction        = currentPlayer.Faction;

            if (faction != FactionType.Empire)
            {
                if (faction == FactionType.Rebel)
                {
                    text = rewardGroup.RebelGuaranteedReward;
                }
            }
            else
            {
                text = rewardGroup.EmpireGuaranteedReward;
            }
            CrateSupplyVO optional = dataController.GetOptional <CrateSupplyVO>(text);
            Lang          lang     = Service.Get <Lang>();

            if (optional != null)
            {
                UXUtils.TrySetupItemQualityView(optional, basicElement, advancedElement, eliteElement, null);
                int         num = currentPlayer.Map.FindHighestHqLevel();
                IGeometryVO iconVOFromCrateSupply = GameUtils.GetIconVOFromCrateSupply(optional, num);
                if (iconVOFromCrateSupply != null)
                {
                    ProjectorConfig projectorConfig = ProjectorUtils.GenerateGeometryConfig(iconVOFromCrateSupply, iconSprite, true);
                    projectorConfig.AnimPreference = AnimationPreference.AnimationPreferred;
                    ProjectorUtils.GenerateProjector(projectorConfig);
                }
                else
                {
                    Service.Get <StaRTSLogger>().ErrorFormat("Could not generate geometry for crate supply {0}", new object[]
                    {
                        optional.Uid
                    });
                }
                if (iconVOFromCrateSupply != null)
                {
                    int shardQualityNumeric = GameUtils.GetShardQualityNumeric(optional);
                    if (shardQualityNumeric > -1)
                    {
                        dataFragIcon.SpriteName = string.Format("icoDataFragQ{0}", new object[]
                        {
                            shardQualityNumeric
                        });
                        dataFragIcon.Visible = true;
                    }
                    else
                    {
                        dataFragIcon.Visible = false;
                    }
                }
                InventoryCrateRewardController inventoryCrateRewardController = Service.Get <InventoryCrateRewardController>();
                int rewardAmount = inventoryCrateRewardController.GetRewardAmount(optional, num);
                if (rewardAmount > 1)
                {
                    string text2 = lang.ThousandsSeparated(rewardAmount);
                    prizeLabel.Text = lang.Get("CONFLICT_PRIZE_CRATE_MULTIPLIER", new object[]
                    {
                        text2
                    });
                }
                else
                {
                    prizeLabel.Visible = false;
                }
                if (optionalUnitName != null)
                {
                    optionalUnitName.Text = inventoryCrateRewardController.GetCrateSupplyRewardName(optional);
                }
            }
            else
            {
                Service.Get <StaRTSLogger>().ErrorFormat("Could not find crate supply {0} for faction {1}", new object[]
                {
                    text,
                    currentPlayer.Faction
                });
            }
            if (crateCountLabel != null)
            {
                crateCountLabel.Visible = false;
            }
            string[] crateRewardIds = rewardGroup.CrateRewardIds;
            CrateVO  crateVO        = null;

            if (crateRewardIds != null)
            {
                if (crateRewardIds.Length != 0)
                {
                    crateVO = dataController.GetOptional <CrateVO>(rewardGroup.CrateRewardIds[0]);
                }
                if (crateCountLabel != null && crateRewardIds.Length > 1)
                {
                    crateCountLabel.Visible = true;
                    crateCountLabel.Text    = lang.Get("CONFLICT_PRIZE_CRATE_MULTIPLIER", new object[]
                    {
                        crateRewardIds.Length
                    });
                }
            }
            if (crateVO != null)
            {
                RewardUtils.SetCrateIcon(crateSprite, crateVO, AnimState.Idle);
                return;
            }
            Service.Get <StaRTSLogger>().ErrorFormat("Missing crate reward meta data for tournament reward:{0}", new object[]
            {
                rewardGroup.Uid
            });
        }