Ejemplo n.º 1
0
        private void SetupShardRewardItemElements(string itemUID, CrateSupplyVO crateSupply)
        {
            ShardVO shardVO = Service.Get <IDataController>().Get <ShardVO>(crateSupply.RewardUid);
            int     quality = (int)shardVO.Quality;
            string  name    = string.Format("SpriteTroopImageBkgGridQ{0}", new object[]
            {
                quality
            });

            this.rewardsGrid.GetSubElement <UXElement>(itemUID, name).Visible = false;
            UXSprite subElement = this.rewardsGrid.GetSubElement <UXSprite>(itemUID, "SpriteIconFragmentLootTable");

            UXUtils.SetupFragmentIconSprite(subElement, quality);
            UXSprite      subElement2           = this.rewardsGrid.GetSubElement <UXSprite>(itemUID, "SpriteRewardItemImage");
            IDeployableVO deployableVOFromShard = Service.Get <DeployableShardUnlockController>().GetDeployableVOFromShard(shardVO);

            if (deployableVOFromShard == null)
            {
                Service.Get <StaRTSLogger>().Error("SetupShardRewardItemElements Unable to find deployable");
                return;
            }
            ProjectorConfig projectorConfig = ProjectorUtils.GenerateGeometryConfig(deployableVOFromShard, subElement2, true);

            projectorConfig.AnimPreference = AnimationPreference.AnimationPreferred;
            GeometryProjector item = ProjectorUtils.GenerateProjector(projectorConfig);

            this.projectors.Add(item);
            this.SetupDeployableShardProgress(itemUID, shardVO);
            UXUtils.SetCardQuality(this, this.rewardsGrid, itemUID, quality, "RewardItemCardQ{0}");
        }
Ejemplo n.º 2
0
        public bool IsShardDeployableReadyToUpgrade(string shardId)
        {
            CurrentPlayer            currentPlayer        = Service.CurrentPlayer;
            Dictionary <string, int> shards               = currentPlayer.Shards;
            StaticDataController     staticDataController = Service.StaticDataController;
            ShardVO shardVO = staticDataController.Get <ShardVO>(shardId);
            bool    flag    = shardVO.TargetType == "specialAttack";
            int     num     = 0;

            if (shards.ContainsKey(shardId))
            {
                num += shards[shardId];
            }
            int           upgradeLevelOfDeployable = this.GetUpgradeLevelOfDeployable(shardVO.TargetType, shardVO.TargetGroupId);
            IDeployableVO deployableVOForLevelInGroup;

            if (flag)
            {
                deployableVOForLevelInGroup = this.GetDeployableVOForLevelInGroup <SpecialAttackTypeVO>(upgradeLevelOfDeployable + 1, shardVO.TargetGroupId);
            }
            else
            {
                deployableVOForLevelInGroup = this.GetDeployableVOForLevelInGroup <TroopTypeVO>(upgradeLevelOfDeployable + 1, shardVO.TargetGroupId);
            }
            return(deployableVOForLevelInGroup != null && this.DoesUserHaveUpgradeShardRequirement(deployableVOForLevelInGroup));
        }
Ejemplo n.º 3
0
        private void SetupDeployableShardProgress(string itemUID, ShardVO shard)
        {
            CurrentPlayer          currentPlayer          = Service.Get <CurrentPlayer>();
            TroopUpgradeCatalog    troopUpgradeCatalog    = Service.Get <TroopUpgradeCatalog>();
            StarshipUpgradeCatalog starshipUpgradeCatalog = Service.Get <StarshipUpgradeCatalog>();
            UXSlider subElement  = this.rewardsGrid.GetSubElement <UXSlider>(itemUID, "pBarRewardItemFrag");
            UXSprite subElement2 = this.rewardsGrid.GetSubElement <UXSprite>(itemUID, "SpriteRewardItempBarFrag");

            subElement.Visible = true;
            UXLabel       subElement3 = this.rewardsGrid.GetSubElement <UXLabel>(itemUID, "LabelFragProgress");
            UXElement     subElement4 = this.rewardsGrid.GetSubElement <UXElement>(itemUID, "IconUpgrade");
            IDeployableVO deployableVO;
            IDeployableVO byLevel;

            if (shard.TargetType == "specialAttack")
            {
                int nextLevel = currentPlayer.UnlockedLevels.Starships.GetNextLevel(shard.TargetGroupId);
                deployableVO = starshipUpgradeCatalog.GetByLevel(shard.TargetGroupId, nextLevel);
                byLevel      = starshipUpgradeCatalog.GetByLevel(shard.TargetGroupId, nextLevel - 1);
            }
            else
            {
                int nextLevel = currentPlayer.UnlockedLevels.Troops.GetNextLevel(shard.TargetGroupId);
                deployableVO = troopUpgradeCatalog.GetByLevel(shard.TargetGroupId, nextLevel);
                byLevel      = troopUpgradeCatalog.GetByLevel(shard.TargetGroupId, nextLevel - 1);
            }
            if (deployableVO == null)
            {
                subElement3.Text = this.lang.Get("MAX_LEVEL", new object[0]);
                subElement.Value = 1f;
                return;
            }
            bool flag = Service.Get <UnlockController>().IsMinLevelUnlocked(deployableVO);

            if (!flag)
            {
                deployableVO = byLevel;
            }
            int shardAmount       = Service.Get <DeployableShardUnlockController>().GetShardAmount(deployableVO.UpgradeShardUid);
            int upgradeShardCount = deployableVO.UpgradeShardCount;

            subElement3.Text = this.lang.Get("FRACTION", new object[]
            {
                shardAmount,
                upgradeShardCount
            });
            if (upgradeShardCount == 0)
            {
                Service.Get <StaRTSLogger>().ErrorFormat("CMS Error: Shards required for {0} is zero", new object[]
                {
                    deployableVO.Uid
                });
                return;
            }
            float sliderValue = (float)shardAmount / (float)upgradeShardCount;

            UXUtils.SetShardProgressBarValue(subElement, subElement2, sliderValue);
            subElement4.Visible = (flag && shardAmount >= upgradeShardCount);
        }
