Exemplo n.º 1
0
 private bool VerifyUpgradeData(IUpgradeableVO currentVO, IUpgradeableVO nextVO)
 {
     if (currentVO == null || nextVO == null)
     {
         Service.Get <StaRTSLogger>().ErrorFormat("Deployable upgrade data is null '{0}' '{1}'", new object[]
         {
             (currentVO == null) ? "null" : currentVO.GetType().ToString(),
             (nextVO == null) ? "null" : nextVO.GetType().ToString()
         });
         return(false);
     }
     if (currentVO.GetType() != nextVO.GetType())
     {
         Service.Get <StaRTSLogger>().ErrorFormat("Deployable upgrade type differs from next type: {0} {1} {2} vs {3} {4} {5}", new object[]
         {
             currentVO.GetType(),
             currentVO.UpgradeGroup,
             currentVO.Lvl,
             nextVO.GetType(),
             nextVO.UpgradeGroup,
             nextVO.Lvl
         });
         return(false);
     }
     return(true);
 }
Exemplo n.º 2
0
        public int GetCurrentLevelUnlockedByReward(IUpgradeableVO vo)
        {
            int result = 0;

            if (this.RequiresUnlockByEventReward(vo))
            {
                LevelMap levelMap = null;
                if (vo is BuildingTypeVO)
                {
                    levelMap = this.currentPlayer.UnlockedLevels.Buildings;
                }
                else if (vo is TroopTypeVO)
                {
                    levelMap = this.currentPlayer.UnlockedLevels.Troops;
                }
                else if (vo is SpecialAttackTypeVO)
                {
                    levelMap = this.currentPlayer.UnlockedLevels.Starships;
                }
                if (levelMap != null)
                {
                    result = (levelMap.Has(vo) ? levelMap.GetLevel(vo.UpgradeGroup) : 0);
                }
            }
            return(result);
        }
Exemplo n.º 3
0
        public static void UpgradeTroopsOrStarshipsInventory(InventoryStorage storage, bool isStarship, string productUpgradeGroup, string productUid)
        {
            IDataController dataController = Service.Get <IDataController>();
            Dictionary <string, InventoryEntry> internalStorage = storage.GetInternalStorage();
            int num = 0;

            foreach (string current in internalStorage.Keys)
            {
                IUpgradeableVO arg_43_0;
                if (!isStarship)
                {
                    IUpgradeableVO upgradeableVO = dataController.Get <TroopTypeVO>(current);
                    arg_43_0 = upgradeableVO;
                }
                else
                {
                    IUpgradeableVO upgradeableVO = dataController.Get <SpecialAttackTypeVO>(current);
                    arg_43_0 = upgradeableVO;
                }
                IUpgradeableVO upgradeableVO2 = arg_43_0;
                if (upgradeableVO2.UpgradeGroup == productUpgradeGroup)
                {
                    num += internalStorage[current].Amount;
                    storage.ClearItemAmount(current);
                }
            }
            storage.ModifyItemAmount(productUid, num);
        }
Exemplo n.º 4
0
        protected void AddTroopItem(IUpgradeableVO troop, int troopCount, string tooltipText)
        {
            TroopUpgradeTag troopUpgradeTag = new TroopUpgradeTag(troop as IDeployableVO, true);

            this.troopList.Add(troopUpgradeTag);
            string    uid        = troop.Uid;
            UXElement item       = this.storageItemGrid.CloneTemplateItem(uid);
            UXLabel   subElement = this.storageItemGrid.GetSubElement <UXLabel>(uid, "LabelStorageCount");

            subElement.Text = LangUtils.GetMultiplierText(troopCount);
            UXSprite        subElement2 = this.storageItemGrid.GetSubElement <UXSprite>(uid, "SpriteStorageItemImageTroops");
            ProjectorConfig config      = ProjectorUtils.GenerateGeometryConfig(troop as IDeployableVO, subElement2);

            Service.EventManager.SendEvent(EventId.ButtonCreated, new GeometryTag(troop, config, Service.CurrentPlayer.ActiveArmory));
            ProjectorUtils.GenerateProjector(config);
            UXLabel subElement3 = this.storageItemGrid.GetSubElement <UXLabel>(uid, "LabelTroopLevel");

            subElement3.Text = LangUtils.GetLevelText(troop.Lvl);
            UXElement subElement4 = this.storageItemGrid.GetSubElement <UXElement>(uid, "BtnRequestTroops");

            subElement4.Visible = false;
            UXButton subElement5 = this.storageItemGrid.GetSubElement <UXButton>(uid, "StorageItemsCard");

            if (tooltipText != null)
            {
                this.troopTooltipHelper.RegisterButtonTooltip(subElement5, tooltipText);
            }
            else
            {
                subElement5.Tag       = troopUpgradeTag;
                subElement5.OnClicked = new UXButtonClickedDelegate(this.OnTroopItemClicked);
            }
            this.storageItemGrid.AddItem(item, troop.Order);
        }
