Exemplo n.º 1
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);
        }
Exemplo n.º 2
0
        private UXElement CreateTileWithPrizeInfo(string id, int count, PrizeType prizeType)
        {
            string title       = null;
            string description = null;
            DeployableShardUnlockController deployableShardUnlockController = Service.DeployableShardUnlockController;
            IGeometryVO geometryVO = TimedEventPrizeUtils.GetFinalUnitFromPrize(prizeType, id);
            int         quality    = 0;

            switch (prizeType)
            {
            case PrizeType.Currency:
                title      = this.lang.Get(id.ToUpper(), new object[0]);
                geometryVO = UXUtils.GetDefaultCurrencyIconVO(id);
                break;

            case PrizeType.Infantry:
            case PrizeType.Hero:
            case PrizeType.Vehicle:
            case PrizeType.Mercenary:
            {
                TroopTypeVO troopTypeVO = (TroopTypeVO)geometryVO;
                quality     = deployableShardUnlockController.GetUpgradeQualityForDeployable(troopTypeVO);
                title       = LangUtils.GetTroopDisplayName(troopTypeVO);
                description = LangUtils.GetTroopDescription(troopTypeVO);
                break;
            }

            case PrizeType.SpecialAttack:
            {
                SpecialAttackTypeVO specialAttackTypeVO = (SpecialAttackTypeVO)geometryVO;
                quality     = deployableShardUnlockController.GetUpgradeQualityForDeployable(specialAttackTypeVO);
                title       = LangUtils.GetStarshipDisplayName(specialAttackTypeVO);
                description = LangUtils.GetStarshipDescription(specialAttackTypeVO);
                break;
            }

            case PrizeType.Crate:
            {
                CrateData crateData        = this.cp.Prizes.Crates.Available[id];
                string    crateDisplayName = LangUtils.GetCrateDisplayName(crateData.CrateId);
                title = this.lang.Get("CRATE_INVENTORY_CRATE_TITLE", new object[]
                    {
                        LangUtils.GetPlanetDisplayName(crateData.PlanetId),
                        crateDisplayName
                    });
                geometryVO = Service.StaticDataController.Get <CrateVO>(crateData.CrateId);
                break;
            }
            }
            return(this.CreateInventoryGridItem(id, prizeType, title, description, count, geometryVO, quality));
        }
Exemplo n.º 3
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);
            }
        }
Exemplo n.º 4
0
        private int GetItemQuality(TroopTypeVO troop, List <string> activeEquipment, DeployableShardUnlockController shardUnlockCtrl)
        {
            string text = null;

            Service.SkinController.GetApplicableSkin(troop, activeEquipment, out text);
            int result;

            if (!string.IsNullOrEmpty(text))
            {
                EquipmentVO equipmentVO = this.sdc.Get <EquipmentVO>(text);
                result = (int)equipmentVO.Quality;
            }
            else
            {
                result = shardUnlockCtrl.GetUpgradeQualityForDeployable(troop);
            }
            return(result);
        }
Exemplo n.º 5
0
        private void AddExpendedItems(BattleEntry entry, string entryItemUid, UXGrid expendedGrid)
        {
            BattleDeploymentData            attackerDeployedData            = entry.AttackerDeployedData;
            DeployableShardUnlockController deployableShardUnlockController = Service.DeployableShardUnlockController;

            if (attackerDeployedData == null)
            {
                return;
            }
            Dictionary <string, int> dictionary = null;

            if (attackerDeployedData.SquadData != null)
            {
                dictionary = new Dictionary <string, int>(attackerDeployedData.SquadData);
            }
            if (attackerDeployedData.TroopData != null)
            {
                foreach (KeyValuePair <string, int> current in attackerDeployedData.TroopData)
                {
                    string key = current.Key;
                    int    num = 0;
                    if (dictionary != null && dictionary.ContainsKey(key))
                    {
                        num = dictionary[key];
                        dictionary.Remove(key);
                    }
                    num += current.Value;
                    TroopTypeVO troop       = this.sdc.Get <TroopTypeVO>(key);
                    int         unitQuality = this.GetItemQuality(troop, entry.AttackerEquipment, deployableShardUnlockController);
                    this.AddExpendedItem(expendedGrid, entryItemUid, key, troop, num, unitQuality, entry);
                }
            }
            if (dictionary != null)
            {
                foreach (KeyValuePair <string, int> current2 in dictionary)
                {
                    if (current2.Value >= 1)
                    {
                        TroopTypeVO troopTypeVO = Service.StaticDataController.Get <TroopTypeVO>(current2.Key);
                        int         unitQuality = deployableShardUnlockController.GetUpgradeQualityForDeployable(troopTypeVO);
                        this.AddExpendedItem(expendedGrid, entryItemUid, current2.Key, troopTypeVO, current2.Value, unitQuality, entry);
                    }
                }
            }
            if (attackerDeployedData.SpecialAttackData != null)
            {
                foreach (KeyValuePair <string, int> current3 in attackerDeployedData.SpecialAttackData)
                {
                    string key2  = current3.Key;
                    int    value = current3.Value;
                    SpecialAttackTypeVO specialAttackTypeVO = this.sdc.Get <SpecialAttackTypeVO>(key2);
                    int unitQuality = deployableShardUnlockController.GetUpgradeQualityForDeployable(specialAttackTypeVO);
                    this.AddExpendedItem(expendedGrid, entryItemUid, key2, specialAttackTypeVO, value, unitQuality, entry);
                }
            }
            if (attackerDeployedData.HeroData != null)
            {
                foreach (KeyValuePair <string, int> current4 in attackerDeployedData.HeroData)
                {
                    string      key3        = current4.Key;
                    int         value2      = current4.Value;
                    TroopTypeVO troop2      = this.sdc.Get <TroopTypeVO>(key3);
                    int         unitQuality = this.GetItemQuality(troop2, entry.AttackerEquipment, deployableShardUnlockController);
                    this.AddExpendedItem(expendedGrid, entryItemUid, key3, troop2, value2, unitQuality, entry);
                }
            }
            if (attackerDeployedData.ChampionData != null)
            {
                foreach (KeyValuePair <string, int> current5 in attackerDeployedData.ChampionData)
                {
                    string      key4        = current5.Key;
                    int         value3      = current5.Value;
                    TroopTypeVO troop3      = this.sdc.Get <TroopTypeVO>(key4);
                    int         unitQuality = 0;
                    this.AddExpendedItem(expendedGrid, entryItemUid, key4, troop3, value3, unitQuality, entry);
                }
            }
        }