Ejemplo n.º 4
0
        private bool GetUnlockShardUIInfoForCurrentItem(out int currentShardAmount, out int increasedShardAmount, out int shardsNeededForLevel, out bool showLevel, out ShardVO unlockShardToDisplay)
        {
            currentShardAmount   = 0;
            increasedShardAmount = 0;
            shardsNeededForLevel = 0;
            unlockShardToDisplay = null;
            showLevel            = false;
            CrateSupplyVO crateSupply = this.currentCrateItem.CrateSupply;
            SupplyType    type        = crateSupply.Type;

            if (type != SupplyType.ShardSpecialAttack && type != SupplyType.ShardTroop)
            {
                return(false);
            }
            ShardVO unlockShard = this.currentCrateItem.UnlockShard;

            if (unlockShard == null)
            {
                return(false);
            }
            unlockShardToDisplay = unlockShard;
            CurrentPlayer currentPlayer = Service.CurrentPlayer;
            DeployableShardUnlockController deployableShardUnlockController = Service.DeployableShardUnlockController;
            string uid           = unlockShard.Uid;
            string targetGroupId = unlockShard.TargetGroupId;
            string targetType    = unlockShard.TargetType;
            int    num           = 0;

            if (targetType == "hero" || targetType == "troop")
            {
                if (this.troopUpgradeOrignal.ContainsKey(targetGroupId))
                {
                    num = this.troopUpgradeOrignal[targetGroupId];
                }
            }
            else if (targetType == "specialAttack" && this.specialAttackUpgradeOrignal.ContainsKey(targetGroupId))
            {
                num = this.specialAttackUpgradeOrignal[targetGroupId];
            }
            int hqLevel      = currentPlayer.Map.FindHighestHqLevel();
            int num2         = (!this.shardsOriginal.ContainsKey(uid)) ? 0 : this.shardsOriginal[uid];
            int rewardAmount = Service.InventoryCrateRewardController.GetRewardAmount(crateSupply, hqLevel);

            currentShardAmount   = num2;
            increasedShardAmount = num2 + rewardAmount;
            showLevel            = (num > 0);
            if (type == SupplyType.ShardSpecialAttack)
            {
                shardsNeededForLevel = deployableShardUnlockController.GetNumShardsForDeployableToReachLevelInGroup <SpecialAttackTypeVO>(num, num + 1, targetGroupId);
            }
            else if (type == SupplyType.ShardTroop)
            {
                shardsNeededForLevel = deployableShardUnlockController.GetNumShardsForDeployableToReachLevelInGroup <TroopTypeVO>(num, num + 1, targetGroupId);
            }
            return(true);
        }
Ejemplo n.º 5
0
        public int GetUpgradeQualityForDeployable(IDeployableVO deployable)
        {
            int    result          = 0;
            string upgradeShardUid = deployable.UpgradeShardUid;

            if (!string.IsNullOrEmpty(upgradeShardUid))
            {
                ShardVO shardVO = Service.StaticDataController.Get <ShardVO>(upgradeShardUid);
                result = (int)shardVO.Quality;
            }
            return(result);
        }
Ejemplo n.º 6
0
        private void AttemptToUpgradeUnitWithShards(string shardId, int level)
        {
            if (level <= 0)
            {
                return;
            }
            CurrentPlayer            currentPlayer        = Service.CurrentPlayer;
            Dictionary <string, int> shards               = currentPlayer.Shards;
            StaticDataController     staticDataController = Service.StaticDataController;
            ShardVO shardVO       = staticDataController.Get <ShardVO>(shardId);
            string  targetType    = shardVO.TargetType;
            string  targetGroupId = shardVO.TargetGroupId;
            bool    flag          = targetType == "specialAttack";
            int     num           = 0;

            if (shards.ContainsKey(shardId))
            {
                num += shards[shardId];
            }
            int startLevel = level - 1;
            int numShardsForDeployableToReachLevelInGroup;

            if (flag)
            {
                numShardsForDeployableToReachLevelInGroup = this.GetNumShardsForDeployableToReachLevelInGroup <SpecialAttackTypeVO>(startLevel, level, targetGroupId);
            }
            else
            {
                numShardsForDeployableToReachLevelInGroup = this.GetNumShardsForDeployableToReachLevelInGroup <TroopTypeVO>(startLevel, level, targetGroupId);
            }
            if (num >= numShardsForDeployableToReachLevelInGroup)
            {
                UnlockedLevelData unlockedLevels = Service.CurrentPlayer.UnlockedLevels;
                IDeployableVO     deployableVOForLevelInGroup;
                if (flag)
                {
                    deployableVOForLevelInGroup = this.GetDeployableVOForLevelInGroup <SpecialAttackTypeVO>(1, targetGroupId);
                }
                else
                {
                    deployableVOForLevelInGroup = this.GetDeployableVOForLevelInGroup <TroopTypeVO>(1, targetGroupId);
                }
                if (deployableVOForLevelInGroup == null)
                {
                    return;
                }
                unlockedLevels.UpgradeTroopsOrStarships(deployableVOForLevelInGroup.Uid, flag);
                currentPlayer.ModifyShardAmount(shardId, num - numShardsForDeployableToReachLevelInGroup);
                Service.EventManager.SendEvent(EventId.ShardUnitUpgraded, deployableVOForLevelInGroup);
            }
        }
