Exemple #1
0
        private string GetDisplayInstructionsBasedOnSubject()
        {
            string result = string.Empty;

            if (this.isSpecialAttack)
            {
                result = this.lang.Get("UNLOCK_SHRD_STARSHIP_INSTRUCTIONS", new object[0]);
            }
            else
            {
                TroopTypeVO troopTypeVO = (TroopTypeVO)this.subjectVO;
                switch (troopTypeVO.Type)
                {
                case TroopType.Infantry:
                    result = this.lang.Get("UNLOCK_SHRD_INFANTRY_INSTRUCTIONS", new object[0]);
                    break;

                case TroopType.Vehicle:
                    result = this.lang.Get("UNLOCK_SHRD_VEHICLE_INSTRUCTIONS", new object[0]);
                    break;

                case TroopType.Mercenary:
                    result = this.lang.Get("UNLOCK_SHRD_MERCENARY_INSTRUCTIONS", new object[0]);
                    break;

                case TroopType.Hero:
                    result = this.lang.Get("UNLOCK_SHRD_HERO_INSTRUCTIONS", new object[0]);
                    break;
                }
            }
            return(result);
        }
Exemple #2
0
        public bool DoesUserHaveAnyUpgradeableShardUnits()
        {
            CurrentPlayer          currentPlayer          = Service.Get <CurrentPlayer>();
            TroopUpgradeCatalog    troopUpgradeCatalog    = Service.Get <TroopUpgradeCatalog>();
            StarshipUpgradeCatalog starshipUpgradeCatalog = Service.Get <StarshipUpgradeCatalog>();

            foreach (string current in troopUpgradeCatalog.AllUpgradeGroups())
            {
                int         nextLevel = currentPlayer.UnlockedLevels.Troops.GetNextLevel(current);
                TroopTypeVO byLevel   = troopUpgradeCatalog.GetByLevel(current, nextLevel);
                if (byLevel != null && byLevel.PlayerFacing && byLevel.Type != TroopType.Champion && byLevel.Faction == currentPlayer.Faction && !string.IsNullOrEmpty(byLevel.UpgradeShardUid) && this.DoesUserHaveUpgradeShardRequirement(byLevel))
                {
                    bool result = true;
                    return(result);
                }
            }
            foreach (string current2 in starshipUpgradeCatalog.AllUpgradeGroups())
            {
                int nextLevel2 = currentPlayer.UnlockedLevels.Starships.GetNextLevel(current2);
                SpecialAttackTypeVO byLevel2 = starshipUpgradeCatalog.GetByLevel(current2, nextLevel2);
                if (byLevel2 != null && byLevel2.PlayerFacing && byLevel2.Faction == currentPlayer.Faction && !string.IsNullOrEmpty(byLevel2.UpgradeShardUid) && this.DoesUserHaveUpgradeShardRequirement(byLevel2))
                {
                    bool result = true;
                    return(result);
                }
            }
            return(false);
        }
        public TroopShieldViewComponent(TroopTypeVO troop)
        {
            string shieldAssetName = troop.ShieldAssetName;
            string assetName       = Service.Get <IDataController>().Get <EffectsTypeVO>(shieldAssetName).AssetName;

            Service.Get <AssetManager>().Load(ref this.assetHandle, assetName, new AssetSuccessDelegate(this.OnEffectLoaded), null, true);
        }
Exemple #4
0
		public override void ExitMode()
		{
			this.KillAutoSpawnTimer();
			this.KillPressHoldTimer();
			this.currentTroopType = null;
			base.ExitMode();
		}
        private string GetResearchDisplayName(string uid)
        {
            string result = "";

            if (!string.IsNullOrEmpty(uid))
            {
                IDataController dataController = Service.Get <IDataController>();
                TroopTypeVO     optional       = dataController.GetOptional <TroopTypeVO>(uid);
                if (optional != null)
                {
                    result = LangUtils.GetTroopDisplayName(optional);
                }
                else
                {
                    SpecialAttackTypeVO optional2 = dataController.GetOptional <SpecialAttackTypeVO>(uid);
                    if (optional2 != null)
                    {
                        result = LangUtils.GetStarshipDisplayName(optional2);
                    }
                    else
                    {
                        EquipmentVO optional3 = dataController.GetOptional <EquipmentVO>(uid);
                        if (optional3 != null)
                        {
                            result = LangUtils.GetEquipmentDisplayName(optional3);
                        }
                    }
                }
            }
            return(result);
        }
