コード例 #1
0
        private CrateSupplyVO GrantSingleSupplyCrateReward(string crateSupplyId, int hqLevel)
        {
            IDataController dataController = Service.Get <IDataController>();
            CrateSupplyVO   crateSupplyVO  = dataController.Get <CrateSupplyVO>(crateSupplyId);

            switch (crateSupplyVO.Type)
            {
            case SupplyType.Currency:
            case SupplyType.Shard:
            {
                RewardVO vo = this.GenerateRewardFromSupply(crateSupplyVO, hqLevel);
                Service.Get <RewardManager>().TryAndGrantReward(vo, null, null, false);
                break;
            }

            case SupplyType.Troop:
            case SupplyType.Hero:
            case SupplyType.SpecialAttack:
            {
                RewardVO vo2 = this.GenerateRewardFromSupply(crateSupplyVO, hqLevel);
                GameUtils.AddRewardToInventory(vo2);
                break;
            }

            case SupplyType.ShardTroop:
            case SupplyType.ShardSpecialAttack:
                Service.Get <DeployableShardUnlockController>().GrantUnlockShards(crateSupplyVO.RewardUid, this.GetRewardAmount(crateSupplyVO, hqLevel));
                break;

            case SupplyType.Invalid:
                Service.Get <StaRTSLogger>().Error("Supply Type Invalid: " + crateSupplyVO.Uid);
                break;
            }
            return(crateSupplyVO);
        }
コード例 #2
0
        private void InitRewardsGrid()
        {
            this.rewardsGrid = base.GetElement <UXGrid>("GridRewards");
            this.rewardsGrid.SetTemplateItem("RewardItem");
            RewardVO rewardVO = Service.StaticDataController.Get <RewardVO>(this.meta.Reward);
            List <RewardComponentTag> rewardComponents = RewardUtils.GetRewardComponents(rewardVO);

            for (int i = 0; i < rewardComponents.Count; i++)
            {
                RewardComponentTag rewardComponentTag = rewardComponents[i];
                string             itemUid            = rewardVO.Uid + i;
                UXElement          uXElement          = this.rewardsGrid.CloneTemplateItem(itemUid);
                uXElement.Tag = rewardComponentTag;
                UXLabel subElement = this.rewardsGrid.GetSubElement <UXLabel>(itemUid, "LabelRewardCount");
                subElement.Text = rewardComponentTag.Quantity;
                RewardType type = rewardComponentTag.Type;
                UXSprite   subElement2;
                if (type != RewardType.Building && type != RewardType.Currency)
                {
                    subElement2 = this.rewardsGrid.GetSubElement <UXSprite>(itemUid, "SpriteTroop");
                }
                else
                {
                    subElement2 = this.rewardsGrid.GetSubElement <UXSprite>(itemUid, "SpriteReward");
                }
                RewardUtils.SetRewardIcon(subElement2, rewardComponentTag.RewardGeometryConfig, AnimationPreference.NoAnimation);
                this.rewardsGrid.AddItem(uXElement, rewardComponentTag.Order);
                this.rewardsGrid.RepositionItems();
                this.rewardsGrid.Scroll(0.5f);
            }
            this.rewardsGrid.RepositionItems();
            this.rewardsGrid.Scroll(0.5f);
        }
コード例 #3
0
        public CrateVO GetCrateVOFromTargetedOffer(TargetedBundleVO offerVO)
        {
            IDataController dataController = Service.Get <IDataController>();

            if (offerVO == null)
            {
                return(null);
            }
            if (offerVO.RewardUIDs == null || offerVO.RewardUIDs.Count < 1)
            {
                return(null);
            }
            int i     = 0;
            int count = offerVO.RewardUIDs.Count;

            while (i < count)
            {
                RewardVO optional = Service.Get <IDataController>().GetOptional <RewardVO>(offerVO.RewardUIDs[i]);
                if (optional != null)
                {
                    string crateReward = optional.CrateReward;
                    if (!string.IsNullOrEmpty(crateReward))
                    {
                        return(dataController.GetOptional <CrateVO>(crateReward));
                    }
                }
                i++;
            }
            return(null);
        }
コード例 #4
0
        public RewardVO GenerateRewardFromSupply(CrateSupplyVO supplyData, int hqLevel)
        {
            RewardVO rewardVO = new RewardVO();

            rewardVO.Uid = (string.IsNullOrEmpty(supplyData.ScalingUid) ? supplyData.RewardUid : supplyData.ScalingUid);
            switch (supplyData.Type)
            {
            case SupplyType.Currency:
                rewardVO.CurrencyRewards = this.GetUnitRewardUid(supplyData, hqLevel);
                break;

            case SupplyType.Shard:
                rewardVO.ShardRewards = this.GetUnitRewardUid(supplyData, hqLevel);
                break;

            case SupplyType.Troop:
                rewardVO.TroopRewards = this.GetUnitRewardUid(supplyData, hqLevel);
                break;

            case SupplyType.Hero:
                rewardVO.HeroRewards = this.GetUnitRewardUid(supplyData, hqLevel);
                break;

            case SupplyType.SpecialAttack:
                rewardVO.SpecialAttackRewards = this.GetUnitRewardUid(supplyData, hqLevel);
                break;
            }
            return(rewardVO);
        }
コード例 #5
0
        public void TryAndGrantReward(RewardVO vo, RewardManager.SuccessCallback onSuccess, object cookie, bool checkCurrencyCapacity)
        {
            RewardabilityResult rewardabilityResult = RewardUtils.CanPlayerHandleReward(this.cp, vo, checkCurrencyCapacity);
            int       num       = ++this.callbackCounter;
            RewardTag rewardTag = new RewardTag();

            rewardTag.Vo            = vo;
            rewardTag.GlobalSuccess = onSuccess;
            rewardTag.Cookie        = cookie;
            this.rewardTags.Add(num, rewardTag);
            if (rewardabilityResult.CanAward)
            {
                this.GrantReward(num);
            }
            else
            {
                string message = Service.Lang.Get(rewardabilityResult.Reason, new object[0]);
                string title   = Service.Lang.Get("INVENTORY_NO_ROOM_TITLE", new object[0]);
                if (rewardabilityResult.Reason == "INVENTORY_NO_ROOM")
                {
                    YesNoScreen.ShowModal(title, message, false, new OnScreenModalResult(this.ForceCurrencyRewardUsage), rewardTag);
                }
                else
                {
                    AlertScreen.ShowModal(false, null, message, null, null);
                }
            }
        }
コード例 #6
0
        public void GrantSingleSupplyCrateReward(CrateSupplyVO crateSupplyData, int hqLevel)
        {
            switch (crateSupplyData.Type)
            {
            case SupplyType.Currency:
            case SupplyType.Shard:
            {
                RewardVO vo = this.GenerateRewardFromSupply(crateSupplyData, hqLevel);
                Service.RewardManager.TryAndGrantReward(vo, null, null, false);
                break;
            }

            case SupplyType.Troop:
            case SupplyType.Hero:
            case SupplyType.SpecialAttack:
            {
                RewardVO vo2 = this.GenerateRewardFromSupply(crateSupplyData, hqLevel);
                GameUtils.AddRewardToInventory(vo2);
                break;
            }

            case SupplyType.ShardTroop:
            case SupplyType.ShardSpecialAttack:
                Service.DeployableShardUnlockController.GrantUnlockShards(crateSupplyData.RewardUid, this.GetRewardAmount(crateSupplyData, hqLevel));
                break;

            case SupplyType.Invalid:
                Service.Logger.Error("Supply Type Invalid: " + crateSupplyData.Uid);
                break;
            }
        }