Ejemplo n.º 7
0
        public static void HandleCrateSupplyRewardClicked(CrateSupplyVO crateSupply)
        {
            IDataController dataController = Service.Get <IDataController>();
            DeployableShardUnlockController deployableShardUnlockController = Service.Get <DeployableShardUnlockController>();
            IDeployableVO deployableVO = null;
            EquipmentVO   equipmentVO  = null;

            switch (crateSupply.Type)
            {
            case SupplyType.Shard:
                equipmentVO = ArmoryUtils.GetCurrentEquipmentDataByID(crateSupply.RewardUid);
                break;

            case SupplyType.Troop:
            case SupplyType.Hero:
                deployableVO = dataController.Get <TroopTypeVO>(crateSupply.RewardUid);
                break;

            case SupplyType.SpecialAttack:
                deployableVO = dataController.Get <SpecialAttackTypeVO>(crateSupply.RewardUid);
                break;

            case SupplyType.ShardTroop:
            case SupplyType.ShardSpecialAttack:
            {
                ShardVO shard = dataController.Get <ShardVO>(crateSupply.RewardUid);
                deployableVO = deployableShardUnlockController.GetDeployableVOFromShard(shard);
                break;
            }
            }
            Entity availableTroopResearchLab = Service.Get <BuildingLookupController>().GetAvailableTroopResearchLab();

            if (deployableVO != null)
            {
                Service.Get <EventManager>().SendEvent(EventId.LootTableUnitInfoTapped, deployableVO.Uid);
                TroopUpgradeTag      troopUpgradeTag     = new TroopUpgradeTag(deployableVO, true);
                bool                 showUpgradeControls = !string.IsNullOrEmpty(troopUpgradeTag.Troop.UpgradeShardUid);
                DeployableInfoScreen screen = new DeployableInfoScreen(troopUpgradeTag, null, showUpgradeControls, availableTroopResearchLab);
                Service.Get <ScreenController>().AddScreen(screen);
                return;
            }
            if (equipmentVO != null)
            {
                EquipmentInfoScreen screen2 = new EquipmentInfoScreen(equipmentVO, null, availableTroopResearchLab, true);
                Service.Get <ScreenController>().AddScreen(screen2);
            }
        }
Ejemplo n.º 8
0
        public void GrantUnlockShards(string shardId, int count)
        {
            CurrentPlayer            currentPlayer        = Service.CurrentPlayer;
            Dictionary <string, int> shards               = currentPlayer.Shards;
            StaticDataController     staticDataController = Service.StaticDataController;
            ShardVO shardVO       = staticDataController.Get <ShardVO>(shardId);
            string  targetType    = shardVO.TargetType;
            string  targetGroupId = shardVO.TargetGroupId;
            int     num           = count;

            if (shards.ContainsKey(shardId))
            {
                num += shards[shardId];
            }
            currentPlayer.ModifyShardAmount(shardId, num);
            int upgradeLevelOfDeployable = this.GetUpgradeLevelOfDeployable(targetType, targetGroupId);

            if (upgradeLevelOfDeployable == 0)
            {
                this.AttemptToUpgradeUnitWithShards(shardId, 1);
            }
            else
            {
                IDeployableVO deployableVOForLevelInGroup = this.GetDeployableVOForLevelInGroup(upgradeLevelOfDeployable, targetType, targetGroupId);
                if (deployableVOForLevelInGroup == null)
                {
                    Service.Logger.ErrorFormat("No deployableVO found for targetType: {0}, targetGroup: {1}, upgradeLevel: {2}", new object[]
                    {
                        targetType,
                        targetGroupId,
                        upgradeLevelOfDeployable
                    });
                    return;
                }
                if (num - count < deployableVOForLevelInGroup.UpgradeShardCount && num >= deployableVOForLevelInGroup.UpgradeShardCount)
                {
                    this.AllowResearchBuildingBadging = true;
                    Service.EventManager.SendEvent(EventId.ShardUnitNowUpgradable, deployableVOForLevelInGroup.Uid);
                }
            }
        }
Ejemplo n.º 9
0
        public static void TrySetupItemQualityView(CrateSupplyVO supplyData, UXElement unitElement, UXElement basicElement, UXElement advancedElement, UXElement eliteElement, UXElement defaultElement)
        {
            if (supplyData == null)
            {
                return;
            }
            unitElement.Visible     = false;
            basicElement.Visible    = false;
            advancedElement.Visible = false;
            eliteElement.Visible    = false;
            bool         flag         = false;
            ShardQuality shardQuality = ShardQuality.Basic;

            if (supplyData.Type == SupplyType.ShardTroop || supplyData.Type == SupplyType.ShardSpecialAttack)
            {
                ShardVO optional = Service.StaticDataController.GetOptional <ShardVO>(supplyData.RewardUid);
                shardQuality = optional.Quality;
                flag         = true;
            }
            else if (supplyData.Type == SupplyType.Shard)
            {
                EquipmentVO currentEquipmentDataByID = ArmoryUtils.GetCurrentEquipmentDataByID(supplyData.RewardUid);
                shardQuality = currentEquipmentDataByID.Quality;
                flag         = true;
            }
            if (flag)
            {
                unitElement.Visible     = (shardQuality == ShardQuality.Unit);
                basicElement.Visible    = (shardQuality == ShardQuality.Basic);
                advancedElement.Visible = (shardQuality == ShardQuality.Advanced);
                eliteElement.Visible    = (shardQuality == ShardQuality.Elite);
            }
            if (defaultElement != null)
            {
                defaultElement.Visible = !flag;
            }
        }