Exemplo n.º 5
0
        public void UpgradeEquipmentLevel(Contract contract)
        {
            IDataController dataController = Service.Get <IDataController>();
            IUpgradeableVO  level          = dataController.Get <EquipmentVO>(contract.ProductUid);

            this.Equipment.SetLevel(level);
        }
Exemplo n.º 6
0
        public void UpgradeEquipmentLevel(Contract contract)
        {
            StaticDataController staticDataController = Service.StaticDataController;
            IUpgradeableVO       level = staticDataController.Get <EquipmentVO>(contract.ProductUid);

            this.Equipment.SetLevel(level);
        }
Exemplo n.º 7
0
        public float GetContractTimeReductionMultiplierForPerks(IUpgradeableVO deployableVO, List <string> perkIds)
        {
            BuildingLookupController buildingLookupController = Service.BuildingLookupController;
            BuildingTypeVO           minBuildingRequirement   = buildingLookupController.GetMinBuildingRequirement(deployableVO);
            List <string>            perkEffectIds            = this.GetPerkEffectIds(perkIds);

            return(ContractTimePerkUtils.GetTimeReductionMultiplier(minBuildingRequirement, perkEffectIds));
        }
Exemplo n.º 8
0
 private bool IsUnlocked(GamePlayer player, IUpgradeableVO vo, int buildOrUpgrade, out BuildingTypeVO req)
 {
     req = null;
     if (this.RequiresUnlockByEventReward(vo))
     {
         return(this.HasUnlockedByReward(player, vo));
     }
     return(this.IsUnlockedByRequirement(vo, buildOrUpgrade, out req));
 }
Exemplo n.º 9
0
        public static IUpgradeableVO GetFinalUnitFromPrize(PrizeType prizeType, string prizeID)
        {
            BuildingLookupController buildingLookupController = Service.Get <BuildingLookupController>();
            IUpgradeableVO           result = null;
            TroopUpgradeCatalog      troopUpgradeCatalog = Service.Get <TroopUpgradeCatalog>();

            switch (prizeType)
            {
            case PrizeType.Infantry:
            {
                int val   = buildingLookupController.GetHighestLevelForBarracks();
                int lvl   = troopUpgradeCatalog.GetMaxRewardableLevel(prizeID).Lvl;
                int level = Math.Min(val, lvl);
                result = troopUpgradeCatalog.GetByLevel(prizeID, level);
                break;
            }

            case PrizeType.Hero:
            {
                int val   = buildingLookupController.GetHighestLevelForHeroCommands();
                int lvl   = troopUpgradeCatalog.GetMaxRewardableLevel(prizeID).Lvl;
                int level = Math.Min(val, lvl);
                result = troopUpgradeCatalog.GetByLevel(prizeID, level);
                break;
            }

            case PrizeType.SpecialAttack:
            {
                StarshipUpgradeCatalog starshipUpgradeCatalog = Service.Get <StarshipUpgradeCatalog>();
                int val   = buildingLookupController.GetHighestLevelForStarshipCommands();
                int lvl   = starshipUpgradeCatalog.GetMaxRewardableLevel(prizeID).Lvl;
                int level = Math.Min(val, lvl);
                result = starshipUpgradeCatalog.GetByLevel(prizeID, level);
                break;
            }

            case PrizeType.Vehicle:
            {
                int val   = buildingLookupController.GetHighestLevelForFactories();
                int lvl   = troopUpgradeCatalog.GetMaxRewardableLevel(prizeID).Lvl;
                int level = Math.Min(val, lvl);
                result = troopUpgradeCatalog.GetByLevel(prizeID, level);
                break;
            }

            case PrizeType.Mercenary:
            {
                int val   = buildingLookupController.GetHighestLevelForCantinas();
                int lvl   = troopUpgradeCatalog.GetMaxRewardableLevel(prizeID).Lvl;
                int level = Math.Min(val, lvl);
                result = troopUpgradeCatalog.GetByLevel(prizeID, level);
                break;
            }
            }
            return(result);
        }