コード例 #7
0
 public static void GrantInstantBuildingUpgrade(RewardVO reward, CurrentPlayer cp)
 {
     for (int i = 0; i < reward.BuildingInstantUpgrades.Length; i++)
     {
         string[] array = reward.BuildingInstantUpgrades[i].Split(new char[]
         {
             ':'
         });
         int            num            = Convert.ToInt32(array[1], CultureInfo.InvariantCulture);
         string         text           = array[0];
         BuildingTypeVO buildingTypeVO = Service.Get <IDataController>().Get <BuildingTypeVO>(text);
         if (buildingTypeVO == null)
         {
             Service.Get <StaRTSLogger>().WarnFormat("buildingUiD {0} does not exist", new object[]
             {
                 text
             });
         }
         else
         {
             BuildingUpgradeCatalog  buildingUpgradeCatalog = Service.Get <BuildingUpgradeCatalog>();
             ISupportController      supportController      = Service.Get <ISupportController>();
             NodeList <BuildingNode> nodeList = Service.Get <EntityController>().GetNodeList <BuildingNode>();
             for (BuildingNode buildingNode = nodeList.Head; buildingNode != null; buildingNode = buildingNode.Next)
             {
                 BuildingTypeVO buildingType = buildingNode.BuildingComp.BuildingType;
                 if (buildingType.Lvl < num && buildingType.Type == buildingTypeVO.Type && buildingType.Type != BuildingType.Clearable)
                 {
                     BuildingTypeVO byLevel = buildingUpgradeCatalog.GetByLevel(buildingType.UpgradeGroup, num);
                     if (byLevel != null && byLevel.PlayerFacing)
                     {
                         if (!string.IsNullOrEmpty(buildingTypeVO.LinkedUnit))
                         {
                             if (ContractUtils.IsChampionRepairing(buildingNode.Entity))
                             {
                                 supportController.FinishCurrentContract(buildingNode.Entity, true);
                             }
                             if (cp.Inventory.Champion.GetItemAmount(buildingTypeVO.LinkedUnit) == 0)
                             {
                                 cp.OnChampionRepaired(buildingTypeVO.LinkedUnit);
                             }
                         }
                         supportController.StartBuildingUpgrade(byLevel, buildingNode.Entity, true);
                         int   boardX = buildingNode.Entity.Get <BoardItemComponent>().BoardItem.BoardX;
                         int   boardZ = buildingNode.Entity.Get <BoardItemComponent>().BoardItem.BoardZ;
                         float x;
                         float z;
                         EditBaseController.BuildingBoardToWorld(buildingNode.Entity, boardX, boardZ, out x, out z);
                         Vector3 worldLocation = new Vector3(x, 0f, z);
                         worldLocation.x = Units.BoardToWorldX(boardX);
                         worldLocation.z = Units.BoardToWorldX(boardZ);
                         Service.Get <WorldInitializer>().View.PanToLocation(worldLocation);
                     }
                 }
             }
         }
     }
 }
コード例 #8
0
        public bool IsRewardOnlySoftCurrency(string rewardUid)
        {
            if (string.IsNullOrEmpty(rewardUid))
            {
                return(true);
            }
            RewardVO rewardVO = this.sdc.Get <RewardVO>(rewardUid);

            return(rewardVO.BuildingUnlocks == null && rewardVO.HeroRewards == null && rewardVO.HeroUnlocks == null && rewardVO.SpecialAttackRewards == null && rewardVO.SpecialAttackUnlocks == null && rewardVO.TroopRewards == null && rewardVO.TroopUnlocks == null);
        }
コード例 #9
0
        public string GetRewardString(string rewardUid)
        {
            if (string.IsNullOrEmpty(rewardUid))
            {
                return(string.Empty);
            }
            RewardVO vo = this.sdc.Get <RewardVO>(rewardUid);

            return(this.GetRewardString(vo, Service.Lang.Get("SupplyRewardFormat", new object[0])));
        }
コード例 #10
0
        public void TryAndGrantReward(string rewardUid, RewardManager.SuccessCallback onSuccess, object cookie, bool checkCurrencyCapacity)
        {
            if (string.IsNullOrEmpty(rewardUid))
            {
                return;
            }
            RewardVO vo = this.sdc.Get <RewardVO>(rewardUid);

            this.TryAndGrantReward(vo, onSuccess, cookie, checkCurrencyCapacity);
        }
コード例 #11
0
        public static void GrantInAppPurchaseRewardToHQInventory(RewardVO reward)
        {
            UnlockController unlockController = Service.Get <UnlockController>();

            unlockController.GrantBuildingUnlockReward(reward.BuildingUnlocks);
            unlockController.GrantTroopUnlockReward(reward.TroopUnlocks);
            unlockController.GrantTroopUnlockReward(reward.HeroUnlocks);
            unlockController.GrantSpecialAttackUnlockReward(reward.SpecialAttackUnlocks);
            GameUtils.AddRewardToInventory(reward);
        }
コード例 #12
0
        public static int GetShardsRewarded(RewardVO reward)
        {
            int result = 0;

            if (reward.ShardRewards != null && reward.ShardRewards.Length != 0)
            {
                string[] array = reward.ShardRewards[0].Split(new char[]
                {
                    ':'
                });
                result = Convert.ToInt32(array[1], CultureInfo.InvariantCulture);
            }
            return(result);
        }
コード例 #13
0
 private void InitMissionRewardsGrid(string rewardUid, int campaignPoints)
 {
     this.rewardsGrid = this.screen.GetElement <UXGrid>("MissionRewardsGrid");
     this.rewardsGrid.Clear();
     this.rewardsGrid.SetTemplateItem("MissionRewardsItem");
     if (string.IsNullOrEmpty(rewardUid) && campaignPoints <= 0)
     {
         return;
     }
     if (campaignPoints > 0)
     {
         string    itemUid    = "RewardItem0";
         UXElement item       = this.rewardsGrid.CloneTemplateItem(itemUid);
         UXLabel   subElement = this.rewardsGrid.GetSubElement <UXLabel>(itemUid, "LabelMissionReward");
         subElement.Text = base.LangController.Get("CAMPAIGN_POINTS", new object[]
         {
             campaignPoints
         });
         UXSprite subElement2 = this.rewardsGrid.GetSubElement <UXSprite>(itemUid, "SpriteMissionReward");
         subElement2.Visible    = true;
         subElement2.SpriteName = "icoCampaignPoints";
         this.rewardsGrid.AddItem(item, 0);
     }
     else
     {
         RewardVO rewardVO = base.Sdc.Get <RewardVO>(rewardUid);
         List <RewardComponentTag> rewardComponents = RewardUtils.GetRewardComponents(rewardVO);
         int i     = 0;
         int count = rewardComponents.Count;
         while (i < count)
         {
             string             itemUid2           = "RewardItem" + i;
             RewardComponentTag rewardComponentTag = rewardComponents[i];
             UXElement          item2       = this.rewardsGrid.CloneTemplateItem(itemUid2);
             UXLabel            subElement3 = this.rewardsGrid.GetSubElement <UXLabel>(itemUid2, "LabelMissionReward");
             subElement3.Text = base.LangController.Get("CURRENCY_VALUE_NAME", new object[]
             {
                 rewardComponentTag.Quantity,
                 rewardComponentTag.RewardName
             });
             UXSprite subElement4 = this.rewardsGrid.GetSubElement <UXSprite>(itemUid2, "SpriteMissionReward");
             RewardUtils.SetRewardIcon(subElement4, rewardComponentTag.RewardGeometryConfig, AnimationPreference.NoAnimation);
             this.rewardsGrid.AddItem(item2, i);
             i++;
         }
     }
     this.rewardsGrid.RepositionItems();
     this.rewardsGrid.Scroll(0.5f);
 }
