Exemple #1
0
        public static bool CanCancelDeployableContract(Entity selectedBuilding)
        {
            if (!ContractUtils.IsArmyUpgrading(selectedBuilding))
            {
                return(false);
            }
            IDataController   dataController    = Service.Get <IDataController>();
            BuildingComponent buildingComponent = selectedBuilding.Get <BuildingComponent>();
            Contract          contract          = Service.Get <ISupportController>().FindCurrentContract(buildingComponent.BuildingTO.Key);
            string            productUid        = contract.ProductUid;
            IDeployableVO     optional          = dataController.GetOptional <TroopTypeVO>(productUid);
            string            text = null;

            if (optional != null)
            {
                text = optional.UpgradeShardUid;
            }
            else
            {
                optional = dataController.GetOptional <SpecialAttackTypeVO>(productUid);
                if (optional != null)
                {
                    text = optional.UpgradeShardUid;
                }
                else
                {
                    Service.Get <StaRTSLogger>().Error("CanCancelDeployableContract: Unsupported deployable type, not troop or special attack " + productUid);
                }
            }
            return(string.IsNullOrEmpty(text));
        }
Exemple #2
0
 public EatResponse OnEvent(EventId id, object cookie)
 {
     if (id != EventId.ShardUnitUpgraded)
     {
         if (id != EventId.EquipmentUnlocked)
         {
             if (id == EventId.ScreenClosing)
             {
                 this.Render(this.vto, false);
             }
         }
         else
         {
             Service.EventManager.RegisterObserver(this, EventId.ScreenClosing);
         }
     }
     else
     {
         IDeployableVO deployableVO = (IDeployableVO)cookie;
         if (deployableVO == null)
         {
             return(EatResponse.NotEaten);
         }
         if (deployableVO.Lvl > 1)
         {
             return(EatResponse.NotEaten);
         }
         Service.EventManager.RegisterObserver(this, EventId.ScreenClosing);
     }
     return(EatResponse.NotEaten);
 }
Exemple #3
0
        private void PopulateExpendedTroops(Dictionary <string, int> troops, Dictionary <string, int> squadTroops, bool isSpecialAttack, BattleEntry battle)
        {
            if (troops == null)
            {
                return;
            }
            IDataController dataController = Service.Get <IDataController>();

            foreach (KeyValuePair <string, int> current in troops)
            {
                if (current.get_Value() >= 1)
                {
                    int num = 0;
                    if (squadTroops != null && squadTroops.ContainsKey(current.get_Key()))
                    {
                        num = squadTroops[current.get_Key()];
                        squadTroops.Remove(current.get_Key());
                    }
                    IDeployableVO arg_82_0;
                    if (!isSpecialAttack)
                    {
                        IDeployableVO deployableVO = dataController.Get <TroopTypeVO>(current.get_Key());
                        arg_82_0 = deployableVO;
                    }
                    else
                    {
                        IDeployableVO deployableVO = dataController.Get <SpecialAttackTypeVO>(current.get_Key());
                        arg_82_0 = deployableVO;
                    }
                    IDeployableVO deployableVO2 = arg_82_0;
                    UXElement     item          = this.CreateDeployableUXElement(this.troopGrid, current.get_Key(), deployableVO2.AssetName, current.get_Value() + num, deployableVO2, battle);
                    this.troopGrid.AddItem(item, deployableVO2.Order);
                }
            }
        }
Exemple #4
0
 public EatResponse OnEvent(EventId id, object cookie)
 {
     if (id == EventId.ShardUnitUpgraded)
     {
         IDeployableVO deployableVO = (IDeployableVO)cookie;
         if (deployableVO == null)
         {
             return(EatResponse.NotEaten);
         }
         if (deployableVO.Lvl > 1)
         {
             return(EatResponse.NotEaten);
         }
         this.deployablesToCelebrate.Add(deployableVO);
         if (GameUtils.IsUnlockBlockingScreenOpen())
         {
             Service.EventManager.RegisterObserver(this, EventId.ScreenClosing);
         }
         else
         {
             this.QueueShowDeployableUnlocks();
         }
     }
     else if (id == EventId.ScreenClosing && cookie is InventoryCrateCollectionScreen)
     {
         Service.EventManager.UnregisterObserver(this, EventId.ScreenClosing);
         GameUtils.CloseStoreOrInventoryScreen();
         this.QueueShowDeployableUnlocks();
     }
     return(EatResponse.NotEaten);
 }