Exemple #6
0
        public void StartChampionRepair(SmartEntity building)
        {
            BuildingTypeVO buildingType = building.BuildingComp.BuildingType;

            this.repairChampionType = this.FindChampionTypeIfPlatform(buildingType);
            if (this.repairChampionType == null)
            {
                return;
            }
            int credits    = this.repairChampionType.Credits;
            int materials  = this.repairChampionType.Materials;
            int contraband = this.repairChampionType.Contraband;

            if (credits != 0 || materials != 0 || contraband != 0)
            {
                string purchaseContext = string.Format("{0}|{1}|{2}|{3}", new object[]
                {
                    StringUtils.ToLowerCaseUnderscoreSeperated(this.repairChampionType.Type.ToString()),
                    this.repairChampionType.TroopID,
                    this.repairChampionType.Lvl,
                    "repair"
                });
                if (PayMeScreen.ShowIfNotEnoughCurrency(credits, materials, contraband, purchaseContext, new OnScreenModalResult(this.OnPayMeForCurrencyResult)))
                {
                    return;
                }
            }
            if (PayMeScreen.ShowIfNoFreeDroids(new OnScreenModalResult(this.OnPayMeForDroidResult), null))
            {
                return;
            }
            this.ConfirmRepair();
        }
Exemple #7
0
        private bool IsChampionBroken(ChampionComponent championComp)
        {
            TroopTypeVO championType     = championComp.ChampionType;
            SmartEntity selectedBuilding = this.FindPlatformForChampion(championType);

            return(!this.PlayerHasChampion(championType) && (!ContractUtils.IsBuildingUpgrading(selectedBuilding) && !ContractUtils.IsBuildingConstructing(selectedBuilding)));
        }
Exemple #8
0
        private void UpgradeChampionToMatchPlatform(SmartEntity building)
        {
            BuildingTypeVO buildingType = building.BuildingComp.BuildingType;
            TroopTypeVO    troopTypeVO  = this.FindChampionTypeIfPlatform(buildingType);

            if (troopTypeVO == null)
            {
                return;
            }
            BuildingUpgradeCatalog buildingUpgradeCatalog = Service.BuildingUpgradeCatalog;
            BuildingTypeVO         nextLevel    = buildingUpgradeCatalog.GetNextLevel(buildingType);
            TroopTypeVO            troopTypeVO2 = this.FindChampionTypeIfPlatform(nextLevel);

            if (troopTypeVO2 == null)
            {
                return;
            }
            this.AddChampionToInventoryIfAlive(building, false);
            CurrentPlayer currentPlayer = Service.CurrentPlayer;

            UnlockedLevelData.UpgradeTroopsOrStarshipsInventory(currentPlayer.Inventory.Champion, false, troopTypeVO2.UpgradeGroup, troopTypeVO2.Uid);
            this.DestroyChampionEntity(troopTypeVO);
            if (Service.GameStateMachine.CurrentState is HomeState)
            {
                this.CreateChampionEntity(troopTypeVO2, building);
            }
        }
Exemple #9
0
        public bool IsChampionAvailable(SmartEntity building)
        {
            BuildingTypeVO buildingType = building.BuildingComp.BuildingType;
            TroopTypeVO    troopTypeVO  = this.FindChampionTypeIfPlatform(buildingType);

            return(troopTypeVO != null && this.PlayerHasChampion(troopTypeVO));
        }
Exemple #10
0
        private SmartEntity CreateDefensiveChampionEntityForBattle(TroopTypeVO championType, SmartEntity building)
        {
            TransformComponent transformComp = building.TransformComp;
            IntPosition        boardPosition = new IntPosition(transformComp.CenterGridX(), transformComp.CenterGridZ());

            return(Service.TroopController.SpawnChampion(championType, TeamType.Defender, boardPosition));
        }