コード例 #14
0
        public void GrantTargetedBundleRewards(TargetedBundleVO offerVO)
        {
            IDataController dataController = Service.Get <IDataController>();
            int             i     = 0;
            int             count = offerVO.RewardUIDs.Count;

            while (i < count)
            {
                RewardVO optional = dataController.GetOptional <RewardVO>(offerVO.RewardUIDs[i]);
                if (optional == null)
                {
                    Service.Get <StaRTSLogger>().WarnFormat("Trying to grant {0} which cannot be found.", new object[]
                    {
                        offerVO.RewardUIDs[i]
                    });
                }
                else
                {
                    bool flag = true;
                    if (optional.CurrencyRewards != null)
                    {
                        Dictionary <string, int> dictionary = GameUtils.ListToMap(optional.CurrencyRewards);
                        int num = 0;
                        dictionary.TryGetValue("crystals", out num);
                        if (num > 0)
                        {
                            flag = false;
                        }
                    }
                    else if (!string.IsNullOrEmpty(optional.DroidRewards))
                    {
                        flag = false;
                    }
                    else if (optional.BuildingInstantRewards != null || optional.BuildingInstantUpgrades != null || optional.HeroResearchInstantUpgrades != null || optional.TroopResearchInstantUpgrades != null || optional.SpecAttackResearchInstantUpgrades != null)
                    {
                        flag = false;
                    }
                    if (flag)
                    {
                        RewardUtils.GrantInAppPurchaseRewardToHQInventory(optional);
                    }
                    else
                    {
                        RewardUtils.GrantReward(Service.Get <CurrentPlayer>(), optional);
                    }
                }
                i++;
            }
        }
コード例 #15
0
        private bool GetEquipmentShardUIInfoForCurrentItem(out int currentShardAmount, out int increasedShardAmount, out int shardsNeededForLevel, out bool showLevel, out EquipmentVO equipmentVoToDisplay)
        {
            currentShardAmount   = 0;
            increasedShardAmount = 0;
            shardsNeededForLevel = 0;
            equipmentVoToDisplay = null;
            showLevel            = false;
            CrateSupplyVO crateSupply = this.currentCrateItem.CrateSupply;

            if (crateSupply.Type != SupplyType.Shard)
            {
                return(false);
            }
            EquipmentVO equipment = this.currentCrateItem.Equipment;

            if (equipment == null)
            {
                return(false);
            }
            EquipmentUpgradeCatalog equipmentUpgradeCatalog = Service.EquipmentUpgradeCatalog;
            string equipmentID = equipment.EquipmentID;
            int    num         = (!this.shardsOriginal.ContainsKey(equipmentID)) ? 0 : this.shardsOriginal[equipmentID];

            currentShardAmount = num;
            RewardVO reward         = Service.InventoryCrateRewardController.GenerateRewardFromSupply(crateSupply, this.hq);
            int      shardsRewarded = RewardUtils.GetShardsRewarded(reward);
            int      num2           = num + shardsRewarded;

            increasedShardAmount = num2;
            EquipmentVO equipmentVO = equipment;

            showLevel = true;
            if (this.equipmentOriginal.ContainsKey(equipmentID))
            {
                int num3  = this.equipmentOriginal[equipmentID];
                int level = Mathf.Min(num3 + 1, equipmentUpgradeCatalog.GetMaxLevel(equipmentID).Lvl);
                equipmentVoToDisplay = equipmentUpgradeCatalog.GetByLevel(equipment, num3);
                equipmentVO          = equipmentUpgradeCatalog.GetByLevel(equipmentVoToDisplay, level);
            }
            else
            {
                equipmentVoToDisplay = equipmentUpgradeCatalog.GetMinLevel(equipmentVO.EquipmentID);
                equipmentVO          = equipmentVoToDisplay;
                showLevel            = false;
            }
            shardsNeededForLevel = equipmentVO.UpgradeShards;
            return(true);
        }
コード例 #16
0
        public static bool SetupTargetedOfferCrateRewardDisplay(RewardVO rewardVO, UXLabel itemLabel, UXSprite itemSprite)
        {
            if (string.IsNullOrEmpty(rewardVO.CrateReward))
            {
                return(false);
            }
            CrateVO optional = Service.Get <IDataController>().GetOptional <CrateVO>(rewardVO.CrateReward);

            if (optional != null)
            {
                itemLabel.Text = LangUtils.GetCrateDisplayName(optional);
                RewardUtils.SetCrateIcon(itemSprite, optional, AnimState.Closed);
                return(true);
            }
            return(false);
        }
コード例 #17
0
        public void GrantShopSupply(CrateSupplyVO supplyData, int quantity)
        {
            RewardVO rewardVO = new RewardVO();

            rewardVO.Uid = supplyData.RewardUid;
            string[] array = new string[]
            {
                supplyData.RewardUid + ":" + quantity
            };
            switch (supplyData.Type)
            {
            case SupplyType.Currency:
                rewardVO.CurrencyRewards = array;
                Service.RewardManager.TryAndGrantReward(rewardVO, null, null, false);
                break;

            case SupplyType.Shard:
                rewardVO.ShardRewards = array;
                Service.RewardManager.TryAndGrantReward(rewardVO, null, null, false);
                break;

            case SupplyType.Troop:
                rewardVO.TroopRewards = array;
                GameUtils.AddRewardToInventory(rewardVO);
                break;

            case SupplyType.Hero:
                rewardVO.HeroRewards = array;
                GameUtils.AddRewardToInventory(rewardVO);
                break;

            case SupplyType.SpecialAttack:
                rewardVO.SpecialAttackRewards = array;
                GameUtils.AddRewardToInventory(rewardVO);
                break;

            case SupplyType.ShardTroop:
                Service.DeployableShardUnlockController.GrantUnlockShards(rewardVO.Uid, quantity);
                break;

            case SupplyType.ShardSpecialAttack:
                Service.DeployableShardUnlockController.GrantUnlockShards(rewardVO.Uid, quantity);
                break;
            }
        }
コード例 #18
0
        private void InitRewardGrid()
        {
            RewardVO rewardVO = null;

            if (!string.IsNullOrEmpty(this.missionVO.Rewards))
            {
                rewardVO = Service.StaticDataController.Get <RewardVO>(this.missionVO.Rewards);
            }
            this.rewardTable = base.GetElement <UXTable>("RewardTable");
            if (rewardVO != null && rewardVO.CurrencyRewards != null)
            {
                this.rewardTable.Visible = true;
                this.rewardTable.SetTemplateItem("RewardTemplate");
                UXUtils.HideChildrenRecursively(base.GetElement <UXElement>("RewardIconType").Root, true);
                for (int i = 0; i < rewardVO.CurrencyRewards.Length; i++)
                {
                    string[] array = rewardVO.CurrencyRewards[i].Split(new char[]
                    {
                        ':'
                    });
                    string key = array[0];
                    if (this.rewardIconMap.ContainsKey(key))
                    {
                        string    text    = "RewardIcon" + this.rewardIconMap[key];
                        string    text2   = this.lang.ThousandsSeparated(Convert.ToInt32(array[1]));
                        string    itemUid = text + i;
                        UXElement item    = this.rewardTable.CloneTemplateItem(itemUid);
                        this.rewardTable.GetSubElement <UXSprite>(itemUid, text).Visible           = true;
                        this.rewardTable.GetSubElement <UXLabel>(itemUid, "RewardValueLabel").Text = text2;
                        this.rewardTable.AddItem(item, i);
                    }
                }
                this.rewardTable.RepositionItems();
            }
            else
            {
                this.rewardTable.Visible = false;
            }
        }