Exemple #5
0
        private TroopUpgradeTag GetPrevLevel(TroopUpgradeTag tag)
        {
            if (tag.IsMaxLevel && tag.Troop.PlayerFacing)
            {
                return(tag);
            }
            IDeployableVO deployableVO = null;

            if (tag.Troop is SpecialAttackTypeVO)
            {
                deployableVO = Service.StarshipUpgradeCatalog.GetPrevLevel(tag.Troop as SpecialAttackTypeVO);
            }
            else if (tag.Troop is TroopTypeVO)
            {
                deployableVO = Service.TroopUpgradeCatalog.GetPrevLevel(tag.Troop as TroopTypeVO);
            }
            string requirementText      = null;
            string shortRequirementText = null;
            bool   reqMet = Service.UnlockController.CanDeployableBeUpgraded(deployableVO, tag.Troop, out requirementText, out shortRequirementText);

            return(new TroopUpgradeTag(deployableVO, reqMet)
            {
                RequirementText = requirementText,
                ShortRequirementText = shortRequirementText
            });
        }
        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}");
        }
        public bool CanDeployableBeUpgraded(IDeployableVO currentVO, IDeployableVO vo)
        {
            string text  = null;
            string text2 = null;

            return(this.CanDeployableBeUpgraded(currentVO, vo, out text, out text2));
        }
Exemple #8
0
 public DeployableUnlockedCelebrationScreen(IDeployableVO vo, bool isSpecialAttack, bool isUnlock)
 {
     this.outLineMatList = new List <Material>();
     base..ctor("gui_equipment_unlocked");
     this.subjectVO       = vo;
     this.isSpecialAttack = isSpecialAttack;
     this.isUnlock        = isUnlock;
 }
Exemple #9
0
        public bool DoesUserHaveUpgradeShardRequirement(IDeployableVO deployableVO)
        {
            if (deployableVO == null || string.IsNullOrEmpty(deployableVO.UpgradeShardUid))
            {
                return(false);
            }
            int shardAmount = this.GetShardAmount(deployableVO.UpgradeShardUid);

            return(shardAmount >= deployableVO.UpgradeShardCount);
        }
Exemple #10
0
        public bool IsUIDForAShardUpgradableDeployable(string uid)
        {
            StaticDataController staticDataController = Service.StaticDataController;
            IDeployableVO        optional             = staticDataController.GetOptional <TroopTypeVO>(uid);

            if (optional == null)
            {
                optional = staticDataController.GetOptional <SpecialAttackTypeVO>(uid);
            }
            return(optional != null && !string.IsNullOrEmpty(optional.UpgradeShardUid));
        }
Exemple #11
0
        public void CreateMobilizationHolo(string unitUid, bool isStarship, bool isNavCenter)
        {
            AssetManager assetManager = Service.AssetManager;

            if (this.coneAssetHandle == AssetHandle.Invalid && !isNavCenter)
            {
                assetManager.Load(ref this.coneAssetHandle, "fx_summon_hologram", new AssetSuccessDelegate(this.OnEffectLoaded), null, true);
            }
            if (unitUid == null)
            {
                return;
            }
            StaticDataController staticDataController = Service.StaticDataController;
            IDeployableVO        geometry             = null;
            int    num;
            string text;

            if (isStarship)
            {
                SpecialAttackTypeVO specialAttackTypeVO = staticDataController.Get <SpecialAttackTypeVO>(unitUid);
                num      = specialAttackTypeVO.Order;
                text     = specialAttackTypeVO.HologramUid;
                geometry = specialAttackTypeVO;
            }
            else if (isNavCenter)
            {
                text = unitUid;
                num  = 2147483647;
            }
            else
            {
                TroopTypeVO troopTypeVO = staticDataController.Get <TroopTypeVO>(unitUid);
                num      = troopTypeVO.Order;
                text     = troopTypeVO.HologramUid;
                geometry = troopTypeVO;
            }
            if (num <= this.unitOrder)
            {
                return;
            }
            if (string.IsNullOrEmpty(text))
            {
                return;
            }
            this.DestroyHolo();
            this.unitOrder       = num;
            this.useHoloRotation = true;
            MobilizationHologramVO mobilizationHologramVO = staticDataController.Get <MobilizationHologramVO>(text);
            GeometryTag            geometryTag            = new GeometryTag(geometry, mobilizationHologramVO.AssetName);

            Service.EventManager.SendEvent(EventId.HologramCreated, geometryTag);
            assetManager.Load(ref this.holoAssetHandle, geometryTag.assetName, new AssetSuccessDelegate(this.OnEffectLoaded), new AssetFailureDelegate(this.OnEffectLoadFailed), false);
        }
