Ejemplo n.º 1
0
        public void ActivateEquipment(string equipmentId)
        {
            CurrentPlayer currentPlayer            = Service.CurrentPlayer;
            EquipmentVO   currentEquipmentDataByID = ArmoryUtils.GetCurrentEquipmentDataByID(equipmentId);

            if (currentEquipmentDataByID == null)
            {
                Service.Logger.Warn("Invalid EquipmentID: " + equipmentId);
                return;
            }
            if (currentPlayer.ActiveArmory.Equipment.Contains(currentEquipmentDataByID.Uid))
            {
                return;
            }
            if (ArmoryUtils.GetCurrentActiveEquipmentCapacity(currentPlayer.ActiveArmory) + currentEquipmentDataByID.Size > currentPlayer.ActiveArmory.MaxCapacity)
            {
                string instructions = Service.Lang.Get("ARMORY_FULL", new object[0]);
                Service.UXController.MiscElementsManager.ShowPlayerInstructions(instructions);
                return;
            }
            if (!ArmoryUtils.IsEquipmentOnValidPlanet(currentPlayer, currentEquipmentDataByID))
            {
                string instructions2 = Service.Lang.Get("BASE_ON_INCORRECT_PLANET", new object[0]);
                Service.UXController.MiscElementsManager.ShowPlayerInstructions(instructions2);
                return;
            }
            currentPlayer.ActiveArmory.Equipment.Add(currentEquipmentDataByID.Uid);
            Service.EventManager.SendEvent(EventId.EquipmentActivated, currentEquipmentDataByID);
            EquipmentIdRequest       request = new EquipmentIdRequest(equipmentId);
            ActivateEquipmentCommand activateEquipmentCommand = new ActivateEquipmentCommand(request);

            activateEquipmentCommand.Context = equipmentId;
            activateEquipmentCommand.AddFailureCallback(new AbstractCommand <EquipmentIdRequest, DefaultResponse> .OnFailureCallback(this.OnActivateEquipmentFailure));
            Service.ServerAPI.Enqueue(activateEquipmentCommand);
        }
Ejemplo n.º 2
0
        public void DeactivateEquipment(string equipmentId)
        {
            CurrentPlayer currentPlayer            = Service.CurrentPlayer;
            EquipmentVO   currentEquipmentDataByID = ArmoryUtils.GetCurrentEquipmentDataByID(equipmentId);

            if (!currentPlayer.ActiveArmory.Equipment.Contains(currentEquipmentDataByID.Uid))
            {
                return;
            }
            this.DeactivateEquipmentOnClient(currentPlayer, currentEquipmentDataByID);
            EquipmentIdRequest         request = new EquipmentIdRequest(equipmentId);
            DeactivateEquipmentCommand deactivateEquipmentCommand = new DeactivateEquipmentCommand(request);

            deactivateEquipmentCommand.Context = equipmentId;
            deactivateEquipmentCommand.AddFailureCallback(new AbstractCommand <EquipmentIdRequest, DefaultResponse> .OnFailureCallback(this.OnDeactivateEquipmentFailure));
            Service.ServerAPI.Enqueue(deactivateEquipmentCommand);
        }
Ejemplo n.º 3
0
        private void SetupEquipmentShardRewardItemElements(string itemUID, CrateSupplyVO crateSupply)
        {
            EquipmentVO currentEquipmentDataByID = ArmoryUtils.GetCurrentEquipmentDataByID(crateSupply.RewardUid);
            int         quality = (int)currentEquipmentDataByID.Quality;
            string      name    = string.Format("SpriteTroopImageBkgGridQ{0}", quality);

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

            UXUtils.SetupFragmentIconSprite(subElement, quality);
            this.SetupEquipmentShardProgress(itemUID, currentEquipmentDataByID);
            UXSprite        subElement2     = this.rewardsGrid.GetSubElement <UXSprite>(itemUID, "SpriteRewardItemImage");
            ProjectorConfig projectorConfig = ProjectorUtils.GenerateEquipmentConfig(currentEquipmentDataByID, subElement2, true);

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

            this.projectors.Add(item);
            UXUtils.SetCardQuality(this, this.rewardsGrid, itemUID, quality, "RewardItemCardQ{0}");
        }
Ejemplo n.º 4
0
        public static void TrySetupItemQualityView(CrateSupplyVO supplyData, UXElement unitElement, UXElement basicElement, UXElement advancedElement, UXElement eliteElement, UXElement defaultElement)
        {
            if (supplyData == null)
            {
                return;
            }
            unitElement.Visible     = false;
            basicElement.Visible    = false;
            advancedElement.Visible = false;
            eliteElement.Visible    = false;
            bool         flag         = false;
            ShardQuality shardQuality = ShardQuality.Basic;

            if (supplyData.Type == SupplyType.ShardTroop || supplyData.Type == SupplyType.ShardSpecialAttack)
            {
                ShardVO optional = Service.StaticDataController.GetOptional <ShardVO>(supplyData.RewardUid);
                shardQuality = optional.Quality;
                flag         = true;
            }
            else if (supplyData.Type == SupplyType.Shard)
            {
                EquipmentVO currentEquipmentDataByID = ArmoryUtils.GetCurrentEquipmentDataByID(supplyData.RewardUid);
                shardQuality = currentEquipmentDataByID.Quality;
                flag         = true;
            }
            if (flag)
            {
                unitElement.Visible     = (shardQuality == ShardQuality.Unit);
                basicElement.Visible    = (shardQuality == ShardQuality.Basic);
                advancedElement.Visible = (shardQuality == ShardQuality.Advanced);
                eliteElement.Visible    = (shardQuality == ShardQuality.Elite);
            }
            if (defaultElement != null)
            {
                defaultElement.Visible = !flag;
            }
        }
Ejemplo n.º 5
0
        public string GetCrateSupplyRewardName(CrateSupplyVO supplyData)
        {
            string text = string.Empty;

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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