Ejemplo n.º 1
0
    public void Activate()
    {
        if (!Booster.CanActivate(this.BoosterDefinition, this.Context))
        {
            return;
        }
        if (this.IsActive())
        {
            this.OnReactivation();
            if (this.BoosterDefinition.BoosterType == BoosterDefinition.Type.ResettingTime)
            {
                return;
            }
        }
        else
        {
            if (this.BoosterDefinition.BoosterType == BoosterDefinition.Type.Instant)
            {
                this.Duration = 0;
            }
            else
            {
                this.TurnWhenStarted = this.game.Turn;
                this.Context.AddChild(this);
                this.ApplyClassTimedDescriptor();
                this.ApplyDescriptors(true);
                this.RemainingTime = this.Duration;
            }
            this.ApplyEffects();
            this.Context.Refresh(false);
        }
        if (this.game != null)
        {
            IVisibilityService service = this.game.Services.GetService <IVisibilityService>();
            if (service != null && this.empire != null)
            {
                service.NotifyVisibilityHasChanged(this.empire);
            }
        }
        if (this.BoosterDefinition.Effects != null)
        {
            for (int i = 0; i < this.BoosterDefinition.Effects.Length; i++)
            {
                BoosterEffect effect = this.BoosterDefinition.Effects[i];
                if (Booster.CheckPrerequisites(effect, this.Context))
                {
                    this.ExecuteCommands(effect);
                }
            }
        }
        IEventService service2 = Services.GetService <IEventService>();

        if (service2 != null)
        {
            service2.Notify(new EventBoosterActivated(this.empire, this));
        }
    }
Ejemplo n.º 2
0
    private void ReleaseKaijuArmyActions()
    {
        DepartmentOfDefense  agency = this.Empire.GetAgency <DepartmentOfDefense>();
        SimulationDescriptor value  = this.SimulationDescriptorDatabase.GetValue(DepartmentOfTheInterior.ArmyStatusBesiegerDescriptorName);

        this.KaijuArmy.RemoveDescriptor(value);
        if (this.KaijuArmy.IsEarthquaker)
        {
            this.KaijuArmy.SetEarthquakerStatus(false, false, null);
        }
        if (this.KaijuArmy.PillageTarget.IsValid)
        {
            DepartmentOfDefense.StopPillage(this.KaijuArmy);
        }
        if (this.KaijuArmy.IsAspirating)
        {
            agency.StopAspirating(this.KaijuArmy);
        }
        if (this.KaijuArmy.IsDismantlingDevice)
        {
            ITerraformDeviceRepositoryService service = this.gameService.Game.Services.GetService <ITerraformDeviceRepositoryService>();
            TerraformDevice device = service[this.KaijuArmy.DismantlingDeviceTarget] as TerraformDevice;
            agency.StopDismantelingDevice(this.KaijuArmy, device);
        }
        if (this.KaijuArmy.IsDismantlingCreepingNode)
        {
            CreepingNode creepingNode = null;
            if (this.gameEntityRepositoryService.TryGetValue <CreepingNode>(this.KaijuArmy.DismantlingCreepingNodeTarget, out creepingNode))
            {
                agency.StopDismantelingCreepingNode(this.KaijuArmy, creepingNode);
            }
        }
        IWorldPositionningService service2 = this.gameService.Game.Services.GetService <IWorldPositionningService>();
        Region region = service2.GetRegion(this.KaijuArmy.WorldPosition);

        if (region.City != null && region.City.Empire != this.Empire)
        {
            DepartmentOfTheInterior agency2 = region.City.Empire.GetAgency <DepartmentOfTheInterior>();
            if (agency2 != null)
            {
                if (region.City.BesiegingEmpire == this.Empire && agency2.NeedToStopSiege(region.City))
                {
                    agency2.StopSiege(region.City);
                }
                agency2.StopNavalSiege(region.City, this.KaijuArmy);
            }
            IVisibilityService service3 = this.gameService.Game.Services.GetService <IVisibilityService>();
            service3.NotifyVisibilityHasChanged(this.Empire);
        }
    }