Exemple #12
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);
        }
Exemple #13
0
        private void QueueShowDeployableUnlocks()
        {
            int count = this.deployablesToCelebrate.Count;

            for (int i = 0; i < count; i++)
            {
                IDeployableVO deployableVO    = this.deployablesToCelebrate[i];
                bool          isSpecialAttack = deployableVO is SpecialAttackTypeVO;
                this.ShowDeployableUnlockedCelebration(deployableVO, isSpecialAttack);
            }
            this.deployablesToCelebrate.Clear();
        }
Exemple #14
0
        private void ShowDeployableUnlockedCelebration(IDeployableVO vo, bool isSpecialAttack, bool showImmediate)
        {
            QueueScreenBehavior subType = QueueScreenBehavior.QueueAndDeferTillClosed;

            if (showImmediate)
            {
                subType = QueueScreenBehavior.Default;
            }
            bool isUnlock = vo.Lvl == 1;

            Service.ScreenController.AddScreen(new DeployableUnlockedCelebrationScreen(vo, isSpecialAttack, isUnlock), subType);
        }
Exemple #15
0
        private void QueueShowDeployableUnlocks()
        {
            bool flag  = GameUtils.CanShardUnlockCelebrationPlayImmediately();
            int  count = this.deployablesToCelebrate.Count;

            for (int i = 0; i < count; i++)
            {
                IDeployableVO deployableVO    = this.deployablesToCelebrate[i];
                bool          isSpecialAttack = deployableVO is SpecialAttackTypeVO;
                this.ShowDeployableUnlockedCelebration(deployableVO, isSpecialAttack, flag && i == 0);
            }
            this.deployablesToCelebrate.Clear();
        }
Exemple #16
0
        public int GetUpgradeQualityForDeployableUID(string uid)
        {
            StaticDataController staticDataController = Service.StaticDataController;
            IDeployableVO        optional             = staticDataController.GetOptional <TroopTypeVO>(uid);

            if (optional == null)
            {
                optional = staticDataController.GetOptional <SpecialAttackTypeVO>(uid);
            }
            if (optional == null)
            {
                return(0);
            }
            return(this.GetUpgradeQualityForDeployable(optional));
        }
Exemple #17
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);
            }
        }
Exemple #18
0
        private void SetupTroopShardProgressBar(string itemUid, IDeployableVO troopType, bool isMaxLevel)
        {
            UXSlider subElement  = this.troopGrid.GetSubElement <UXSlider>(itemUid, "pBarQuality");
            UXSprite subElement2 = this.troopGrid.GetSubElement <UXSprite>(itemUid, "SpritepBarQuality");
            UXLabel  subElement3 = this.troopGrid.GetSubElement <UXLabel>(itemUid, "LabelNumberQuality");

            if (isMaxLevel)
            {
                subElement3.Text = string.Empty;
                subElement.Value = 0f;
                this.troopGrid.GetSubElement <UXElement>(itemUid, "IconUpgradeQuality").Visible = false;
                return;
            }
            int shardAmount       = Service.DeployableShardUnlockController.GetShardAmount(troopType.UpgradeShardUid);
            int upgradeShardCount = troopType.UpgradeShardCount;

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

            subElement.Value = ((num <= 1f) ? num : 1f);
            UXElement subElement4 = this.troopGrid.GetSubElement <UXElement>(itemUid, "IconUpgradeQuality");

            subElement4.Visible = (shardAmount >= upgradeShardCount);
            if (subElement4.Visible)
            {
                subElement2.Color = UXUtils.COLOR_SHARD_COMPLETE;
            }
            else
            {
                subElement2.Color = UXUtils.COLOR_SHARD_INPROGRESS;
            }
        }