コード例 #19
0
        private bool CanPurchaseIAPLinkedOffer(TargetedBundleVO currentOffer)
        {
            bool            flag           = true;
            IDataController dataController = Service.Get <IDataController>();
            int             i     = 0;
            int             count = currentOffer.RewardUIDs.Count;

            while (i < count)
            {
                RewardVO optional = dataController.GetOptional <RewardVO>(currentOffer.RewardUIDs[i]);
                if (optional != null && optional.BuildingInstantRewards != null)
                {
                    flag = this.CanPlaceAllRewardBuildings(optional.BuildingInstantRewards);
                    if (!flag)
                    {
                        AlertScreen.ShowModal(false, Service.Get <Lang>().Get("promo_error_nospace_title", new object[0]), Service.Get <Lang>().Get("promo_error_nospace_desc", new object[0]), null, null);
                        break;
                    }
                }
                i++;
            }
            return(flag);
        }
コード例 #20
0
        private void UpdateElements()
        {
            IDataController dataController = Service.Get <IDataController>();

            if (this.currentOffer != null)
            {
                UXLabel element = base.GetElement <UXLabel>("LabelTitle");
                element.Text = this.lang.Get(this.currentOffer.Title, new object[0]);
                UXLabel element2 = base.GetElement <UXLabel>("LabelDescription");
                element2.Text = this.lang.Get(this.currentOffer.ConfirmationString, new object[0]);
                int i     = 0;
                int count = this.currentOffer.RewardUIDs.Count;
                while (i < count)
                {
                    RewardVO rewardVO = dataController.Get <RewardVO>(this.currentOffer.RewardUIDs[i]);
                    if (!RewardUtils.SetupTargetedOfferCrateRewardDisplay(rewardVO, this.itemLabels[i], this.itemSprites[i]))
                    {
                        List <RewardComponentTag> rewardComponents = RewardUtils.GetRewardComponents(rewardVO);
                        int j      = 0;
                        int count2 = rewardComponents.Count;
                        while (j < count2)
                        {
                            RewardComponentTag rewardComponentTag = rewardComponents[j];
                            this.itemLabels[i].Text = this.lang.Get("AMOUNT_AND_NAME", new object[]
                            {
                                rewardComponentTag.RewardName,
                                rewardComponentTag.Quantity
                            });
                            RewardUtils.SetRewardIcon(this.itemSprites[i], rewardComponentTag.RewardGeometryConfig, AnimationPreference.NoAnimation);
                            j++;
                        }
                    }
                    i++;
                }
                this.confirmButton.Tag = this.currentOffer;
            }
        }
コード例 #21
0
 private void ClaimReward(string limitedTimeRewardUid, string contextUid)
 {
     if (!string.IsNullOrEmpty(contextUid))
     {
         StaticDataController staticDataController = Service.StaticDataController;
         LimitedTimeRewardVO  optional             = staticDataController.GetOptional <LimitedTimeRewardVO>(limitedTimeRewardUid);
         if (optional == null)
         {
             Service.Logger.WarnFormat("No LimitedTimeReward data found for uid: {0}", new object[]
             {
                 limitedTimeRewardUid
             });
             return;
         }
         RewardVO optional2 = staticDataController.GetOptional <RewardVO>(optional.RewardUid);
         if (optional2 == null)
         {
             Service.Logger.WarnFormat("LimitedTimeReward {0} points to reward {1} but it was not found", new object[]
             {
                 limitedTimeRewardUid,
                 optional.RewardUid
             });
             return;
         }
         HolonetClaimRewardRequest request = new HolonetClaimRewardRequest(limitedTimeRewardUid, contextUid);
         HolonetClaimRewardCommand command = new HolonetClaimRewardCommand(request);
         Service.ServerAPI.Sync(command);
         GameUtils.AddRewardToInventory(optional2);
         Service.CurrentPlayer.AddHolonetReward(limitedTimeRewardUid);
         Lang   lang = Service.Lang;
         string text = lang.Get(optional.Title, new object[0]);
         AlertScreen.ShowModal(false, lang.Get("hn_reward_redeemed", new object[0]), lang.Get("hn_reward_claimed_desc", new object[]
         {
             text
         }), null, null);
     }
 }
コード例 #22
0
        private void UpdateElements()
        {
            StaticDataController     staticDataController     = Service.StaticDataController;
            TargetedBundleController targetedBundleController = Service.TargetedBundleController;

            this.currentOffer = targetedBundleController.CurrentTargetedOffer;
            if (this.currentOffer != null)
            {
                UXLabel element = base.GetElement <UXLabel>("LabelTitle");
                element.Text = this.lang.Get(this.currentOffer.Title, new object[0]);
                UXLabel element2 = base.GetElement <UXLabel>("LabelDescription");
                element2.Text = this.lang.Get(this.currentOffer.Description, new object[0]);
                TextureVO optional = staticDataController.GetOptional <TextureVO>("gui_textures_promotional");
                if (optional != null)
                {
                    UXTexture element3 = base.GetElement <UXTexture>("TexturePromoArt");
                    element3.LoadTexture(optional.AssetName);
                }
                optional = staticDataController.GetOptional <TextureVO>("targeted_bundle_entry");
                if (optional != null)
                {
                    UXTexture element4 = base.GetElement <UXTexture>("TextureEnvironmentEntry");
                    element4.LoadTexture(optional.AssetName);
                }
                optional = staticDataController.GetOptional <TextureVO>("targeted_bundle_treads");
                if (optional != null)
                {
                    UXTexture element5 = base.GetElement <UXTexture>("TextureEnvironmentRight");
                    element5.LoadTexture(optional.AssetName);
                }
                optional = staticDataController.GetOptional <TextureVO>("targeted_bundle_treads");
                if (optional != null)
                {
                    UXTexture element6 = base.GetElement <UXTexture>("TextureEnvironmentLeft");
                    element6.LoadTexture(optional.AssetName);
                }
                optional = staticDataController.GetOptional <TextureVO>("targeted_bundle_dust");
                if (optional != null)
                {
                    UXTexture element7 = base.GetElement <UXTexture>("TextureEnvironmentDustRight");
                    element7.LoadTexture(optional.AssetName);
                    element7 = base.GetElement <UXTexture>("TextureEnvironmentDustLeft");
                    element7.LoadTexture(optional.AssetName);
                }
                int i     = 0;
                int count = this.currentOffer.RewardUIDs.Count;
                while (i < count)
                {
                    RewardVO rewardVO = staticDataController.Get <RewardVO>(this.currentOffer.RewardUIDs[i]);
                    if (!RewardUtils.SetupTargetedOfferCrateRewardDisplay(rewardVO, this.itemLabels[i], this.itemSprites[i]))
                    {
                        List <RewardComponentTag> rewardComponents = RewardUtils.GetRewardComponents(rewardVO);
                        int j      = 0;
                        int count2 = rewardComponents.Count;
                        while (j < count2)
                        {
                            RewardComponentTag rewardComponentTag = rewardComponents[j];
                            this.itemLabels[i].Text = this.lang.Get("AMOUNT_AND_NAME", new object[]
                            {
                                rewardComponentTag.RewardName,
                                rewardComponentTag.Quantity
                            });
                            RewardUtils.SetRewardIcon(this.itemSprites[i], rewardComponentTag.RewardGeometryConfig, AnimationPreference.AnimationAlways);
                            j++;
                        }
                    }
                    i++;
                }
                if (targetedBundleController.IsCurrencyCostOffer(this.currentOffer))
                {
                    this.SetupCurrencyCostOffer(this.currentOffer);
                }
                else
                {
                    this.SetupIAPLinkedOffer(this.currentOffer);
                }
                UXUtils.SetupAnimatedCharacter(this.characterSprite1, this.currentOffer.Character1Image, ref this.charGeometry1);
                UXUtils.SetupAnimatedCharacter(this.characterSprite2, this.currentOffer.Character2Image, ref this.charGeometry2);
                uint serverTime = Service.ServerAPI.ServerTime;
                this.timeRemaining   = (int)(targetedBundleController.OfferExpiresAt - serverTime);
                this.timerLabel.Text = this.lang.Get("expires_in", new object[]
                {
                    GameUtils.GetTimeLabelFromSeconds(this.timeRemaining)
                });
                this.valueLabel.Text = this.lang.Get("PERCENTAGE", new object[]
                {
                    this.currentOffer.Discount.ToString()
                });
                this.value2Label.Text = this.lang.Get("TARGETED_BUNDLE_DISCOUNT", new object[]
                {
                    this.currentOffer.Discount.ToString()
                });
            }
            else
            {
                Service.Logger.Error("No current offer available for targeted bundle screen");
            }
        }