Exemplo n.º 10
0
        private bool HasUnlockedByReward(IUpgradeableVO vo, LevelMap levels)
        {
            bool result = false;

            if (this.RequiresUnlockByEventReward(vo))
            {
                result = (levels.Has(vo) && levels.GetLevel(vo.UpgradeGroup) >= vo.Lvl);
            }
            return(result);
        }
Exemplo n.º 11
0
 public void GrantUnlockByReward(IUpgradeableVO vo)
 {
     if (vo is BuildingTypeVO)
     {
         this.currentPlayer.UnlockedLevels.Buildings.SetLevel(vo);
     }
     else if (vo is TroopTypeVO)
     {
         this.currentPlayer.UnlockedLevels.Troops.SetLevel(vo);
     }
     else if (vo is SpecialAttackTypeVO)
     {
         this.currentPlayer.UnlockedLevels.Starships.SetLevel(vo);
     }
 }
Exemplo n.º 12
0
        public bool IsMinLevelUnlocked(IUpgradeableVO vo)
        {
            IUpgradeableVO vo2 = null;

            if (vo is TroopTypeVO)
            {
                vo2 = Service.Get <TroopUpgradeCatalog>().GetMinLevel((TroopTypeVO)vo);
            }
            else if (vo is SpecialAttackTypeVO)
            {
                vo2 = Service.Get <StarshipUpgradeCatalog>().GetMinLevel((SpecialAttackTypeVO)vo);
            }
            BuildingTypeVO buildingTypeVO = null;

            return(this.IsUnlocked(vo2, 1, out buildingTypeVO));
        }
Exemplo n.º 13
0
        public BuildingTypeVO GetMinBuildingRequirement(IUpgradeableVO vo)
        {
            BuildingTypeVO result = null;

            if (vo is TroopTypeVO)
            {
                TroopTypeVO minLevel = Service.TroopUpgradeCatalog.GetMinLevel(vo as TroopTypeVO);
                result = Service.BuildingLookupController.GetTroopUnlockRequirement(minLevel);
            }
            else if (vo is SpecialAttackTypeVO)
            {
                SpecialAttackTypeVO minLevel2 = Service.StarshipUpgradeCatalog.GetMinLevel(vo as SpecialAttackTypeVO);
                result = Service.BuildingLookupController.GetStarshipUnlockRequirement(minLevel2);
            }
            return(result);
        }
Exemplo n.º 14
0
 public void SetIconAsset(IUpgradeableVO iconAsset)
 {
     if (this.iconSprite != null)
     {
         bool flag = iconAsset != null;
         this.iconSprite.Visible = flag;
         this.DestroyIconGeometry();
         if (flag)
         {
             ProjectorConfig projectorConfig = ProjectorUtils.GenerateGeometryConfig(iconAsset, this.iconSprite);
             Service.EventManager.SendEvent(EventId.ButtonCreated, new GeometryTag(iconAsset, projectorConfig, Service.CurrentPlayer.ActiveArmory));
             projectorConfig.AnimPreference = AnimationPreference.AnimationPreferred;
             projectorConfig.Sharpness      = 4f;
             this.iconGeometry = ProjectorUtils.GenerateProjector(projectorConfig);
         }
     }
 }
Exemplo n.º 15
0
        public static int GetTroopContractTotalTime(string productUid, DeliveryType type, List <string> perkIds)
        {
            int             num            = 0;
            IDataController dataController = Service.Get <IDataController>();
            IUpgradeableVO  upgradeableVO  = null;

            switch (type)
            {
            case DeliveryType.Infantry:
            case DeliveryType.Vehicle:
            case DeliveryType.Hero:
            case DeliveryType.Champion:
            case DeliveryType.Mercenary:
            {
                TroopTypeVO troopTypeVO = dataController.Get <TroopTypeVO>(productUid);
                num           = troopTypeVO.TrainingTime;
                upgradeableVO = troopTypeVO;
                break;
            }

            case DeliveryType.Starship:
            case DeliveryType.UpgradeStarship:
            {
                SpecialAttackTypeVO specialAttackTypeVO = dataController.Get <SpecialAttackTypeVO>(productUid);
                if (type == DeliveryType.UpgradeStarship)
                {
                    num = specialAttackTypeVO.UpgradeTime;
                }
                else
                {
                    num = specialAttackTypeVO.TrainingTime;
                }
                upgradeableVO = specialAttackTypeVO;
                break;
            }
            }
            ContractType contractType = ContractUtils.GetContractType(type);

            if (upgradeableVO != null && perkIds != null && perkIds.Count > 0 && ContractUtils.IsTroopType(contractType))
            {
                PerkManager perkManager = Service.Get <PerkManager>();
                float       contractTimeReductionMultiplierForPerks = perkManager.GetContractTimeReductionMultiplierForPerks(upgradeableVO, perkIds);
                num = Mathf.FloorToInt((float)num * contractTimeReductionMultiplierForPerks);
            }
            return(num);
        }