Exemple #19
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);
                }
            }
        }
Exemple #20
0
        private void CreateUnlockCards <T>(List <T> deployableList) where T : IDeployableVO
        {
            this.troopListForInfoScreen = new List <TroopUpgradeTag>();
            int i     = 0;
            int count = deployableList.Count;

            while (i < count)
            {
                IDeployableVO deployableVO = deployableList[i];
                if (deployableVO is TroopTypeVO)
                {
                    int level = Service.CurrentPlayer.UnlockedLevels.Troops.GetLevel(deployableVO.UpgradeGroup);
                    deployableVO = Service.TroopUpgradeCatalog.GetByLevel(deployableVO.UpgradeGroup, level);
                }
                else
                {
                    int level2 = Service.CurrentPlayer.UnlockedLevels.Starships.GetLevel(deployableVO.UpgradeGroup);
                    deployableVO = Service.StarshipUpgradeCatalog.GetByLevel(deployableVO.UpgradeGroup, level2);
                }
                if (deployableVO.PlayerFacing)
                {
                    TroopUpgradeTag troopUpgradeTag = new TroopUpgradeTag(deployableVO, true);
                    this.troopListForInfoScreen.Add(troopUpgradeTag);
                    UXElement item       = this.unlockGrid.CloneTemplateItem(deployableVO.Uid);
                    UXButton  subElement = this.unlockGrid.GetSubElement <UXButton>(deployableVO.Uid, "BuildingUnlockCard");
                    subElement.OnClicked = new UXButtonClickedDelegate(this.OnUnlockCardClicked);
                    subElement.Tag       = troopUpgradeTag;
                    UXSprite        subElement2     = this.unlockGrid.GetSubElement <UXSprite>(deployableVO.Uid, "SpriteItemImageTroops");
                    ProjectorConfig projectorConfig = ProjectorUtils.GenerateGeometryConfig(deployableVO, subElement2);
                    projectorConfig.AnimPreference = AnimationPreference.AnimationPreferred;
                    ProjectorUtils.GenerateProjector(projectorConfig);
                    UXLabel subElement3 = this.unlockGrid.GetSubElement <UXLabel>(deployableVO.Uid, "LabelUnlockCount");
                    subElement3.Text = LangUtils.GetMultiplierText(1);
                    this.unlockGrid.AddItem(item, deployableVO.Order);
                }
                i++;
            }
        }
Exemple #21
0
        private static string GetDeployableDecalSpriteName(IDeployableVO deployableVO)
        {
            string result = null;

            if (deployableVO is TroopTypeVO)
            {
                TroopTypeVO troopTypeVO = (TroopTypeVO)deployableVO;
                if (troopTypeVO.Type == TroopType.Hero)
                {
                    if (!string.IsNullOrEmpty(troopTypeVO.UIDecalAssetName))
                    {
                        result = troopTypeVO.UIDecalAssetName;
                    }
                    else
                    {
                        FactionType faction = troopTypeVO.Faction;
                        if (faction != FactionType.Empire)
                        {
                            if (faction != FactionType.Rebel)
                            {
                                result = "HeroDecalNeutral";
                            }
                            else
                            {
                                result = "HeroDecalRebel";
                            }
                        }
                        else
                        {
                            result = "HeroDecalEmpire";
                        }
                    }
                }
            }
            return(result);
        }
Exemple #22
0
        private void PopulateExpendedTroops(Dictionary <string, int> troops, Dictionary <string, int> squadTroops, bool isSpecialAttack, BattleEntry battle)
        {
            if (troops == null)
            {
                return;
            }
            StaticDataController staticDataController = Service.StaticDataController;

            foreach (KeyValuePair <string, int> current in troops)
            {
                if (current.Value >= 1)
                {
                    int num = 0;
                    if (squadTroops != null && squadTroops.ContainsKey(current.Key))
                    {
                        num = squadTroops[current.Key];
                        squadTroops.Remove(current.Key);
                    }
                    IDeployableVO deployableVO = (!isSpecialAttack) ? staticDataController.Get <TroopTypeVO>(current.Key) : staticDataController.Get <SpecialAttackTypeVO>(current.Key);
                    UXElement     item         = this.CreateDeployableUXElement(this.troopGrid, current.Key, deployableVO.AssetName, current.Value + num, deployableVO, battle);
                    this.troopGrid.AddItem(item, deployableVO.Order);
                }
            }
        }