Exemple #11
0
        private string GetUpgradeDisplayTitleBasedOnSubject()
        {
            string result = string.Empty;

            if (this.isSpecialAttack)
            {
                result = this.lang.Get("UPGRADE_SHRD_STARSHIP_TITLE", new object[0]);
            }
            else
            {
                TroopTypeVO troopTypeVO = (TroopTypeVO)this.subjectVO;
                switch (troopTypeVO.Type)
                {
                case TroopType.Infantry:
                    result = this.lang.Get("UPGRADE_SHRD_INFANTRY_TITLE", new object[0]);
                    break;

                case TroopType.Vehicle:
                    result = this.lang.Get("UPGRADE_SHRD_VEHICLE_TITLE", new object[0]);
                    break;

                case TroopType.Mercenary:
                    result = this.lang.Get("UPGRADE_SHRD_MERCENARY_TITLE", new object[0]);
                    break;

                case TroopType.Hero:
                    result = this.lang.Get("UPGRADE_SHRD_HERO_TITLE", new object[0]);
                    break;
                }
            }
            return(result);
        }
Exemple #12
0
        private bool AddTroopItem(KeyValuePair <string, InventoryEntry> unit, TroopTypeVO troop)
        {
            string   itemUid  = "troop_" + troop.Uid;
            UXButton uXButton = this.troopDonateGrid.CloneItem(itemUid, this.troopTemplateItem) as UXButton;

            uXButton.Tag       = unit;
            uXButton.OnClicked = new UXButtonClickedDelegate(this.OnTroopToDonateClicked);
            UXLabel subElement = this.troopDonateGrid.GetSubElement <UXLabel>(itemUid, "LabelDonateTroops");

            subElement.Text = string.Format("x{0}", unit.Value.Amount);
            UXLabel subElement2 = this.troopDonateGrid.GetSubElement <UXLabel>(itemUid, "LabelTroopLevel");

            subElement2.Text = LangUtils.GetLevelText(troop.Lvl);
            UXElement subElement3 = this.troopDonateGrid.GetSubElement <UXElement>(itemUid, "WidgetTroopsCardBgDefault");
            UXElement subElement4 = this.troopDonateGrid.GetSubElement <UXElement>(itemUid, "WidgetTroopsCardBgQ10");

            if (string.IsNullOrEmpty(troop.UpgradeShardUid))
            {
                subElement3.Visible = true;
                subElement4.Visible = false;
            }
            else
            {
                subElement3.Visible = false;
                subElement4.Visible = true;
            }
            UXSprite        subElement5     = this.troopDonateGrid.GetSubElement <UXSprite>(itemUid, "SpriteDonateTroopsItem");
            ProjectorConfig projectorConfig = ProjectorUtils.GenerateGeometryConfig(troop, subElement5);

            projectorConfig.AnimPreference = AnimationPreference.NoAnimation;
            ProjectorUtils.GenerateProjector(projectorConfig);
            this.troopDonateGrid.AddItem(uXButton, troop.Order);
            return(troop.Size <= this.totalCapacity - this.alreadyDonatedSize);
        }
Exemple #13
0
        private void HeroAbilityActivateActionCallback(uint id, object cookie)
        {
            HeroAbilityAction    heroAbilityAction    = cookie as HeroAbilityAction;
            StaticDataController staticDataController = Service.StaticDataController;
            TroopTypeVO          troopTypeVO          = staticDataController.Get <TroopTypeVO>(heroAbilityAction.TroopUid);

            Service.TroopAbilityController.ActivateHeroAbility(troopTypeVO.Uid);
        }
 private int CompareTroops(TroopTypeVO a, TroopTypeVO b)
 {
     if (a == b)
     {
         return(0);
     }
     return(b.SizeX.CompareTo(a.SizeX));
 }
        private void HeroAbilityActivateActionCallback(uint id, object cookie)
        {
            HeroAbilityAction heroAbilityAction = cookie as HeroAbilityAction;
            IDataController   dataController    = Service.Get <IDataController>();
            TroopTypeVO       troopTypeVO       = dataController.Get <TroopTypeVO>(heroAbilityAction.TroopUid);

            Service.Get <TroopAbilityController>().ActivateHeroAbility(troopTypeVO.Uid);
        }