Ejemplo n.º 10
0
        public IDeployableVO GetDeployableVOFromShard(ShardVO shard)
        {
            if (shard == null)
            {
                return(null);
            }
            int num = this.GetUpgradeLevelOfDeployable(shard.TargetType, shard.TargetGroupId);

            if (num < 1)
            {
                num = 1;
            }
            IDeployableVO deployableVOForLevelInGroup;

            if (shard.TargetType == "specialAttack")
            {
                deployableVOForLevelInGroup = this.GetDeployableVOForLevelInGroup <SpecialAttackTypeVO>(num, shard.TargetGroupId);
            }
            else
            {
                deployableVOForLevelInGroup = this.GetDeployableVOForLevelInGroup <TroopTypeVO>(num, shard.TargetGroupId);
            }
            return(deployableVOForLevelInGroup);
        }
Ejemplo n.º 11
0
        public string GetCrateSupplyRewardName(CrateSupplyVO supplyData)
        {
            string text = string.Empty;

            if (supplyData == null)
            {
                return(text);
            }
            Lang            lang           = Service.Get <Lang>();
            IDataController dataController = Service.Get <IDataController>();
            string          rewardUid      = supplyData.RewardUid;
            SupplyType      type           = supplyData.Type;

            switch (type)
            {
            case SupplyType.Currency:
                text = lang.Get(supplyData.RewardUid.ToUpper(), new object[0]);
                break;

            case SupplyType.Shard:
            {
                EquipmentVO currentEquipmentDataByID = ArmoryUtils.GetCurrentEquipmentDataByID(rewardUid);
                if (currentEquipmentDataByID != null)
                {
                    text = lang.Get(currentEquipmentDataByID.EquipmentName, new object[0]);
                }
                break;
            }

            case SupplyType.Troop:
            case SupplyType.Hero:
            {
                TroopTypeVO optional = dataController.GetOptional <TroopTypeVO>(rewardUid);
                if (optional != null)
                {
                    text = LangUtils.GetTroopDisplayName(optional);
                }
                break;
            }

            case SupplyType.SpecialAttack:
            {
                SpecialAttackTypeVO optional2 = dataController.GetOptional <SpecialAttackTypeVO>(rewardUid);
                if (optional2 != null)
                {
                    text = LangUtils.GetStarshipDisplayName(optional2);
                }
                break;
            }

            case SupplyType.ShardTroop:
            {
                ShardVO optional3 = dataController.GetOptional <ShardVO>(rewardUid);
                if (optional3 != null)
                {
                    text = LangUtils.GetTroopDisplayNameFromTroopID(optional3.TargetGroupId);
                }
                break;
            }

            case SupplyType.ShardSpecialAttack:
            {
                ShardVO optional4 = dataController.GetOptional <ShardVO>(rewardUid);
                if (optional4 != null)
                {
                    text = LangUtils.GetStarshipDisplayNameFromAttackID(optional4.TargetGroupId);
                }
                break;
            }
            }
            if (string.IsNullOrEmpty(text))
            {
                Service.Get <StaRTSLogger>().ErrorFormat("CrateSupplyVO Uid:{0}, Cannot find reward for RewardUid:{1}, Type:{2}", new object[]
                {
                    supplyData.Uid,
                    rewardUid,
                    type
                });
            }
            return(text);
        }