Exemple #23
0
        public static string GetShardLockedDeployableString(IDeployableVO vo)
        {
            int upgradeShardCount = vo.UpgradeShardCount;

            return(LangUtils.GetShardLockedItemString(vo.UpgradeShardUid, upgradeShardCount));
        }
Exemple #24
0
        private UXElement CreateDeployableUXElement(UXGrid grid, string uid, string assetName, int amount, IDeployableVO troop, BattleEntry battle)
        {
            UXElement       result          = grid.CloneTemplateItem(uid);
            UXSprite        subElement      = grid.GetSubElement <UXSprite>(uid, this.TroopCardIconName);
            ProjectorConfig projectorConfig = ProjectorUtils.GenerateGeometryConfig(troop, subElement);

            Service.Get <EventManager>().SendEvent(EventId.ButtonCreated, new GeometryTag(troop, projectorConfig, battle));
            projectorConfig.AnimPreference = AnimationPreference.NoAnimation;
            ProjectorUtils.GenerateProjector(projectorConfig);
            UXLabel subElement2 = grid.GetSubElement <UXLabel>(uid, this.TroopCardAmountName);

            subElement2.Text = LangUtils.GetMultiplierText(amount);
            UXLabel subElement3 = grid.GetSubElement <UXLabel>(uid, this.TroopCardLevelName);

            subElement3.Text = LangUtils.GetLevelText(troop.Lvl);
            FactionDecal.UpdateDeployableDecal(uid, grid, troop, this.TroopHeroDecalName);
            int upgradeQualityForDeployable = Service.Get <DeployableShardUnlockController>().GetUpgradeQualityForDeployable(troop);

            UXUtils.SetCardQuality(this, this.troopGrid, uid, upgradeQualityForDeployable, this.TroopCardQualityName, this.TroopCardDefaultName);
            UXButton subElement4 = grid.GetSubElement <UXButton>(uid, this.TroopCardName);

            this.troopTooltipHelper.RegisterButtonTooltip(subElement4, troop, battle);
            return(result);
        }
Exemple #25
0
        public static void UpdateDeployableDecal(string itemUid, UXGrid grid, IDeployableVO deployableVO, string elementName)
        {
            string deployableDecalSpriteName = FactionDecal.GetDeployableDecalSpriteName(deployableVO);

            FactionDecal.SetSpriteAndVisibility(grid.GetSubElement <UXSprite>(itemUid, elementName), deployableDecalSpriteName);
        }