コード例 #23
0
 public string GetRewardString(RewardVO vo, string formatString)
 {
     return(this.GetRewardStringInternal(vo, formatString, false));
 }
コード例 #24
0
 public string GetRewardStringWithLevel(RewardVO vo, string formatString)
 {
     return(this.GetRewardStringInternal(vo, formatString, true));
 }
コード例 #25
0
        private string GetRewardStringInternal(RewardVO vo, string formatString, bool withLevel)
        {
            bool          flag          = true;
            StringBuilder stringBuilder = new StringBuilder();

            if (vo.CurrencyRewards != null)
            {
                int i   = 0;
                int num = vo.CurrencyRewards.Length;
                while (i < num)
                {
                    if (!flag)
                    {
                        stringBuilder.Append(", ");
                    }
                    string[] array = vo.CurrencyRewards[i].Split(new char[]
                    {
                        ':'
                    });
                    stringBuilder.AppendFormat(formatString, this.lang.Get(array[0].ToUpper(), new object[0]), this.lang.ThousandsSeparated(Convert.ToInt32(array[1])));
                    flag = false;
                    i++;
                }
            }
            if (vo.ShardRewards != null)
            {
                int i   = 0;
                int num = vo.ShardRewards.Length;
                while (i < num)
                {
                    if (!flag)
                    {
                        stringBuilder.Append(", ");
                    }
                    string[] array2 = vo.ShardRewards[i].Split(new char[]
                    {
                        ':'
                    });
                    this.AppendRewardString(stringBuilder, formatString, LangUtils.GetEquipmentDisplayNameById(array2[0]), array2[1]);
                    flag = false;
                    i++;
                }
            }
            if (vo.BuildingUnlocks != null)
            {
                int i   = 0;
                int num = vo.BuildingUnlocks.Length;
                while (i < num)
                {
                    if (!flag)
                    {
                        stringBuilder.Append(", ");
                    }
                    BuildingTypeVO buildingTypeVO = this.sdc.Get <BuildingTypeVO>(vo.BuildingUnlocks[i]);
                    bool           unlocked       = Service.CurrentPlayer.UnlockedLevels.Buildings.Has(buildingTypeVO);
                    this.AppendUnlockString(stringBuilder, LangUtils.GetBuildingDisplayName(buildingTypeVO), unlocked, flag);
                    flag = false;
                    i++;
                }
            }
            if (vo.TroopUnlocks != null)
            {
                int i   = 0;
                int num = vo.TroopUnlocks.Length;
                while (i < num)
                {
                    if (!flag)
                    {
                        stringBuilder.Append(", ");
                    }
                    TroopTypeVO troopTypeVO = this.sdc.Get <TroopTypeVO>(vo.TroopUnlocks[i]);
                    bool        unlocked    = Service.CurrentPlayer.UnlockedLevels.Troops.Has(troopTypeVO);
                    this.AppendUnlockString(stringBuilder, LangUtils.GetTroopDisplayName(troopTypeVO), unlocked, flag);
                    flag = false;
                    i++;
                }
            }
            if (vo.TroopRewards != null)
            {
                int i   = 0;
                int num = vo.TroopRewards.Length;
                while (i < num)
                {
                    if (!flag)
                    {
                        stringBuilder.Append(", ");
                    }
                    string[] array3 = vo.TroopRewards[i].Split(new char[]
                    {
                        ':'
                    });
                    TroopTypeVO troopTypeVO = this.sdc.Get <TroopTypeVO>(array3[0]);
                    string      text        = LangUtils.GetTroopDisplayName(troopTypeVO);
                    if (withLevel)
                    {
                        text = this.lang.Get("AMOUNT_AND_NAME", new object[]
                        {
                            text,
                            this.lang.Get("lcfly_level", new object[]
                            {
                                troopTypeVO.Lvl
                            })
                        });
                    }
                    this.AppendRewardString(stringBuilder, formatString, text, array3[1]);
                    flag = false;
                    i++;
                }
            }
            if (vo.HeroUnlocks != null)
            {
                int i   = 0;
                int num = vo.HeroUnlocks.Length;
                while (i < num)
                {
                    if (!flag)
                    {
                        stringBuilder.Append(", ");
                    }
                    TroopTypeVO troopTypeVO2 = this.sdc.Get <TroopTypeVO>(vo.HeroUnlocks[i]);
                    bool        unlocked     = Service.CurrentPlayer.UnlockedLevels.Troops.Has(troopTypeVO2);
                    this.AppendUnlockString(stringBuilder, LangUtils.GetTroopDisplayName(troopTypeVO2), unlocked, flag);
                    flag = false;
                    i++;
                }
            }
            if (vo.HeroRewards != null)
            {
                int i   = 0;
                int num = vo.HeroRewards.Length;
                while (i < num)
                {
                    if (!flag)
                    {
                        stringBuilder.Append(", ");
                    }
                    string[] array4 = vo.HeroRewards[i].Split(new char[]
                    {
                        ':'
                    });
                    TroopTypeVO troopTypeVO2 = this.sdc.Get <TroopTypeVO>(array4[0]);
                    string      text2        = LangUtils.GetTroopDisplayName(troopTypeVO2);
                    if (withLevel)
                    {
                        text2 = this.lang.Get("AMOUNT_AND_NAME", new object[]
                        {
                            text2,
                            this.lang.Get("lcfly_level", new object[]
                            {
                                troopTypeVO2.Lvl
                            })
                        });
                    }
                    this.AppendRewardString(stringBuilder, formatString, text2, array4[1]);
                    flag = false;
                    i++;
                }
            }
            if (vo.SpecialAttackUnlocks != null)
            {
                int i   = 0;
                int num = vo.SpecialAttackUnlocks.Length;
                while (i < num)
                {
                    if (!flag)
                    {
                        stringBuilder.Append(", ");
                    }
                    SpecialAttackTypeVO specialAttackTypeVO = this.sdc.Get <SpecialAttackTypeVO>(vo.SpecialAttackUnlocks[i]);
                    bool unlocked = Service.CurrentPlayer.UnlockedLevels.Starships.Has(specialAttackTypeVO);
                    this.AppendUnlockString(stringBuilder, LangUtils.GetStarshipDisplayName(specialAttackTypeVO), unlocked, flag);
                    flag = false;
                    i++;
                }
            }
            if (vo.SpecialAttackRewards != null)
            {
                int i   = 0;
                int num = vo.SpecialAttackRewards.Length;
                while (i < num)
                {
                    if (!flag)
                    {
                        stringBuilder.Append(", ");
                    }
                    string[] array5 = vo.SpecialAttackRewards[i].Split(new char[]
                    {
                        ':'
                    });
                    SpecialAttackTypeVO specialAttackTypeVO = this.sdc.Get <SpecialAttackTypeVO>(array5[0]);
                    string text3 = LangUtils.GetStarshipDisplayName(specialAttackTypeVO);
                    if (withLevel)
                    {
                        text3 = this.lang.Get("AMOUNT_AND_NAME", new object[]
                        {
                            text3,
                            this.lang.Get("lcfly_level", new object[]
                            {
                                specialAttackTypeVO.Lvl
                            })
                        });
                    }
                    this.AppendRewardString(stringBuilder, formatString, text3, array5[1]);
                    flag = false;
                    i++;
                }
            }
            return(stringBuilder.ToString());
        }