Ejemplo n.º 3
0
    private IEnumerator RunAsync()
    {
        if (this.EventService != null)
        {
            this.EventService.Notify(new EventBeginTurn(base.GameClient.Game.Turn));
            if (base.GameClient.Game.Turn == 0 && TutorialManager.IsActivated)
            {
                IPlayerControllerRepositoryService service = base.GameClient.Game.Services.GetService <IPlayerControllerRepositoryService>();
                this.EventService.Notify(new EventTutorialGameStarted(service.ActivePlayerController.Empire));
            }
            if (base.GameClient.Game.Turn == 0)
            {
                IDownloadableContentService service2 = Services.GetService <IDownloadableContentService>();
                if (service2 != null)
                {
                    List <DownloadableContent> list = new List <DownloadableContent>();
                    foreach (DownloadableContent downloadableContent in service2)
                    {
                        DownloadableContentType type = downloadableContent.Type;
                        if ((type == DownloadableContentType.Exclusive || type == DownloadableContentType.Personal) && service2.IsShared(downloadableContent.Name))
                        {
                            list.Add(downloadableContent);
                        }
                    }
                    if (list.Count > 0)
                    {
                        for (int i = list.Count - 1; i >= 0; i--)
                        {
                            StaticString key = string.Format("DownloadableContent/{0}/RunOnce/Notified", list[i].Name);
                            if (!Amplitude.Unity.Framework.Application.Registry.GetValue <bool>(key, false))
                            {
                                Amplitude.Unity.Framework.Application.Registry.SetValue <bool>(key, true);
                                this.EventService.Notify(new EventDownloadableContentPresentation(list[i]));
                            }
                        }
                    }
                    Empire clientEmpire = base.GameClient.GetClientEmpire();
                    if (clientEmpire != null && !clientEmpire.Faction.IsCustom && clientEmpire.Faction.IsStandard)
                    {
                        this.EventService.Notify(new EventFactionPresentation(clientEmpire.Faction));
                    }
                }
            }
        }
        SeasonManager seasonManager = base.GameClient.Game.GetService <ISeasonService>() as SeasonManager;

        if (seasonManager != null)
        {
            seasonManager.GameClient_Turn_Begin();
        }
        PillarManager pillarManager = base.GameClient.Game.GetService <IPillarService>() as PillarManager;

        if (pillarManager != null)
        {
            pillarManager.OnBeginTurn();
        }
        TerraformDeviceManager terraformDeviceManager = base.GameClient.Game.GetService <ITerraformDeviceService>() as TerraformDeviceManager;

        if (terraformDeviceManager != null)
        {
            terraformDeviceManager.GameClient_Turn_Begin();
        }
        WorldEffectManager worldEffectManager = base.GameClient.Game.GetService <IWorldEffectService>() as WorldEffectManager;

        if (worldEffectManager != null)
        {
            worldEffectManager.OnBeginTurn();
        }
        LeechManager leechManager = base.GameClient.Game.GetService <ILeechService>() as LeechManager;

        if (leechManager != null)
        {
            leechManager.OnBeginTurn();
        }
        CooldownManager cooldownManager = base.GameClient.Game.GetService <ICooldownManagementService>() as CooldownManager;

        if (cooldownManager != null)
        {
            cooldownManager.OnBeginTurn();
        }
        MapBoostManager mapBoostManager = base.GameClient.Game.GetService <IMapBoostService>() as MapBoostManager;

        if (mapBoostManager != null)
        {
            mapBoostManager.GameClient_OnBeginTurn();
        }
        RegionalEffectsManager regionalEffectsManager = base.GameClient.Game.GetService <IRegionalEffectsService>() as RegionalEffectsManager;

        if (regionalEffectsManager != null)
        {
            regionalEffectsManager.GameClient_Turn_Begin();
        }
        WeatherManager weatherManager = base.GameClient.Game.GetService <IWeatherService>() as WeatherManager;

        if (weatherManager != null)
        {
            weatherManager.GameClient_Turn_Begin();
        }
        int num;

        for (int index = 0; index < base.GameClient.Game.Empires.Length; index = num + 1)
        {
            yield return(base.GameClient.Game.Empires[index].DoPasses("GameClientState_Turn_Begin"));

            base.GameClient.Game.Empires[index].Refresh(true);
            num = index;
        }
        IVisibilityService service3 = base.GameClient.Game.GetService <IVisibilityService>();

        if (service3 != null)
        {
            IPlayerControllerRepositoryService service4 = base.GameClient.Game.GetService <IPlayerControllerRepositoryService>();
            if (service4 != null && service4.ActivePlayerController != null && service4.ActivePlayerController.Empire != null)
            {
                service3.NotifyVisibilityHasChanged((Empire)service4.ActivePlayerController.Empire);
            }
        }
        IVictoryManagementService service5 = base.GameClient.Game.GetService <IVictoryManagementService>();

        if (service5 != null)
        {
            service5.CheckForAlerts(base.GameClient.Game.Turn - 1);
        }
        IWorldPositionningService service6 = base.GameClient.Game.GetService <IWorldPositionningService>();

        if (service6 != null)
        {
            service6.RefreshDefensiveTowerMapForEveryone();
        }
        yield break;
    }