Exemple #26
0
        public static void UpdateDeployableDecal(string itemUid, string name, UXGrid grid, IDeployableVO deployableVO)
        {
            string deployableDecalSpriteName = FactionDecal.GetDeployableDecalSpriteName(deployableVO);
            string name2 = UXUtils.FormatAppendedName("SpriteHeroDecal", name);

            FactionDecal.SetSpriteAndVisibility(grid.GetSubElement <UXSprite>(itemUid, name2), deployableDecalSpriteName);
        }
        public bool CanDeployableBeUpgraded(IDeployableVO currentVO, IDeployableVO vo, out string requirementText, out string shortRequirementText)
        {
            requirementText      = null;
            shortRequirementText = null;
            BuildingTypeVO buildingTypeVO = null;
            bool           flag           = false;

            if (this.RequiresUnlockByEventReward(vo))
            {
                if (this.IsMinLevelUnlocked(vo))
                {
                    if (vo is TroopTypeVO)
                    {
                        if (!this.VerifyUpgradeData(currentVO, vo))
                        {
                            return(false);
                        }
                        TroopTypeVO vo2 = (TroopTypeVO)currentVO;
                        TroopTypeVO vo3 = (TroopTypeVO)vo;
                        flag = (this.IsTroopUnlockedByRequirement(vo2, ref buildingTypeVO) && this.IsTroopUnlockedByRequirement(vo3, ref buildingTypeVO));
                    }
                    else if (vo is SpecialAttackTypeVO)
                    {
                        if (!this.VerifyUpgradeData(currentVO, vo))
                        {
                            return(false);
                        }
                        SpecialAttackTypeVO vo4 = (SpecialAttackTypeVO)currentVO;
                        SpecialAttackTypeVO vo5 = (SpecialAttackTypeVO)vo;
                        flag = (this.IsSpecialAttackUnlockedByRequirement(vo4, ref buildingTypeVO) && this.IsSpecialAttackUnlockedByRequirement(vo5, ref buildingTypeVO));
                    }
                }
                else
                {
                    requirementText = Service.Get <Lang>().Get("UNLOCK_IN_EVENT_ONLY", new object[0]);
                }
                if (!string.IsNullOrEmpty(currentVO.UpgradeShardUid))
                {
                    shortRequirementText = LangUtils.GetShardLockedDeployableString(currentVO);
                }
                else
                {
                    Service.Get <StaRTSLogger>().ErrorFormat("Deployable has unlockedByEvent but not upgradeShardUid {0} {1} {2}", new object[]
                    {
                        currentVO.GetType(),
                        currentVO.UpgradeGroup,
                        currentVO.Lvl
                    });
                }
            }
            else
            {
                flag = (this.IsUnlockedByRequirement(currentVO, 1, out buildingTypeVO) && this.IsUnlockedByRequirement(vo, 1, out buildingTypeVO));
            }
            if (!flag && requirementText == null && buildingTypeVO != null)
            {
                requirementText = Service.Get <Lang>().Get("BUILDING_REQUIREMENT", new object[]
                {
                    buildingTypeVO.Lvl,
                    LangUtils.GetBuildingDisplayName(buildingTypeVO)
                });
                shortRequirementText = requirementText;
            }
            return(flag);
        }
Exemple #28
0
        private UXElement CreateDeployableUXElement(UXGrid grid, string uid, string assetName, int amount, IDeployableVO troop, BattleEntry battle)
        {
            UXElement       result          = grid.CloneTemplateItem(uid);
            UXSprite        subElement      = grid.GetSubElement <UXSprite>(uid, this.TroopCardIconName);
            ProjectorConfig projectorConfig = ProjectorUtils.GenerateGeometryConfig(troop, subElement);

            Service.EventManager.SendEvent(EventId.ButtonCreated, new GeometryTag(troop, projectorConfig, battle));
            projectorConfig.AnimPreference = AnimationPreference.NoAnimation;
            ProjectorUtils.GenerateProjector(projectorConfig);
            UXLabel subElement2 = grid.GetSubElement <UXLabel>(uid, this.TroopCardAmountName);

            subElement2.Text = LangUtils.GetMultiplierText(amount);
            UXLabel subElement3 = grid.GetSubElement <UXLabel>(uid, this.TroopCardLevelName);

            subElement3.Text = LangUtils.GetLevelText(troop.Lvl);
            FactionDecal.UpdateDeployableDecal(uid, grid, troop, this.TroopHeroDecalName);
            string text = null;

            if (troop is TroopTypeVO)
            {
                TroopTypeVO troop2 = troop as TroopTypeVO;
                Service.SkinController.GetApplicableSkin(troop2, battle.AttackerEquipment, out text);
            }
            int qualityInt;

            if (!string.IsNullOrEmpty(text))
            {
                StaticDataController staticDataController = Service.StaticDataController;
                EquipmentVO          equipmentVO          = staticDataController.Get <EquipmentVO>(text);
                qualityInt = (int)equipmentVO.Quality;
            }
            else
            {
                qualityInt = Service.DeployableShardUnlockController.GetUpgradeQualityForDeployable(troop);
            }
            UXUtils.SetCardQuality(this, this.troopGrid, uid, qualityInt, this.TroopCardQualityName, this.TroopCardDefaultName);
            UXButton subElement4 = grid.GetSubElement <UXButton>(uid, this.TroopCardName);

            this.troopTooltipHelper.RegisterButtonTooltip(subElement4, troop, battle);
            return(result);
        }
 public TroopUpgradeTag(IDeployableVO troop, bool reqMet)
 {
     this.Troop  = troop;
     this.ReqMet = reqMet;
 }
 public TroopTrainingTag(IDeployableVO troop, bool reqMet) : base(troop, reqMet)
 {
 }