コード例 #26
0
 public static bool IsUnlockReward(RewardVO rewardVO)
 {
     return(rewardVO.BuildingUnlocks != null || rewardVO.TroopUnlocks != null || rewardVO.SpecialAttackUnlocks != null || rewardVO.HeroUnlocks != null);
 }
コード例 #27
0
 public static void GrantReward(CurrentPlayer cp, RewardVO reward)
 {
     RewardUtils.GrantReward(cp, reward, 1.0);
 }
コード例 #28
0
        public static void GrantReward(CurrentPlayer cp, RewardVO reward, double saleBonusMultiplier)
        {
            UnlockController unlockController = Service.Get <UnlockController>();

            unlockController.GrantBuildingUnlockReward(reward.BuildingUnlocks);
            unlockController.GrantTroopUnlockReward(reward.TroopUnlocks);
            unlockController.GrantTroopUnlockReward(reward.HeroUnlocks);
            unlockController.GrantSpecialAttackUnlockReward(reward.SpecialAttackUnlocks);
            if (reward.CurrencyRewards != null)
            {
                int i   = 0;
                int num = reward.CurrencyRewards.Length;
                while (i < num)
                {
                    string[] array = reward.CurrencyRewards[i].Split(new char[]
                    {
                        ':'
                    });
                    int itemCapacity = cp.Inventory.GetItemCapacity(array[0]);
                    int itemAmount   = cp.Inventory.GetItemAmount(array[0]);
                    int num2         = Convert.ToInt32(array[1], CultureInfo.InvariantCulture);
                    if (saleBonusMultiplier > 1.0)
                    {
                        num2 = (int)Math.Floor((double)num2 * saleBonusMultiplier);
                    }
                    if (itemCapacity != -1)
                    {
                        int val   = itemCapacity - itemAmount;
                        int delta = Math.Min(val, num2);
                        cp.Inventory.ModifyItemAmount(array[0], delta);
                    }
                    else
                    {
                        cp.Inventory.ModifyItemAmount(array[0], num2);
                    }
                    i++;
                }
            }
            if (reward.ShardRewards != null)
            {
                ArmoryController armoryController = Service.Get <ArmoryController>();
                int i   = 0;
                int num = reward.ShardRewards.Length;
                while (i < num)
                {
                    string[] array2 = reward.ShardRewards[i].Split(new char[]
                    {
                        ':'
                    });
                    int count = Convert.ToInt32(array2[1], CultureInfo.InvariantCulture);
                    armoryController.HandleEarnedShardReward(array2[0], count);
                    i++;
                }
            }
            if (reward.TroopRewards != null)
            {
                int i   = 0;
                int num = reward.TroopRewards.Length;
                while (i < num)
                {
                    string[] array3 = reward.TroopRewards[i].Split(new char[]
                    {
                        ':'
                    });
                    int delta2 = Convert.ToInt32(array3[1], CultureInfo.InvariantCulture);
                    cp.Inventory.Troop.ModifyItemAmount(array3[0], delta2);
                    i++;
                }
            }
            if (reward.HeroRewards != null)
            {
                int i   = 0;
                int num = reward.HeroRewards.Length;
                while (i < num)
                {
                    string[] array4 = reward.HeroRewards[i].Split(new char[]
                    {
                        ':'
                    });
                    int delta3 = Convert.ToInt32(array4[1], CultureInfo.InvariantCulture);
                    cp.Inventory.Hero.ModifyItemAmount(array4[0], delta3);
                    i++;
                }
            }
            if (reward.SpecialAttackRewards != null)
            {
                int i   = 0;
                int num = reward.SpecialAttackRewards.Length;
                while (i < num)
                {
                    string[] array5 = reward.SpecialAttackRewards[i].Split(new char[]
                    {
                        ':'
                    });
                    int delta4 = Convert.ToInt32(array5[1], CultureInfo.InvariantCulture);
                    cp.Inventory.SpecialAttack.ModifyItemAmount(array5[0], delta4);
                    i++;
                }
            }
            if (!string.IsNullOrEmpty(reward.DroidRewards))
            {
                int delta5 = Convert.ToInt32(reward.DroidRewards, CultureInfo.InvariantCulture);
                cp.Inventory.ModifyDroids(delta5);
            }
            if (reward.BuildingInstantRewards != null)
            {
                int i   = 0;
                int num = reward.BuildingInstantRewards.Length;
                while (i < num)
                {
                    string[] array6 = reward.BuildingInstantRewards[i].Split(new char[]
                    {
                        ':'
                    });
                    int            num3           = Convert.ToInt32(array6[1], CultureInfo.InvariantCulture);
                    string         text           = array6[0];
                    BuildingTypeVO buildingTypeVO = Service.Get <IDataController>().Get <BuildingTypeVO>(text);
                    if (buildingTypeVO == null)
                    {
                        Service.Get <StaRTSLogger>().WarnFormat("buildingUiD {0} does not exist", new object[]
                        {
                            text
                        });
                    }
                    else
                    {
                        for (int j = 0; j < num3; j++)
                        {
                            Service.Get <BuildingController>().PlaceRewardedBuilding(buildingTypeVO);
                        }
                    }
                    i++;
                }
            }
            if (reward.BuildingInstantUpgrades != null)
            {
                RewardUtils.GrantInstantBuildingUpgrade(reward, cp);
            }
            if (reward.HeroResearchInstantUpgrades != null)
            {
                int i   = 0;
                int num = reward.HeroResearchInstantUpgrades.Length;
                while (i < num)
                {
                    RewardUtils.GrantInstantTroopHeroUpgrade(reward.HeroResearchInstantUpgrades[i]);
                    i++;
                }
            }
            if (reward.TroopResearchInstantUpgrades != null)
            {
                int i   = 0;
                int num = reward.TroopResearchInstantUpgrades.Length;
                while (i < num)
                {
                    RewardUtils.GrantInstantTroopHeroUpgrade(reward.TroopResearchInstantUpgrades[i]);
                    i++;
                }
            }
            if (reward.SpecAttackResearchInstantUpgrades != null)
            {
                int i   = 0;
                int num = reward.SpecAttackResearchInstantUpgrades.Length;
                while (i < num)
                {
                    RewardUtils.GrantInstantSpecialAttackUpgrade(reward.SpecAttackResearchInstantUpgrades[i]);
                    i++;
                }
            }
        }