Ejemplo n.º 12
0
        private void SetupCrateReward(string itemUid, TournamentRewardsVO rewardGroup, UXGrid rewardGrid, UXElement rewardItem, string rewardSuffix, CrateFlyoutItemVO crateFlyoutItemVO)
        {
            IDataController dataController = Service.Get <IDataController>();
            CurrentPlayer   currentPlayer  = Service.Get <CurrentPlayer>();
            UXButton        uXButton       = rewardItem as UXButton;
            UXSprite        subElement     = rewardGrid.GetSubElement <UXSprite>(itemUid, "SpriteFragmentIcon" + rewardSuffix);

            UXUtils.HideAllQualityCards(rewardGrid, itemUid, "EquipmentItemCardQ{0}" + rewardSuffix);
            UXElement subElement2 = rewardGrid.GetSubElement <UXElement>(itemUid, "ParticlesTopPrize" + rewardSuffix);

            subElement2.Visible = false;
            uXButton.Enabled    = false;
            subElement.Visible  = false;
            CrateSupplyVO optional = dataController.GetOptional <CrateSupplyVO>(crateFlyoutItemVO.CrateSupplyUid);

            if (optional == null)
            {
                Service.Get <StaRTSLogger>().ErrorFormat("Could not find crate supply {0} for faction {1}", new object[]
                {
                    crateFlyoutItemVO.CrateSupplyUid,
                    currentPlayer.Faction
                });
                return;
            }
            bool     flag        = crateFlyoutItemVO.TournamentTierDisplay3D && optional.Type != SupplyType.Currency && optional.Type != SupplyType.Invalid;
            int      num         = currentPlayer.Map.FindHighestHqLevel();
            UXSprite subElement3 = rewardGrid.GetSubElement <UXSprite>(itemUid, "SpriteReward2D" + rewardSuffix);

            subElement3.Visible = false;
            if (flag)
            {
                IGeometryVO iconVOFromCrateSupply = GameUtils.GetIconVOFromCrateSupply(optional, num);
                if (iconVOFromCrateSupply != null)
                {
                    UXSprite        subElement4     = rewardGrid.GetSubElement <UXSprite>(itemUid, "SpriteEquipmentItemImage" + rewardSuffix);
                    ProjectorConfig projectorConfig = ProjectorUtils.GenerateGeometryConfig(iconVOFromCrateSupply, subElement4, true);
                    projectorConfig.AnimPreference = AnimationPreference.AnimationPreferred;
                    ProjectorUtils.GenerateProjector(projectorConfig);
                    if (rewardGroup.TournamentTier == this.tiers[0].Uid)
                    {
                        this.particleElements.Add(subElement2.Root.name);
                    }
                }
                else
                {
                    Service.Get <StaRTSLogger>().ErrorFormat("Could not generate geometry for crate supply {0}", new object[]
                    {
                        optional.Uid
                    });
                }
                uXButton.Tag       = optional;
                uXButton.OnClicked = new UXButtonClickedDelegate(this.OnGuaranteedRewardClicked);
                uXButton.Enabled   = true;
            }
            else
            {
                subElement3.Visible = true;
                int num2 = crateFlyoutItemVO.ListIcons.Length - 1;
                subElement3.SpriteName = crateFlyoutItemVO.ListIcons[num2];
                rewardGrid.GetSubElement <UXElement>(itemUid, "SpriteEquipmentGradient" + rewardSuffix).Visible       = false;
                rewardGrid.GetSubElement <UXElement>(itemUid, "SpriteEquipmentGradientBottom" + rewardSuffix).Visible = false;
                rewardGrid.GetSubElement <UXElement>(itemUid, "SpriteEquipmentImageBkg" + rewardSuffix).Visible       = false;
                rewardGrid.GetSubElement <UXElement>(itemUid, "SpriteFrameHover" + rewardSuffix).Visible = false;
            }
            UXLabel subElement5    = rewardGrid.GetSubElement <UXLabel>(itemUid, "LabelPrizeCount" + rewardSuffix);
            int     rewardAmount   = Service.Get <InventoryCrateRewardController>().GetRewardAmount(optional, num);
            int     num3           = rewardGroup.CrateRewardIds.Length;
            string  text           = this.lang.ThousandsSeparated(rewardAmount * num3);
            string  quantityString = crateFlyoutItemVO.QuantityString;

            if (!string.IsNullOrEmpty(quantityString))
            {
                subElement5.Text = this.lang.Get(quantityString, new object[]
                {
                    text
                });
            }
            else if (rewardAmount > 0)
            {
                subElement5.Text = this.lang.Get("CONFLICT_PRIZE_CRATE_MULTIPLIER", new object[]
                {
                    text
                });
            }
            else
            {
                subElement5.Visible = false;
            }
            int  num4    = -1;
            bool visible = false;

            if (optional.Type == SupplyType.ShardSpecialAttack || optional.Type == SupplyType.ShardTroop)
            {
                ShardVO optional2 = dataController.GetOptional <ShardVO>(optional.RewardUid);
                if (optional2 != null)
                {
                    num4 = (int)optional2.Quality;
                }
            }
            else if (optional.Type == SupplyType.Shard)
            {
                EquipmentVO currentEquipmentDataByID = ArmoryUtils.GetCurrentEquipmentDataByID(optional.RewardUid);
                if (currentEquipmentDataByID != null)
                {
                    num4    = (int)currentEquipmentDataByID.Quality;
                    visible = true;
                }
            }
            else if (optional.Type == SupplyType.Troop || optional.Type == SupplyType.Hero || optional.Type == SupplyType.SpecialAttack)
            {
                num4 = Service.Get <DeployableShardUnlockController>().GetUpgradeQualityForDeployableUID(optional.RewardUid);
            }
            if (num4 > 0 & flag)
            {
                subElement.Visible    = true;
                subElement.SpriteName = string.Format("icoDataFragQ{0}", new object[]
                {
                    num4
                });
                string text2 = string.Format("SpriteEquipmentImageBkgGridQ{0}", new object[]
                {
                    num4
                });
                rewardGrid.GetSubElement <UXElement>(itemUid, text2 + rewardSuffix).Visible = visible;
                UXUtils.SetCardQuality(this, rewardGrid, itemUid, num4, "EquipmentItemCardQ{0}" + rewardSuffix);
            }
        }
