示例#1
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);
        }
示例#2
0
        private UXElement CreateInactiveCard(UXGrid grid, EquipmentVO equipment, CurrentPlayer currentPlayer)
        {
            UXElement uXElement = this.CreateCommonEquipmentCard(grid, equipment, "LabelEquipmentName", "LabelEquipmentLevel", "SpriteEquipmentItemImage", "EquipmentItemCardQ{0}", false, true);

            (uXElement.Tag as SortableEquipment).Player = currentPlayer;
            UXButton subElement = this.inactiveGrid.GetSubElement <UXButton>(equipment.Uid, "BtnEquipmentInfo");

            subElement.OnClicked = new UXButtonClickedDelegate(this.OnInfoButtonClicked);
            subElement.Tag       = equipment;
            UXButton subElement2 = this.inactiveGrid.GetSubElement <UXButton>(equipment.Uid, "BtnEquipmentItemCard");

            subElement2.OnClicked = new UXButtonClickedDelegate(this.OnCardButtonClicked);
            subElement2.Tag       = uXElement;
            EquipmentUpgradeCatalog equipmentUpgradeCatalog = Service.EquipmentUpgradeCatalog;
            UXSlider  subElement3 = this.inactiveGrid.GetSubElement <UXSlider>(equipment.Uid, "pBarEquipmentItemFrag");
            UXSprite  subElement4 = this.inactiveGrid.GetSubElement <UXSprite>(equipment.Uid, "SpriteEquipmentItempBarFrag");
            UXLabel   subElement5 = grid.GetSubElement <UXLabel>(equipment.Uid, "LabelFragProgress");
            UXElement subElement6 = this.inactiveGrid.GetSubElement <UXElement>(equipment.Uid, "IconUpgrade");
            UXSprite  subElement7 = grid.GetSubElement <UXSprite>(equipment.Uid, "SpriteEquipmentImageBkgStroke");
            UXSprite  subElement8 = grid.GetSubElement <UXSprite>(equipment.Uid, "SpriteEquipmentItemBarOutline");
            UXSprite  subElement9 = grid.GetSubElement <UXSprite>(equipment.Uid, "SpriteEquipmentImageBkgGlow");

            subElement7.Color = ArmoryScreen.qualityColor[equipment.Quality];
            subElement8.Color = ArmoryScreen.qualityColor[equipment.Quality];
            subElement9.Color = ArmoryScreen.qualityColor[equipment.Quality];
            subElement9.Alpha = 0.4f;
            float    sliderProgressValue = this.GetSliderProgressValue(equipment, currentPlayer.GetShards(equipment.EquipmentID));
            UXSprite subElement10        = this.inactiveGrid.GetSubElement <UXSprite>(equipment.Uid, "SpriteIconFragment");

            UXUtils.SetupFragmentIconSprite(subElement10, (int)equipment.Quality);
            UXUtils.SetShardProgressBarValue(subElement3, subElement4, sliderProgressValue);
            subElement6.Visible = false;
            if (ArmoryUtils.IsAtMaxLevel(equipmentUpgradeCatalog, equipment))
            {
                subElement5.Text = this.lang.Get("MAX_LEVEL", new object[0]);
            }
            else
            {
                int shards = currentPlayer.GetShards(equipment.EquipmentID);
                int shardsRequiredForNextUpgrade = ArmoryUtils.GetShardsRequiredForNextUpgrade(currentPlayer, equipmentUpgradeCatalog, equipment);
                if (shards >= shardsRequiredForNextUpgrade)
                {
                    subElement5.Text = this.lang.Get("ARMORY_UPGRADE_NOW", new object[0]);
                }
                else
                {
                    subElement5.Text = this.lang.Get("OBJECTIVE_PROGRESS", new object[]
                    {
                        shards,
                        shardsRequiredForNextUpgrade
                    });
                }
            }
            if (ArmoryUtils.IsEquipmentOwned(currentPlayer, equipment))
            {
                EquipmentVO nextLevel = equipmentUpgradeCatalog.GetNextLevel(equipment);
                if (nextLevel != null)
                {
                    if (Service.ISupportController.FindFirstContractWithProductUid(nextLevel.Uid) != null)
                    {
                        subElement5.Visible = false;
                        subElement3.Visible = false;
                    }
                    else if (currentPlayer.GetShards(equipment.EquipmentID) >= nextLevel.UpgradeShards)
                    {
                        subElement6.Visible = true;
                    }
                }
            }
            this.SetDimmerBasedOnRequirements(currentPlayer, equipment);
            return(uXElement);
        }