Exemple #16
0
        public static bool IsUpgradeTroopContractValid(Contract contract)
        {
            TroopTypeVO         upgradeable         = Service.Get <IDataController>().Get <TroopTypeVO>(contract.ProductUid);
            TroopUpgradeCatalog troopUpgradeCatalog = Service.Get <TroopUpgradeCatalog>();
            CurrentPlayer       currentPlayer       = Service.Get <CurrentPlayer>();

            return(troopUpgradeCatalog.CanUpgradeTo(currentPlayer.UnlockedLevels.Troops, upgradeable));
        }
Exemple #17
0
		public TroopDeployer()
		{
			this.currentTroopType = null;
			this.autoSpawnTimerID = 0u;
			this.pressHoldTimerID = 0u;
			this.multiTapTimerID = 0u;
			this.currentOffsetIndex = 0;
		}
 public void Cleanup()
 {
     if (this.loadedAssets)
     {
         if (this.effectObj != null)
         {
             UnityEngine.Object.Destroy(this.effectObj);
         }
         UnityUtils.DestroyMaterial(this.troopCardMaterial);
         AssetManager assetManager = Service.Get <AssetManager>();
         if (this.effectHandle != AssetHandle.Invalid)
         {
             assetManager.Unload(this.effectHandle);
             this.effectHandle = AssetHandle.Invalid;
         }
         if (this.troopHandle != AssetHandle.Invalid)
         {
             assetManager.Unload(this.troopHandle);
             this.troopHandle = AssetHandle.Invalid;
         }
     }
     if (this.shuttle == null)
     {
         Service.Get <EventManager>().UnregisterObserver(this, EventId.ShuttleAnimStateChanged);
     }
     else
     {
         this.shuttle = null;
     }
     if (this.timerId != 0u)
     {
         Service.Get <ViewTimerManager>().KillViewTimer(this.timerId);
     }
     else
     {
         this.timerId = 0u;
     }
     if (this.animPosition != null)
     {
         Service.Get <AnimController>().CompleteAndRemoveAnim(this.animPosition);
     }
     this.troopVO           = null;
     this.troopEntity       = null;
     this.starportEntity    = null;
     this.entityFader       = null;
     this.onFinished        = null;
     this.effectObj         = null;
     this.troopCardPS       = null;
     this.shuttleGlowPS     = null;
     this.troopCardTexture  = null;
     this.troopCardMaterial = null;
     this.animPosition      = null;
     this.showFullEffect    = false;
     this.pathReached       = false;
     Service.Get <EventManager>().UnregisterObserver(this, EventId.TroopViewReady);
     Service.Get <EventManager>().UnregisterObserver(this, EventId.BuildingMovedOnBoard);
     Service.Get <EventManager>().UnregisterObserver(this, EventId.BuildingReplaced);
 }
Exemple #19
0
        private SmartEntity CreateChampionEntity(TroopTypeVO championType, SmartEntity building)
        {
            TransformComponent transformComp = building.TransformComp;
            SmartEntity        smartEntity   = Service.Get <EntityFactory>().CreateChampionEntity(championType, new IntPosition(transformComp.CenterGridX(), transformComp.CenterGridZ()));

            Service.Get <BoardController>().Board.AddChild(smartEntity.BoardItemComp.BoardItem, transformComp.X, transformComp.Z, null, false);
            Service.Get <EntityController>().AddEntity(smartEntity);
            return(smartEntity);
        }
Exemple #20
0
 private void OnPayMeForDroidResult(object result, object cookie)
 {
     if (result != null)
     {
         this.ConfirmRepair();
         return;
     }
     this.repairChampionType = null;
 }
Exemple #21
0
        private void DestroyChampionEntity(TroopTypeVO championType)
        {
            SmartEntity smartEntity = this.FindChampionEntity(championType);

            if (smartEntity != null)
            {
                Service.Get <EntityFactory>().DestroyEntity(smartEntity, true, false);
            }
        }