Ejemplo n.º 13
0
        private void UpdateRewardUI(CrateFlyoutItemVO crateFlyoutItemVO)
        {
            IDataController dataController = Service.Get <IDataController>();
            InventoryCrateRewardController inventoryCrateRewardController = Service.Get <InventoryCrateRewardController>();
            string        crateSupplyUid = crateFlyoutItemVO.CrateSupplyUid;
            CrateSupplyVO optional       = dataController.GetOptional <CrateSupplyVO>(crateSupplyUid);

            if (optional != null)
            {
                base.GetElement <UXElement>("RewardItemDefault").Visible = false;
                for (int i = 1; i <= 3; i++)
                {
                    base.GetElement <UXElement>(string.Format("RewardItemCardQ{0}", new object[]
                    {
                        i
                    })).Visible = false;
                }
                if (optional.Type == SupplyType.ShardTroop || optional.Type == SupplyType.ShardSpecialAttack)
                {
                    ShardVO optional2 = Service.Get <IDataController>().GetOptional <ShardVO>(optional.RewardUid);
                    int     quality   = (int)optional2.Quality;
                    base.GetElement <UXElement>(string.Format("RewardItemCardQ{0}", new object[]
                    {
                        quality
                    })).Visible = true;
                    base.GetElement <UXElement>(string.Format("SpriteTroopImageBkgGridQ{0}", new object[]
                    {
                        quality
                    })).Visible = false;
                }
                else if (optional.Type == SupplyType.Shard)
                {
                    EquipmentVO currentEquipmentDataByID = ArmoryUtils.GetCurrentEquipmentDataByID(optional.RewardUid);
                    int         quality2 = (int)currentEquipmentDataByID.Quality;
                    base.GetElement <UXElement>(string.Format("RewardItemCardQ{0}", new object[]
                    {
                        quality2
                    })).Visible = true;
                    base.GetElement <UXElement>(string.Format("SpriteTroopImageBkgGridQ{0}", new object[]
                    {
                        quality2
                    })).Visible = true;
                }
                else if (optional.Type == SupplyType.Troop || optional.Type == SupplyType.Hero || optional.Type == SupplyType.SpecialAttack)
                {
                    int upgradeQualityForDeployableUID = Service.Get <DeployableShardUnlockController>().GetUpgradeQualityForDeployableUID(optional.RewardUid);
                    if (upgradeQualityForDeployableUID > 0)
                    {
                        base.GetElement <UXElement>(string.Format("RewardItemCardQ{0}", new object[]
                        {
                            upgradeQualityForDeployableUID
                        })).Visible = true;
                        base.GetElement <UXElement>(string.Format("SpriteTroopImageBkgGridQ{0}", new object[]
                        {
                            upgradeQualityForDeployableUID
                        })).Visible = false;
                    }
                }
                else
                {
                    base.GetElement <UXElement>("RewardItemDefault").Visible = true;
                }
                IGeometryVO iconVOFromCrateSupply = GameUtils.GetIconVOFromCrateSupply(optional, this.hqLevel);
                if (iconVOFromCrateSupply != null)
                {
                    ProjectorConfig projectorConfig = ProjectorUtils.GenerateGeometryConfig(iconVOFromCrateSupply, this.spriteRewardImage, true);
                    projectorConfig.AnimPreference = AnimationPreference.AnimationPreferred;
                    ProjectorUtils.GenerateProjector(projectorConfig);
                }
                else
                {
                    Service.Get <StaRTSLogger>().ErrorFormat("CrateInfoModalScreen: Could not generate geometry for crate supply {0}", new object[]
                    {
                        optional.Uid
                    });
                }
                this.labelRewardChance.Text = this.lang.Get(crateFlyoutItemVO.DetailChanceString, new object[0]);
                this.labelRewardName.Text   = this.lang.Get(crateFlyoutItemVO.DetailDescString, new object[0]);
                string[] listIcons = crateFlyoutItemVO.ListIcons;
                if (listIcons != null && listIcons.Length != 0)
                {
                    this.spriteRewardIcon.SpriteName = listIcons[listIcons.Length - 1];
                }
                else
                {
                    this.spriteRewardIcon.Visible = false;
                }
                string detailTypeStringId = crateFlyoutItemVO.DetailTypeStringId;
                if (!string.IsNullOrEmpty(detailTypeStringId))
                {
                    this.labelRewardType.Visible = true;
                    string text = this.lang.Get(detailTypeStringId, new object[0]);
                    this.labelRewardType.Text = text;
                }
                else
                {
                    this.labelRewardType.Visible = false;
                }
                int    rewardAmount   = inventoryCrateRewardController.GetRewardAmount(optional, this.hqLevel);
                string text2          = this.lang.ThousandsSeparated(rewardAmount);
                string quantityString = crateFlyoutItemVO.QuantityString;
                if (!string.IsNullOrEmpty(quantityString))
                {
                    this.labelRewardAmt.Text = this.lang.Get(quantityString, new object[]
                    {
                        text2
                    });
                }
                else if (rewardAmount > 1)
                {
                    this.labelRewardAmt.Text = this.lang.Get("lcfly_quant", new object[]
                    {
                        text2
                    });
                }
                else
                {
                    this.labelRewardAmt.Visible = false;
                }
                UXSprite element  = base.GetElement <UXSprite>("SpriteLockIcon");
                UXSprite element2 = base.GetElement <UXSprite>("SpriteRewardDim");
                UXLabel  element3 = base.GetElement <UXLabel>("LabelEquipmentRequirement");
                element.Visible  = false;
                element2.Visible = false;
                element3.Visible = false;
                bool flag = crateFlyoutItemVO.ReqArmory && !ArmoryUtils.PlayerHasArmory();
                if (flag)
                {
                    element2.Visible = true;
                    element.Visible  = true;
                    element3.Visible = true;
                    element3.Text    = this.lang.Get("EQUIPMENT_ARMORY_REQUIRED", new object[0]);
                }
                this.UpdateRowHighlight(crateFlyoutItemVO.Uid, true);
                return;
            }
            Service.Get <StaRTSLogger>().ErrorFormat("CrateInfoModalScreen: Could not find crate supply {0} for crate flyout {1}", new object[]
            {
                crateSupplyUid,
                crateFlyoutItemVO.Uid
            });
        }