コード例 #29
0
        public static List <RewardComponentTag> GetRewardComponents(RewardVO rewardVO)
        {
            List <RewardComponentTag> list           = new List <RewardComponentTag>();
            IDataController           dataController = Service.Get <IDataController>();
            Dictionary <string, int>  dictionary     = GameUtils.ListToMap(rewardVO.TroopRewards);

            foreach (string current in dictionary.Keys)
            {
                RewardComponentTag item        = default(RewardComponentTag);
                TroopTypeVO        troopTypeVO = dataController.Get <TroopTypeVO>(current);
                item.RewardName = LangUtils.GetTroopDisplayName(troopTypeVO);
                item.Quantity   = Service.Get <Lang>().Get("TROOP_MULTIPLIER", new object[]
                {
                    dictionary[current]
                });
                item.RewardAssetName      = troopTypeVO.AssetName;
                item.RewardGeometryConfig = troopTypeVO;
                item.Type = RewardType.Troop;
                list.Add(item);
            }
            dictionary = GameUtils.ListToMap(rewardVO.HeroRewards);
            foreach (string current2 in dictionary.Keys)
            {
                RewardComponentTag item2        = default(RewardComponentTag);
                TroopTypeVO        troopTypeVO2 = dataController.Get <TroopTypeVO>(current2);
                item2.RewardName = LangUtils.GetTroopDisplayName(troopTypeVO2);
                item2.Quantity   = Service.Get <Lang>().Get("TROOP_MULTIPLIER", new object[]
                {
                    dictionary[current2]
                });
                item2.RewardAssetName      = troopTypeVO2.AssetName;
                item2.RewardGeometryConfig = troopTypeVO2;
                item2.Type = RewardType.Troop;
                list.Add(item2);
            }
            dictionary = GameUtils.ListToMap(rewardVO.SpecialAttackRewards);
            foreach (string current3 in dictionary.Keys)
            {
                RewardComponentTag  item3 = default(RewardComponentTag);
                SpecialAttackTypeVO specialAttackTypeVO = dataController.Get <SpecialAttackTypeVO>(current3);
                item3.RewardName = LangUtils.GetStarshipDisplayName(specialAttackTypeVO);
                item3.Quantity   = Service.Get <Lang>().Get("TROOP_MULTIPLIER", new object[]
                {
                    dictionary[current3]
                });
                item3.RewardAssetName      = specialAttackTypeVO.AssetName;
                item3.RewardGeometryConfig = specialAttackTypeVO;
                item3.Type = RewardType.Troop;
                list.Add(item3);
            }
            dictionary = GameUtils.ListToMap(rewardVO.CurrencyRewards);
            foreach (string current4 in dictionary.Keys)
            {
                RewardComponentTag item4 = default(RewardComponentTag);
                item4.RewardName = Service.Get <Lang>().Get(current4.ToUpper(), new object[0]);
                int num = dictionary[current4];
                item4.Quantity = Service.Get <Lang>().ThousandsSeparated(num);
                int num2 = 0;
                int num3 = 0;
                if (current4 == "credits")
                {
                    num2 = GameConstants.CREDITS_3_THRESHOLD;
                    num3 = GameConstants.CREDITS_2_THRESHOLD;
                }
                else if (current4 == "materials")
                {
                    num2 = GameConstants.MATERIALS_3_THRESHOLD;
                    num3 = GameConstants.MATERIALS_2_THRESHOLD;
                }
                else if (current4 == "contraband")
                {
                    num2 = GameConstants.CONTRABAND_3_THRESHOLD;
                    num3 = GameConstants.CONTRABAND_2_THRESHOLD;
                }
                else if (current4 == "crystals")
                {
                    num2 = GameConstants.CRYSTALS_3_THRESHOLD;
                    num3 = GameConstants.CRYSTALS_2_THRESHOLD;
                }
                if (num >= num2)
                {
                    item4.RewardAssetName = current4 + 3;
                }
                else if (num >= num3)
                {
                    item4.RewardAssetName = current4 + 2;
                }
                else
                {
                    item4.RewardAssetName = current4 + 1;
                }
                item4.RewardGeometryConfig = dataController.Get <CurrencyIconVO>(item4.RewardAssetName);
                item4.Type = RewardType.Currency;
                list.Add(item4);
            }
            if (rewardVO.HeroUnlocks != null)
            {
                int i    = 0;
                int num4 = rewardVO.HeroUnlocks.Length;
                while (i < num4)
                {
                    RewardComponentTag item5        = default(RewardComponentTag);
                    TroopTypeVO        troopTypeVO3 = dataController.Get <TroopTypeVO>(rewardVO.HeroUnlocks[i]);
                    item5.RewardName           = LangUtils.GetTroopDisplayName(troopTypeVO3);
                    item5.Quantity             = Service.Get <Lang>().Get("LABEL_REWARD_UNLOCKED", new object[0]);
                    item5.RewardAssetName      = troopTypeVO3.AssetName;
                    item5.RewardGeometryConfig = troopTypeVO3;
                    item5.Type = RewardType.Troop;
                    list.Add(item5);
                    i++;
                }
            }
            if (rewardVO.TroopUnlocks != null)
            {
                int j    = 0;
                int num5 = rewardVO.TroopUnlocks.Length;
                while (j < num5)
                {
                    RewardComponentTag item6        = default(RewardComponentTag);
                    TroopTypeVO        troopTypeVO4 = dataController.Get <TroopTypeVO>(rewardVO.TroopUnlocks[j]);
                    item6.RewardName           = LangUtils.GetTroopDisplayName(troopTypeVO4);
                    item6.Quantity             = Service.Get <Lang>().Get("LABEL_REWARD_UNLOCKED", new object[0]);
                    item6.RewardAssetName      = troopTypeVO4.AssetName;
                    item6.RewardGeometryConfig = troopTypeVO4;
                    item6.Type = RewardType.Troop;
                    list.Add(item6);
                    j++;
                }
            }
            if (rewardVO.SpecialAttackUnlocks != null)
            {
                int k    = 0;
                int num6 = rewardVO.SpecialAttackUnlocks.Length;
                while (k < num6)
                {
                    RewardComponentTag  item7 = default(RewardComponentTag);
                    SpecialAttackTypeVO specialAttackTypeVO2 = dataController.Get <SpecialAttackTypeVO>(rewardVO.SpecialAttackUnlocks[k]);
                    item7.RewardName           = LangUtils.GetStarshipDisplayName(specialAttackTypeVO2);
                    item7.Quantity             = Service.Get <Lang>().Get("LABEL_REWARD_UNLOCKED", new object[0]);
                    item7.RewardAssetName      = specialAttackTypeVO2.AssetName;
                    item7.RewardGeometryConfig = specialAttackTypeVO2;
                    item7.Type = RewardType.Troop;
                    list.Add(item7);
                    k++;
                }
            }
            if (rewardVO.BuildingUnlocks != null)
            {
                int l    = 0;
                int num7 = rewardVO.BuildingUnlocks.Length;
                while (l < num7)
                {
                    RewardComponentTag item8          = default(RewardComponentTag);
                    BuildingTypeVO     buildingTypeVO = dataController.Get <BuildingTypeVO>(rewardVO.BuildingUnlocks[l]);
                    item8.RewardName           = LangUtils.GetBuildingDisplayName(buildingTypeVO);
                    item8.Quantity             = Service.Get <Lang>().Get("LABEL_REWARD_UNLOCKED", new object[0]);
                    item8.RewardAssetName      = buildingTypeVO.AssetName;
                    item8.RewardGeometryConfig = buildingTypeVO;
                    item8.Type = RewardType.Building;
                    list.Add(item8);
                    l++;
                }
            }
            if (!string.IsNullOrEmpty(rewardVO.DroidRewards))
            {
                RewardComponentTag item9        = default(RewardComponentTag);
                TroopTypeVO        troopTypeVO5 = dataController.Get <TroopTypeVO>("troopWorkerDroid");
                item9.RewardName           = LangUtils.GetTroopDisplayName(troopTypeVO5);
                item9.Quantity             = rewardVO.DroidRewards;
                item9.RewardAssetName      = troopTypeVO5.AssetName;
                item9.RewardGeometryConfig = troopTypeVO5;
                item9.Type = RewardType.BuilderDroid;
                list.Add(item9);
            }
            dictionary = GameUtils.ListToMap(rewardVO.BuildingInstantRewards);
            foreach (string current5 in dictionary.Keys)
            {
                RewardComponentTag item10 = default(RewardComponentTag);
                RewardUtils.GetBuildingReward(current5, ref item10);
                item10.Quantity = Service.Get <Lang>().Get("TROOP_MULTIPLIER", new object[]
                {
                    dictionary[current5]
                });
                list.Add(item10);
            }
            if (rewardVO.BuildingInstantUpgrades != null)
            {
                int m    = 0;
                int num8 = rewardVO.BuildingInstantUpgrades.Length;
                while (m < num8)
                {
                    RewardComponentTag item11 = default(RewardComponentTag);
                    string[]           array  = RewardUtils.ParsePairedStrings(rewardVO.BuildingInstantUpgrades[m], ':');
                    RewardUtils.GetBuildingReward(array[0], ref item11);
                    item11.Quantity = Service.Get <Lang>().Get("LABEL_REWARD_UPGRADE", new object[0]);
                    list.Add(item11);
                    m++;
                }
            }
            if (rewardVO.HeroResearchInstantUpgrades != null)
            {
                int n    = 0;
                int num9 = rewardVO.HeroResearchInstantUpgrades.Length;
                while (n < num9)
                {
                    RewardComponentTag item12 = default(RewardComponentTag);
                    RewardUtils.GetInstantTroopReward(rewardVO.HeroResearchInstantUpgrades[n], ref item12);
                    list.Add(item12);
                    n++;
                }
            }
            if (rewardVO.TroopResearchInstantUpgrades != null)
            {
                int num10 = 0;
                int num11 = rewardVO.TroopResearchInstantUpgrades.Length;
                while (num10 < num11)
                {
                    RewardComponentTag item13 = default(RewardComponentTag);
                    RewardUtils.GetInstantTroopReward(rewardVO.TroopResearchInstantUpgrades[num10], ref item13);
                    list.Add(item13);
                    num10++;
                }
            }
            if (rewardVO.SpecAttackResearchInstantUpgrades != null)
            {
                int num12 = 0;
                int num13 = rewardVO.SpecAttackResearchInstantUpgrades.Length;
                while (num12 < num13)
                {
                    RewardComponentTag item14 = default(RewardComponentTag);
                    RewardUtils.GetInstantSpecialAttackReward(rewardVO.SpecAttackResearchInstantUpgrades[num12], ref item14);
                    list.Add(item14);
                    num12++;
                }
            }
            return(list);
        }