Exemplo n.º 16
0
        public bool HasUnlockedByReward(GamePlayer player, IUpgradeableVO vo)
        {
            bool result = false;

            if (vo is BuildingTypeVO)
            {
                result = this.HasUnlockedBuildingByReward(player, vo);
            }
            else if (vo is TroopTypeVO)
            {
                result = this.HasUnlockedTroopByReward(player, vo);
            }
            else if (vo is SpecialAttackTypeVO)
            {
                result = this.HasUnlockedSpecialAttackByReward(player, vo);
            }
            return(result);
        }
Exemplo n.º 17
0
        private void OnInfoButtonClicked(UXButton button)
        {
            PrizeInventoryItemTag prizeInventoryItemTag = button.Tag as PrizeInventoryItemTag;
            IUpgradeableVO        finalUnitFromPrize    = TimedEventPrizeUtils.GetFinalUnitFromPrize(prizeInventoryItemTag.PrizeType, prizeInventoryItemTag.PrizeID);

            if (finalUnitFromPrize != null)
            {
                SmartEntity     availableTroopResearchLab = Service.BuildingLookupController.GetAvailableTroopResearchLab();
                TroopUpgradeTag troopUpgradeTag           = new TroopUpgradeTag(finalUnitFromPrize as IDeployableVO, true);
                bool            showUpgradeControls       = !string.IsNullOrEmpty(troopUpgradeTag.Troop.UpgradeShardUid);
                Service.ScreenController.AddScreen(new DeployableInfoScreen(troopUpgradeTag, null, showUpgradeControls, availableTroopResearchLab));
            }
            else
            {
                prizeInventoryItemTag.MainElement.Visible = false;
                prizeInventoryItemTag.InfoLabel.Visible   = true;
            }
            Service.EventManager.SendEvent(EventId.InfoButtonClicked, null);
        }
Exemplo n.º 18
0
        private int CompareBySortOrder(IUpgradeableVO a, IUpgradeableVO b)
        {
            if (a == b)
            {
                return(0);
            }
            int num = a.Order - b.Order;

            if (num == 0)
            {
                Service.Logger.WarnFormat("Upgradable {0} matches order ({1}) of {2}", new object[]
                {
                    a.Uid,
                    a.Order,
                    b.Uid
                });
            }
            return(num);
        }
Exemplo n.º 19
0
        public void RegisterButtonTooltip(UXButton button, IUpgradeableVO vo, BattleEntry battle)
        {
            string tooltipText = null;

            if (vo is SpecialAttackTypeVO)
            {
                tooltipText = LangUtils.GetStarshipDisplayName((SpecialAttackTypeVO)vo);
            }
            else if (vo is TroopTypeVO)
            {
                tooltipText = LangUtils.GetTroopDisplayName((TroopTypeVO)vo);
            }
            GeometryTag geometryTag = new GeometryTag(vo, tooltipText, battle);

            Service.Get <EventManager>().SendEvent(EventId.TooltipCreated, geometryTag);
            if (geometryTag.tooltipText != null)
            {
                this.RegisterButtonTooltip(button, geometryTag.tooltipText);
            }
        }