Ejemplo n.º 14
0
        public InventoryCrateAnimation(List <CrateSupplyVO> supplyTableDataList, CrateData crateData, Dictionary <string, int> shardsOriginal, Dictionary <string, int> equipmentOriginal, Dictionary <string, int> troopUpgradeOriginalCopy, Dictionary <string, int> specialAttackUpgradeOriginalCopy)
        {
            List <string> assetNames = new List <string>();
            List <object> cookies    = new List <object>();

            this.assetHandles        = new List <AssetHandle>();
            this.supplyCrateDataList = new List <SupplyCrateTag>();
            this.hq     = crateData.HQLevel;
            this.screen = new InventoryCrateCollectionScreen(this, crateData);
            StaticDataController staticDataController = Service.StaticDataController;

            this.crateVO                     = staticDataController.Get <CrateVO>(crateData.CrateId);
            this.shardsOriginal              = shardsOriginal;
            this.equipmentOriginal           = equipmentOriginal;
            this.troopUpgradeOrignal         = troopUpgradeOriginalCopy;
            this.specialAttackUpgradeOrignal = specialAttackUpgradeOriginalCopy;
            this.crateAnimState              = InventoryCrateAnimationState.Falling;
            this.crateLandTimer              = 0u;
            this.playOpenOnLanding           = false;
            this.isSkippingReward            = false;
            this.rewardAnimStarted           = false;
            this.rewardAnimEventReceived     = false;
            this.IsLoaded                    = false;
            int i     = 0;
            int count = supplyTableDataList.Count;

            while (i < count)
            {
                SupplyCrateTag supplyCrateTag = new SupplyCrateTag();
                CrateSupplyVO  crateSupplyVO  = supplyTableDataList[i];
                SupplyType     type           = crateSupplyVO.Type;
                supplyCrateTag.CrateSupply = crateSupplyVO;
                this.supplyCrateDataList.Add(supplyCrateTag);
                if (type != SupplyType.Currency)
                {
                    IGeometryVO iconVOFromCrateSupply = GameUtils.GetIconVOFromCrateSupply(crateSupplyVO, this.hq);
                    this.AddAssetToLoadList(assetNames, cookies, iconVOFromCrateSupply.IconAssetName);
                    ProjectorConfig projectorConfig;
                    if (iconVOFromCrateSupply is EquipmentVO)
                    {
                        EquipmentVO equipmentVO = (EquipmentVO)iconVOFromCrateSupply;
                        supplyCrateTag.Equipment    = equipmentVO;
                        supplyCrateTag.ShardQuailty = equipmentVO.Quality;
                        projectorConfig             = ProjectorUtils.GenerateEquipmentConfig(iconVOFromCrateSupply as EquipmentVO, new Action <RenderTexture, ProjectorConfig>(this.RenderTextureCompleteCallback), 256f, 256f);
                    }
                    else
                    {
                        if (type == SupplyType.ShardSpecialAttack || type == SupplyType.ShardTroop)
                        {
                            ShardVO shardVO = staticDataController.Get <ShardVO>(crateSupplyVO.RewardUid);
                            supplyCrateTag.ShardQuailty = shardVO.Quality;
                            supplyCrateTag.UnlockShard  = shardVO;
                        }
                        projectorConfig = ProjectorUtils.GenerateGeometryConfig(iconVOFromCrateSupply, new Action <RenderTexture, ProjectorConfig>(this.RenderTextureCompleteCallback), 256f, 256f);
                    }
                    projectorConfig.AnimPreference = AnimationPreference.AnimationPreferred;
                    supplyCrateTag.Config          = projectorConfig;
                    supplyCrateTag.Projector       = ProjectorUtils.GenerateProjector(projectorConfig);
                }
                i++;
            }
            this.AddAssetToLoadList(assetNames, cookies, this.crateVO.RewardAnimationAssetName);
            this.AddAssetToLoadList(assetNames, cookies, "crate_controller");
            Service.AssetManager.MultiLoad(this.assetHandles, assetNames, new AssetSuccessDelegate(this.LoadSuccess), new AssetFailureDelegate(this.LoadFailed), cookies, new AssetsCompleteDelegate(this.AssetsCompleteDelegate), null);
        }
Ejemplo n.º 15
0
        private void AddUpgradeableItemToTroopGrid(IDeployableVO nextTroop, IDeployableVO currentTroop, int sortOrder)
        {
            string    uid        = nextTroop.Uid;
            UXElement uXElement  = this.troopGrid.CloneTemplateItem(uid);
            UXLabel   subElement = this.troopGrid.GetSubElement <UXLabel>(uid, "LabelTroopLevel");

            subElement.Text = LangUtils.GetLevelText(currentTroop.Lvl);
            UXElement subElement2 = this.troopGrid.GetSubElement <UXElement>(uid, "CardDefault");
            UXElement subElement3 = this.troopGrid.GetSubElement <UXElement>(uid, "CardQuality");
            string    text        = null;
            string    text2       = null;
            bool      flag        = !nextTroop.PlayerFacing || nextTroop.Lvl == currentTroop.Lvl;
            bool      flag2;

            if (flag)
            {
                flag2 = false;
                text  = this.lang.Get("MAX_LEVEL", new object[0]);
                text2 = text;
            }
            else
            {
                flag2 = Service.UnlockController.CanDeployableBeUpgraded(currentTroop, nextTroop, out text, out text2);
            }
            this.troopGrid.GetSubElement <UXSprite>(uid, "SpriteDim").Visible             = !flag2;
            this.troopGrid.GetSubElement <UXSprite>(uid, "SpriteIconLockedTroop").Visible = (!flag2 && !flag);
            UXSprite subElement4 = this.troopGrid.GetSubElement <UXSprite>(uid, "SpriteFragmentTroop");
            bool     flag3       = !string.IsNullOrEmpty(currentTroop.UpgradeShardUid);

            if (flag3)
            {
                subElement2.Visible = false;
                subElement3.Visible = true;
                subElement4.Visible = true;
                ShardVO   shardVO            = this.dataController.Get <ShardVO>(currentTroop.UpgradeShardUid);
                int       quality            = (int)shardVO.Quality;
                string    name               = string.Format("CardQ10", quality);
                UXElement optionalSubElement = this.troopGrid.GetOptionalSubElement <UXElement>(uid, name);
                if (optionalSubElement != null)
                {
                    base.RevertToOriginalNameRecursively(optionalSubElement.Root, uid);
                    optionalSubElement.Visible = true;
                }
                UXUtils.SetupFragmentIconSprite(subElement4, quality);
                IDeployableVO troopType = currentTroop;
                if (Service.UnlockController.IsMinLevelUnlocked(currentTroop))
                {
                    troopType = nextTroop;
                }
                this.SetupTroopShardProgressBar(uid, troopType, flag);
            }
            else
            {
                subElement4.Visible = false;
                subElement2.Visible = true;
                subElement3.Visible = false;
            }
            UXLabel subElement5 = this.troopGrid.GetSubElement <UXLabel>(uid, "LabelRequirement");

            subElement5.Visible = !flag2;
            if (!flag2)
            {
                subElement5.Text = text2;
            }
            UXSlider subElement6 = this.troopGrid.GetSubElement <UXSlider>(uid, "pBarUpgradeTime");

            subElement6.Visible = false;
            UXLabel subElement7 = this.troopGrid.GetSubElement <UXLabel>(uid, "LabelpBarUpgradeTime");

            subElement7.Visible = false;
            UXSlider subElement8 = this.troopGrid.GetSubElement <UXSlider>(uid, "pBarUpgradeTimeQuality");

            subElement8.Visible = false;
            UXLabel subElement9 = this.troopGrid.GetSubElement <UXLabel>(uid, "LabelpBarUpgradeTimeQuality");

            subElement9.Visible = false;
            string text3 = "SpriteTroopItemImage";

            if (flag3)
            {
                text3 += "Quality";
            }
            UXSprite        subElement10 = this.troopGrid.GetSubElement <UXSprite>(uid, text3);
            ProjectorConfig config       = ProjectorUtils.GenerateGeometryConfig(nextTroop, subElement10, true);

            ProjectorUtils.GenerateProjector(config);
            FactionDecal.SetDeployableDecalVisibiliy(uid, this.troopGrid, false);
            TroopUpgradeTag troopUpgradeTag = new TroopUpgradeTag(nextTroop, flag2);

            troopUpgradeTag.IsMaxLevel           = flag;
            troopUpgradeTag.RequirementText      = text;
            troopUpgradeTag.ShortRequirementText = text2;
            UXButton subElement11 = this.troopGrid.GetSubElement <UXButton>(uid, "ButtonTroopItemCard");

            subElement11.Tag       = troopUpgradeTag;
            subElement11.OnClicked = new UXButtonClickedDelegate(this.OnTroopCardClicked);
            uXElement.Tag          = troopUpgradeTag;
            this.troopGrid.AddItem(uXElement, sortOrder);
        }
