예제 #1
0
        private bool ShouldBadgeResearchBuilding()
        {
            DeployableShardUnlockController deployableShardUnlockController = Service.DeployableShardUnlockController;
            ArmoryController armoryController = Service.ArmoryController;
            bool             flag             = deployableShardUnlockController.AllowResearchBuildingBadging && deployableShardUnlockController.DoesUserHaveAnyUpgradeableShardUnits();
            bool             flag2            = armoryController.AllowShowEquipmentTabBadge && armoryController.DoesUserHaveAnyUpgradableEquipment();

            return(flag || flag2);
        }
예제 #2
0
        public EatResponse OnEvent(EventId id, object cookie)
        {
            switch (id)
            {
            case EventId.BattleReplaySetup:
            {
                BattleRecord battleRecord = (BattleRecord)cookie;
                ArmoryController.AddEquipmentBuffs(battleRecord.AttackerEquipment, battleRecord.DefenderEquipment);
                return(EatResponse.NotEaten);
            }

            case EventId.BattleRecordRetrieved:
            {
                GetReplayResponse getReplayResponse = (GetReplayResponse)cookie;
                BattleRecord      replayData        = getReplayResponse.ReplayData;
                ArmoryController.AddEquipmentBuffs(replayData.AttackerEquipment, replayData.DefenderEquipment);
                return(EatResponse.NotEaten);
            }

            case EventId.BattleLeftBeforeStarting:
            case EventId.BattleReplayEnded:
                goto IL_150;

            case EventId.BattleLoadedForDefend:
                break;

            default:
                switch (id)
                {
                case EventId.EquipmentUnlocked:
                    this.pendingCelebrationEquipment = (cookie as EquipmentVO);
                    this.UpdateLastEquipmentUnlocked(this.pendingCelebrationEquipment.Uid);
                    if (this.AllowUnlockCelebration)
                    {
                        if (GameUtils.IsUnlockBlockingScreenOpen())
                        {
                            Service.EventManager.RegisterObserver(this, EventId.ScreenClosing);
                        }
                        else
                        {
                            bool immediate = GameUtils.CanShardUnlockCelebrationPlayImmediately();
                            this.ShowEquipmentUnlockedCelebration(immediate);
                        }
                    }
                    return(EatResponse.NotEaten);

                case EventId.EquipmentUpgraded:
                {
                    ContractEventData    contractEventData    = cookie as ContractEventData;
                    StaticDataController staticDataController = Service.StaticDataController;
                    EquipmentVO          equipmentVO          = staticDataController.Get <EquipmentVO>(contractEventData.Contract.ProductUid);
                    this.UpdateActiveArmoryLevel(equipmentVO);
                    return(EatResponse.NotEaten);
                }

                case EventId.EquipmentActivated:
                case EventId.EquipmentDeactivated:
                    this.UpdateArmoryBuildingTooltip();
                    return(EatResponse.NotEaten);

                default:
                    switch (id)
                    {
                    case EventId.ScreenClosing:
                        if (cookie is InventoryCrateCollectionScreen)
                        {
                            GameUtils.CloseStoreOrInventoryScreen();
                            Service.EventManager.UnregisterObserver(this, EventId.ScreenClosing);
                            if (this.AllowUnlockCelebration)
                            {
                                this.ShowEquipmentUnlockedCelebration(false);
                            }
                        }
                        return(EatResponse.NotEaten);

                    case EventId.ScreenClosed:
                    case EventId.ScreenOverlayClosing:
                    {
IL_58:
                        if (id == EventId.BattleLoadStart)
                        {
                            goto IL_E3;
                        }
                        if (id == EventId.BattleEndFullyProcessed)
                        {
                            goto IL_150;
                        }
                        if (id != EventId.PlanetConfirmRelocate)
                        {
                            return(EatResponse.NotEaten);
                        }
                        CurrentPlayer        currentPlayer         = Service.CurrentPlayer;
                        StaticDataController staticDataController2 = Service.StaticDataController;
                        for (int i = currentPlayer.ActiveArmory.Equipment.Count - 1; i >= 0; i--)
                        {
                            EquipmentVO equipment = staticDataController2.Get <EquipmentVO>(currentPlayer.ActiveArmory.Equipment[i]);
                            if (!ArmoryUtils.IsEquipmentValidForPlanet(equipment, (string)cookie))
                            {
                                this.DeactivateEquipmentOnClient(currentPlayer, equipment);
                            }
                        }
                        return(EatResponse.NotEaten);
                    }

                    case EventId.ScreenLoaded:
                        if (cookie is ArmoryScreen)
                        {
                            this.UpdateLastEquipmentUnlocked("false");
                        }
                        return(EatResponse.NotEaten);
                    }
                    goto IL_58;
                }
                break;
            }
IL_E3:
            CurrentBattle currentBattle = Service.BattleController.GetCurrentBattle();

            ArmoryController.AddEquipmentBuffs(currentBattle.AttackerEquipment, currentBattle.DefenderEquipment);
            return(EatResponse.NotEaten);

IL_150:
            Service.BuffController.ClearEquipmentBuffs();
            return(EatResponse.NotEaten);
        }
예제 #3
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++;
                }
            }
        }
예제 #4
0
 public unsafe static long $Invoke1(long instance, long *args)
 {
     ArmoryController.AddEquipmentBuffs((List <string>)GCHandledObjects.GCHandleToObject(*args), (List <string>)GCHandledObjects.GCHandleToObject(args[1]));
     return(-1L);
 }