Exemple #22
0
 public static void AddTroopToStarportReserve(SmartEntity starport, TroopTypeVO troop)
 {
     if (starport != null)
     {
         int num = StorageSpreadUtils.GetStarportFillSize(starport);
         num += troop.Size;
         StorageSpreadUtils.SetStarportFillSize(starport, num);
     }
 }
Exemple #23
0
        private CancelScreen(Entity building) : base(false, null, null, null, false)
        {
            this.building = building;
            Service.EventManager.RegisterObserver(this, EventId.ContractCompleted, EventPriority.Default);
            this.contract = Service.ISupportController.FindCurrentContract(building.Get <BuildingComponent>().BuildingTO.Key);
            if (this.contract != null)
            {
                string productUid = this.contract.ProductUid;
                string text       = null;
                string id         = "CANCEL_UPGRADE_TITLE";
                string id2        = "CANCEL_UPGRADE_MESSAGE";
                StaticDataController staticDataController = Service.StaticDataController;
                switch (this.contract.DeliveryType)
                {
                case DeliveryType.Champion:
                    text = LangUtils.GetTroopDisplayName(staticDataController.Get <TroopTypeVO>(productUid));
                    id   = "CANCEL_REPAIR_TITLE";
                    id2  = "CANCEL_REPAIR_MESSAGE";
                    break;

                case DeliveryType.UpgradeBuilding:
                case DeliveryType.SwapBuilding:
                {
                    BuildingTypeVO buildingInfo = staticDataController.Get <BuildingTypeVO>(productUid);
                    text = LangUtils.GetBuildingDisplayName(buildingInfo);
                    break;
                }

                case DeliveryType.UpgradeTroop:
                {
                    TroopTypeVO troopInfo = staticDataController.Get <TroopTypeVO>(productUid);
                    text = LangUtils.GetTroopDisplayName(troopInfo);
                    break;
                }

                case DeliveryType.UpgradeStarship:
                {
                    SpecialAttackTypeVO starshipInfo = staticDataController.Get <SpecialAttackTypeVO>(productUid);
                    text = LangUtils.GetStarshipDisplayName(starshipInfo);
                    break;
                }

                case DeliveryType.UpgradeEquipment:
                {
                    EquipmentVO vo = staticDataController.Get <EquipmentVO>(productUid);
                    text = LangUtils.GetEquipmentDisplayName(vo);
                    break;
                }
                }
                this.title = ((text != null) ? this.lang.Get(id, new object[]
                {
                    text
                }) : string.Empty);
                this.message = this.lang.Get(id2, new object[0]);
            }
        }
 public bool EnterMode(TroopTypeVO troopType)
 {
     if (this.currentTroopType != null)
     {
         this.ExitMode();
     }
     this.currentTroopType = troopType;
     this.EnterMode();
     return(true);
 }
 private bool IsTroopUnlockedByRequirement(TroopTypeVO vo, ref BuildingTypeVO req)
 {
     if (vo != null && !string.IsNullOrEmpty(vo.BuildingRequirement))
     {
         BuildingLookupController buildingLookupController = Service.Get <BuildingLookupController>();
         req = buildingLookupController.GetTroopUnlockRequirement(vo);
         return(req == null || buildingLookupController.HasConstructedBuilding(req));
     }
     return(true);
 }