Ejemplo n.º 16
0
        public ShardShopViewTO GenerateViewTO(int index, CurrentPlayer player, ShardShopData data)
        {
            StaticDataController staticDataController = Service.StaticDataController;
            int             playerHQLevel             = player.Map.FindHighestHqLevel();
            ShardShopViewTO shardShopViewTO           = new ShardShopViewTO();
            string          shardSlotId = GameUtils.GetShardSlotId(index);
            int             num         = 0;

            foreach (int current in data.Purchases[index].Values)
            {
                num += current;
            }
            int num2 = this.adjustedOfferQuantity[index] - num;

            shardShopViewTO.SlotIndex = index;
            shardShopViewTO.SupplyVO  = data.ShardOffers[shardSlotId];
            shardShopViewTO.RemainingShardsForSale = num2;
            if (num2 > 0)
            {
                shardShopViewTO.CostOfNextShard = ShardShopController.CalculateCost(index, 1, data);
                shardShopViewTO.CostOfAllShards = ShardShopController.CalculateCost(index, num2, data);
            }
            shardShopViewTO.CanAffordSingle       = CostUtils.HasRequiredCurrency(player, shardShopViewTO.CostOfNextShard);
            shardShopViewTO.CanAffordAll          = CostUtils.HasRequiredCurrency(player, shardShopViewTO.CostOfAllShards);
            shardShopViewTO.PlayerHQLevel         = playerHQLevel;
            shardShopViewTO.ItemName              = GameUtils.GetShardShopNameWithoutQuantity(shardShopViewTO.SupplyVO, staticDataController);
            shardShopViewTO.Quality               = GameUtils.GetShardQualityNumeric(shardShopViewTO.SupplyVO);
            shardShopViewTO.UpgradeShardsEarned   = GameUtils.GetUpgradeShardsOwned(shardShopViewTO.SupplyVO, player);
            shardShopViewTO.UpgradeShardsRequired = GameUtils.GetUpgradeShardsRequired(shardShopViewTO.SupplyVO, player, staticDataController);
            shardShopViewTO.State = "unlocked";
            SupplyType type = shardShopViewTO.SupplyVO.Type;

            if (this.adjustedOfferQuantity[index] < 1)
            {
                shardShopViewTO.State = "maxedOut";
            }
            else if (num2 < 1)
            {
                shardShopViewTO.State = "soldOut";
            }
            else if (type == SupplyType.Shard && !ArmoryUtils.PlayerHasArmory())
            {
                shardShopViewTO.State = "requiresArmory";
            }
            else if (type == SupplyType.ShardTroop)
            {
                ShardVO             shardVO             = staticDataController.Get <ShardVO>(shardShopViewTO.SupplyVO.RewardUid);
                TroopUpgradeCatalog troopUpgradeCatalog = Service.TroopUpgradeCatalog;
                TroopTypeVO         byLevel             = troopUpgradeCatalog.GetByLevel(shardVO.TargetGroupId, 1);
                if (byLevel != null && byLevel.Type == TroopType.Mercenary && !Service.BuildingLookupController.HasCantina())
                {
                    shardShopViewTO.State = "requiresCantina";
                }
            }
            if (type == SupplyType.Shard)
            {
                EquipmentUpgradeCatalog equipmentUpgradeCatalog  = Service.EquipmentUpgradeCatalog;
                EquipmentVO             currentEquipmentDataByID = ArmoryUtils.GetCurrentEquipmentDataByID(shardShopViewTO.SupplyVO.RewardUid);
                int shards = player.GetShards(shardShopViewTO.SupplyVO.RewardUid);
                int shardsRequiredForNextUpgrade = ArmoryUtils.GetShardsRequiredForNextUpgrade(player, equipmentUpgradeCatalog, currentEquipmentDataByID);
                shardShopViewTO.Upgradeable = (shards >= shardsRequiredForNextUpgrade && shardsRequiredForNextUpgrade > 0);
            }
            else if (type == SupplyType.ShardTroop || type == SupplyType.ShardSpecialAttack)
            {
                shardShopViewTO.Upgradeable = Service.DeployableShardUnlockController.IsShardDeployableReadyToUpgrade(shardShopViewTO.SupplyVO.RewardUid);
            }
            return(shardShopViewTO);
        }