Exemplo n.º 20
0
        protected void AddTroopItem(IUpgradeableVO troop, int troopCount)
        {
            TroopUpgradeTag item = new TroopUpgradeTag(troop as IDeployableVO, true);

            this.troopList.Add(item);
            string    uid        = troop.Uid;
            UXElement item2      = this.storageItemGrid.CloneTemplateItem(uid);
            UXLabel   subElement = this.storageItemGrid.GetSubElement <UXLabel>(uid, "LabelDonateTroops");

            subElement.Text = LangUtils.GetMultiplierText(troopCount);
            UXSprite        subElement2     = this.storageItemGrid.GetSubElement <UXSprite>(uid, "SpriteDonateTroopsItem");
            ProjectorConfig projectorConfig = ProjectorUtils.GenerateGeometryConfig(troop as IDeployableVO, subElement2);

            projectorConfig.AnimPreference = AnimationPreference.AnimationPreferred;
            ProjectorUtils.GenerateProjector(projectorConfig);
            UXLabel subElement3 = this.storageItemGrid.GetSubElement <UXLabel>(uid, "LabelTroopLevel");

            subElement3.Text = LangUtils.GetLevelText(troop.Lvl);
            this.storageItemGrid.GetSubElement <UXSprite>(uid, "SpriteCardEmpty").Visible = false;
            this.storageItemGrid.AddItem(item2, troop.Order);
        }
Exemplo n.º 21
0
        private void CalculateScale(string inventoryEntryKey)
        {
            int scale = 1;

            if (this.inventoryType != null)
            {
                IUpgradeableVO upgradeableVO = null;
                if (this.inventoryType == typeof(TroopTypeVO))
                {
                    upgradeableVO = Service.StaticDataController.Get <TroopTypeVO>(inventoryEntryKey);
                }
                else if (this.inventoryType == typeof(SpecialAttackTypeVO))
                {
                    upgradeableVO = Service.StaticDataController.Get <SpecialAttackTypeVO>(inventoryEntryKey);
                }
                if (upgradeableVO != null)
                {
                    scale = upgradeableVO.Size;
                }
            }
            this.internalStorage[inventoryEntryKey].Scale = scale;
        }
Exemplo n.º 22
0
        private bool IsUnlockedByRequirement(IUpgradeableVO vo, int buildOrUpgrade, out BuildingTypeVO req)
        {
            bool result = false;

            req = null;
            if (vo is BuildingTypeVO)
            {
                result = this.IsBuildingUnlockedByRequirement((BuildingTypeVO)vo, buildOrUpgrade, ref req);
            }
            else if (vo is TroopTypeVO)
            {
                result = this.IsTroopUnlockedByRequirement((TroopTypeVO)vo, ref req);
            }
            else if (vo is SpecialAttackTypeVO)
            {
                result = this.IsSpecialAttackUnlockedByRequirement((SpecialAttackTypeVO)vo, ref req);
            }
            else if (vo is EquipmentVO)
            {
                result = this.IsEquipmentUnlockedByRequirement((EquipmentVO)vo, ref req);
            }
            return(result);
        }
Exemplo n.º 23
0
 public bool RequiresUnlockByEventReward(IUpgradeableVO vo)
 {
     return(vo != null && vo.UnlockedByEvent);
 }
Exemplo n.º 24
0
        public bool IsUnlockedByRequirement(IUpgradeableVO vo, int buildOrUpgrade)
        {
            BuildingTypeVO buildingTypeVO = null;

            return(this.IsUnlockedByRequirement(vo, buildOrUpgrade, out buildingTypeVO));
        }
Exemplo n.º 25
0
 public bool HasUnlockedSpecialAttackByReward(IUpgradeableVO vo)
 {
     return(this.HasUnlockedByReward(vo, this.currentPlayer.UnlockedLevels.Starships));
 }
Exemplo n.º 26
0
 public bool HasUnlockedSpecialAttackByReward(GamePlayer player, IUpgradeableVO vo)
 {
     return(this.HasUnlockedByReward(vo, player.UnlockedLevels.Starships));
 }
Exemplo n.º 27
0
 public bool HasUnlockedTroopByReward(IUpgradeableVO vo)
 {
     return(this.HasUnlockedByReward(vo, this.currentPlayer.UnlockedLevels.Troops));
 }
Exemplo n.º 28
0
 public bool HasUnlockedTroopByReward(GamePlayer player, IUpgradeableVO vo)
 {
     return(this.HasUnlockedByReward(vo, player.UnlockedLevels.Troops));
 }
Exemplo n.º 29
0
 public bool HasUnlockedBuildingByReward(IUpgradeableVO vo)
 {
     return(this.HasUnlockedByReward(vo, this.currentPlayer.UnlockedLevels.Buildings));
 }
Exemplo n.º 30
0
 public bool HasUnlockedBuildingByReward(GamePlayer player, IUpgradeableVO vo)
 {
     return(this.HasUnlockedByReward(vo, player.UnlockedLevels.Buildings));
 }