Exemple #26
0
        private static int CompareTroop(TroopTypeVO a, TroopTypeVO b)
        {
            int num = b.Size - a.Size;

            if (num == 0)
            {
                num = a.Order - b.Order;
            }
            return(num);
        }
        public SmartEntity CreateChampionEntity(TroopTypeVO championType, IntPosition position)
        {
            SmartEntity smartEntity = this.CreateWalkerBaseEntity(position, championType.SizeX, championType.SizeY);

            smartEntity.TransformComp.Rotation = 90f;
            smartEntity.Add(new ChampionComponent(championType));
            smartEntity.Add(new WalkerComponent(championType.AssetName, championType));
            Service.Get <EntityViewManager>().LoadEntityAsset(smartEntity);
            return(smartEntity);
        }
        private void TroopPlacedActionCallback(uint id, object cookie)
        {
            TroopPlacedAction troopPlacedAction = cookie as TroopPlacedAction;
            IDataController   dataController    = Service.Get <IDataController>();
            TroopTypeVO       troopTypeVO       = dataController.Get <TroopTypeVO>(troopPlacedAction.TroopId);
            IntPosition       boardPosition     = new IntPosition(troopPlacedAction.BoardX, troopPlacedAction.BoardZ);

            Service.Get <TroopController>().SpawnTroop(troopTypeVO, troopPlacedAction.TeamType, boardPosition, (troopPlacedAction.TeamType == TeamType.Defender) ? TroopSpawnMode.LeashedToBuilding : TroopSpawnMode.Unleashed, true);
            this.battleController.OnTroopDeployed(troopTypeVO.Uid, troopPlacedAction.TeamType, boardPosition);
        }
        private void ChampionDeployedActionCallback(uint id, object cookie)
        {
            ChampionDeployedAction championDeployedAction = cookie as ChampionDeployedAction;
            IDataController        dataController         = Service.Get <IDataController>();
            TroopTypeVO            troopTypeVO            = dataController.Get <TroopTypeVO>(championDeployedAction.TroopUid);
            IntPosition            boardPosition          = new IntPosition(championDeployedAction.BoardX, championDeployedAction.BoardZ);

            Service.Get <TroopController>().SpawnChampion(troopTypeVO, championDeployedAction.TeamType, boardPosition);
            this.battleController.OnChampionDeployed(troopTypeVO.Uid, championDeployedAction.TeamType, boardPosition);
        }
Exemple #30
0
        private void OnTroopToDonateClicked(UXButton button)
        {
            Service.Get <EventManager>().SendEvent(EventId.SquadSelect, null);
            KeyValuePair <string, InventoryEntry> keyValuePair = (KeyValuePair <string, InventoryEntry>)button.Tag;
            string          key            = keyValuePair.get_Key();
            InventoryEntry  value          = keyValuePair.get_Value();
            IDataController dataController = Service.Get <IDataController>();
            TroopTypeVO     troopTypeVO    = dataController.Get <TroopTypeVO>(key);
            int             amount         = value.Amount;

            if (button.VisuallyDisabled)
            {
                string instructions;
                if (amount <= 0)
                {
                    instructions = Service.Get <Lang>().Get("SQUAD_DONATE_NO_TROOPS", new object[0]);
                }
                else if (this.hasEligibleTroop)
                {
                    instructions = Service.Get <Lang>().Get("SQUAD_DONATE_NO_CAPACITY_FOR_UNIT", new object[0]);
                }
                else
                {
                    instructions = Service.Get <Lang>().Get("SQUAD_DONATE_NO_CAPACITY", new object[0]);
                }
                Service.Get <UXController>().MiscElementsManager.ShowPlayerInstructionsError(instructions);
                return;
            }
            int num  = this.GetTotalSizeOfTroopsToDonate(dataController) + this.alreadyDonatedSize + troopTypeVO.Size;
            int num2 = this.GetNumberOfTroopsDonated() + this.currentPlayerDonationCount;

            if (amount > 0 && num <= this.totalCapacity && num2 < this.troopDonationLimit)
            {
                string itemUid = "troop_" + troopTypeVO.Uid;
                if (this.troopsToDonate.ContainsKey(key))
                {
                    Dictionary <string, int> arg_123_0 = this.troopsToDonate;
                    string key2 = key;
                    int    num3 = arg_123_0[key2];
                    arg_123_0[key2] = num3 + 1;
                }
                else
                {
                    this.troopsToDonate.Add(key, 1);
                }
                int     num4       = value.Amount - this.troopsToDonate[key];
                UXLabel subElement = this.troopDonateGrid.GetSubElement <UXLabel>(itemUid, "LabelDonateTroops");
                subElement.Text = string.Format("x{0}", new object[]
                {
                    num4
                });
            }
            this.donateTroopsConfirm.Enabled = true;
            this.RefreshView();
        }