コード例 #30
0
        public static RewardabilityResult CanPlayerHandleReward(CurrentPlayer cp, RewardVO reward, bool checkCurrencyCapacity)
        {
            RewardabilityResult rewardabilityResult = new RewardabilityResult();
            IDataController     dataController      = Service.Get <IDataController>();

            if (reward.TroopRewards != null)
            {
                int num  = 0;
                int num2 = cp.Inventory.Troop.GetTotalStorageCapacity() - cp.Inventory.Troop.GetTotalStorageAmount();
                for (int i = 0; i < reward.TroopRewards.Length; i++)
                {
                    string[] array = reward.TroopRewards[i].Split(new char[]
                    {
                        ':'
                    });
                    TroopTypeVO troopTypeVO = dataController.Get <TroopTypeVO>(array[0]);
                    num += troopTypeVO.Size * Convert.ToInt32(array[1], CultureInfo.InvariantCulture);
                }
                if (num > num2)
                {
                    rewardabilityResult.CanAward = false;
                    rewardabilityResult.Reason   = "NOT_ENOUGH_HOUSING";
                }
            }
            if (reward.HeroRewards != null)
            {
                int num  = 0;
                int num2 = cp.Inventory.Hero.GetTotalStorageCapacity() - cp.Inventory.Hero.GetTotalStorageAmount();
                for (int i = 0; i < reward.HeroRewards.Length; i++)
                {
                    string[] array = reward.HeroRewards[i].Split(new char[]
                    {
                        ':'
                    });
                    TroopTypeVO troopTypeVO2 = dataController.Get <TroopTypeVO>(array[0]);
                    num += troopTypeVO2.Size * Convert.ToInt32(array[1], CultureInfo.InvariantCulture);
                }
                if (num > num2)
                {
                    rewardabilityResult.CanAward = false;
                    rewardabilityResult.Reason   = "NOT_ENOUGH_SPACE";
                }
            }
            if (reward.SpecialAttackRewards != null)
            {
                int num  = 0;
                int num2 = cp.Inventory.SpecialAttack.GetTotalStorageCapacity() - cp.Inventory.SpecialAttack.GetTotalStorageAmount();
                for (int i = 0; i < reward.SpecialAttackRewards.Length; i++)
                {
                    string[] array = reward.SpecialAttackRewards[i].Split(new char[]
                    {
                        ':'
                    });
                    SpecialAttackTypeVO specialAttackTypeVO = dataController.Get <SpecialAttackTypeVO>(array[0]);
                    num += specialAttackTypeVO.Size * Convert.ToInt32(array[1], CultureInfo.InvariantCulture);
                }
                if (num > num2)
                {
                    rewardabilityResult.CanAward = false;
                    rewardabilityResult.Reason   = "NOT_ENOUGH_SPACE";
                }
            }
            if (reward.CurrencyRewards != null & checkCurrencyCapacity)
            {
                int num3 = cp.CurrentReputationAmount;
                int maxReputationAmount = cp.MaxReputationAmount;
                int num4 = cp.CurrentContrabandAmount;
                int maxContrabandAmount = cp.MaxContrabandAmount;
                int num5 = cp.CurrentMaterialsAmount;
                int maxMaterialsAmount = cp.MaxMaterialsAmount;
                int num6             = cp.CurrentCreditsAmount;
                int maxCreditsAmount = cp.MaxCreditsAmount;
                for (int i = 0; i < reward.CurrencyRewards.Length; i++)
                {
                    string[] array = reward.CurrencyRewards[i].Split(new char[]
                    {
                        ':'
                    });
                    if (array[0] == "contraband")
                    {
                        num4 += int.Parse(array[1]);
                        if (num4 > maxContrabandAmount)
                        {
                            rewardabilityResult.CanAward = false;
                            rewardabilityResult.Reason   = "INVENTORY_NO_ROOM";
                            return(rewardabilityResult);
                        }
                    }
                    if (array[0] == "reputation")
                    {
                        num3 += int.Parse(array[1]);
                        if (num3 > maxReputationAmount)
                        {
                            rewardabilityResult.CanAward = false;
                            rewardabilityResult.Reason   = "INVENTORY_NO_ROOM";
                            return(rewardabilityResult);
                        }
                    }
                    if (array[0] == "materials")
                    {
                        num5 += int.Parse(array[1]);
                        if (num5 > maxMaterialsAmount)
                        {
                            rewardabilityResult.CanAward = false;
                            rewardabilityResult.Reason   = "INVENTORY_NO_ROOM";
                            return(rewardabilityResult);
                        }
                    }
                    if (array[0] == "credits")
                    {
                        num6 += int.Parse(array[1]);
                        if (num6 > maxCreditsAmount)
                        {
                            rewardabilityResult.CanAward = false;
                            rewardabilityResult.Reason   = "INVENTORY_NO_ROOM";
                            return(rewardabilityResult);
                        }
                    }
                }
            }
            return(rewardabilityResult);
        }