Beispiel #1
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);
        }
Beispiel #2
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++;
                }
            }
        }