Exemple #1
0
        public TownHall(IWood wood, IBuilder builder, IVisibilityService visibilityService, IStoryService storyService, IHyperState hyperState, IBuilder builder1) : base(builder1, hyperState)
        {
            _wood              = wood;
            _builder           = builder;
            _visibilityService = visibilityService;
            _storyService      = storyService;

            BuildTime = 50_000;
        }
Exemple #2
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));
        }
    }
Exemple #3
0
        public StoryService(ApplicationState state, IResourceService resourceService, IVisibilityService visibilityService, IWorkerService workerService)
        {
            _state             = state;
            _resourceService   = resourceService;
            _visibilityService = visibilityService;
            _workerService     = workerService;

            AddOutput("the field is icy cold");
            AddOutput("there is no fire...");
        }
Exemple #4
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);
        }
    }
Exemple #5
0
    public bool IsVisibleFor(global::Empire empire)
    {
        IGameService service = Services.GetService <IGameService>();

        if (service != null)
        {
            IVisibilityService service2 = service.Game.Services.GetService <IVisibilityService>();
            if (service != null)
            {
                if (this.isVisibleInFogOfWar)
                {
                    return(service2.IsWorldPositionExploredFor(this.WorldPosition, empire) || service2.IsWorldPositionVisibleFor(this.WorldPosition, empire));
                }
                return(service2.IsWorldPositionVisibleFor(this.WorldPosition, empire));
            }
        }
        return(false);
    }
Exemple #6
0
        public ScreenConductor(IUnityContainer container,
                               IScreenFactoryRegistry screenFactoryRegistry,
                               IEventAggregator eventAggregator,
                               IRegionManager regionManager,
                               IVisibilityService visibilityService)
        {
            this.activeScreenKey = ScreenKeyType.None;

            this.Container             = container;
            this.ScreenFactoryRegistry = screenFactoryRegistry;
            this.EventAggregator       = eventAggregator;
            this.RegionManager         = regionManager;
            this.VisibilityService     = visibilityService;

            this.ScreenCollection = new Dictionary <ScreenKeyType, IScreen>();
            mainRegion            = this.RegionManager.Regions[RegionConstants.REGION_MAIN_AREA];
            SubscribeToEvents();
        }
        public ScreenConductor(IUnityContainer container, 
            IScreenFactoryRegistry screenFactoryRegistry, 
            IEventAggregator eventAggregator, 
            IRegionManager regionManager, 
            IVisibilityService visibilityService
            )
        {
            this._activeScreenName = "";

            this.Container = container;
            this.ScreenFactoryRegistry = screenFactoryRegistry;
            _eventManager = eventAggregator;
            this.RegionManager = regionManager;
            this.VisibilityService = visibilityService;
            _logger = Container.Resolve<ILoggerFacade>();
            this.ScreenCollection = new Dictionary<string, IScreen>();
            SubscribeToEvents();
        }
 private bool Accept(WorldPosition worldPosition)
 {
     worldPosition = base.GlobalPositionningService.FromRelativeToConstrainedWorldPosition(worldPosition);
     if (!worldPosition.IsValid)
     {
         return(false);
     }
     if (base.WorldPositionningService != null)
     {
         int regionIndex = (int)base.WorldPositionningService.GetRegionIndex(worldPosition);
         if (regionIndex != this.City.Region.Index)
         {
             return(false);
         }
         IVisibilityService service = base.GameService.Game.Services.GetService <IVisibilityService>();
         if (!service.IsWorldPositionExploredFor(worldPosition, this.City.Empire))
         {
             return(false);
         }
     }
     return(true);
 }
Exemple #9
0
 public TownHall(IWood wood, IBuilder builder, IVisibilityService visibilityService)
 {
     _wood              = wood;
     _builder           = builder;
     _visibilityService = visibilityService;
 }
Exemple #10
0
 public HeaderConductor(IUnityContainer container, IScreenFactoryRegistry screenFactoryRegistry, IEventAggregator eventAggregator, IRegionManager regionManager, IVisibilityService visibilityService)
     : base(container, screenFactoryRegistry, eventAggregator, regionManager, visibilityService)
 {
     MyRegionName = RegionName.Header;
     Region = this.RegionManager.Regions[RegionConstants.REGION_HEADER];
 }
Exemple #11
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;
    }
Exemple #12
0
    public static bool HasSaveAttackableTargetsNearby(Garrison Attacker, int size, DepartmentOfForeignAffairs departmentOfForeignAffairs, out List <IGarrison> Targets, bool NavalOnly = false)
    {
        IIntelligenceAIHelper service  = AIScheduler.Services.GetService <IIntelligenceAIHelper>();
        IVisibilityService    service2 = Services.GetService <IGameService>().Game.Services.GetService <IVisibilityService>();

        Targets = new List <IGarrison>();
        if (size < 1 || Attacker == null || !(Attacker is IWorldPositionable))
        {
            return(false);
        }
        List <global::Empire> list = new List <global::Empire>(Array.FindAll <global::Empire>((Services.GetService <IGameService>().Game as global::Game).Empires, (global::Empire match) => match is MajorEmpire && departmentOfForeignAffairs.IsAtWarWith(match)));

        if (list.Count < 1)
        {
            return(false);
        }
        bool result = true;
        IWorldPositionningService service3 = Services.GetService <IGameService>().Game.Services.GetService <IWorldPositionningService>();

        foreach (global::Empire empire in list)
        {
            List <Garrison>         list2   = new List <Garrison>();
            DepartmentOfDefense     agency  = empire.GetAgency <DepartmentOfDefense>();
            DepartmentOfTheInterior agency2 = empire.GetAgency <DepartmentOfTheInterior>();
            if (!NavalOnly)
            {
                list2.AddRange(agency.Armies.ToList <Army>().FindAll((Army match) => !match.IsSeafaring && !match.IsSettler).Cast <Garrison>());
                list2.AddRange(agency2.Cities.Cast <Garrison>());
                list2.AddRange(agency2.Camps.Cast <Garrison>());
                list2.AddRange(agency2.ConvertedVillages.Cast <Garrison>());
            }
            if (NavalOnly)
            {
                list2.AddRange(agency.Armies.ToList <Army>().FindAll((Army match) => match.IsNaval && !match.IsSettler).Cast <Garrison>());
                list2.AddRange(agency2.OccupiedFortresses.Cast <Garrison>());
            }
            foreach (Garrison garrison in list2)
            {
                if (garrison.UnitsCount > 0 && garrison is IWorldPositionable && (float)service3.GetDistance((garrison as IWorldPositionable).WorldPosition, (Attacker as IWorldPositionable).WorldPosition) <= (float)size && departmentOfForeignAffairs.CanAttack(garrison) && (!garrison.SimulationObject.Tags.Contains(Army.TagCamouflaged) || service2.IsWorldPositionDetectedFor((garrison as IWorldPositionable).WorldPosition, Attacker.Empire)) && service2.IsWorldPositionVisibleFor((garrison as IWorldPositionable).WorldPosition, Attacker.Empire))
                {
                    float num  = 0f;
                    float num2 = 0f;
                    if (!NavalOnly)
                    {
                        service.EstimateMPInBattleground(Attacker, garrison, ref num, ref num2);
                    }
                    else
                    {
                        num  += Attacker.GetPropertyValue(SimulationProperties.MilitaryPower);
                        num2 += garrison.GetPropertyValue(SimulationProperties.MilitaryPower);
                        if (Attacker is Army && (Attacker as Army).IsSeafaring && garrison is Army && !(garrison as Army).IsSeafaring)
                        {
                            num2 *= 0.2f;
                        }
                    }
                    if (num > num2 * 1.5f)
                    {
                        Targets.Add(garrison);
                    }
                    else
                    {
                        result = false;
                    }
                }
            }
        }
        if (Targets.Count == 0)
        {
            result = false;
        }
        return(result);
    }
Exemple #13
0
    public override bool CanApply(IDiplomaticContract diplomaticContract, params string[] flags)
    {
        if (!base.CanApply(diplomaticContract, new string[0]))
        {
            return(false);
        }
        Diagnostics.Assert(base.EmpireWhichProvides != null && base.EmpireWhichReceives != null);
        DepartmentOfTheInterior agency  = base.EmpireWhichProvides.GetAgency <DepartmentOfTheInterior>();
        DepartmentOfTheInterior agency2 = base.EmpireWhichReceives.GetAgency <DepartmentOfTheInterior>();

        Diagnostics.Assert(agency != null && agency2 != null);
        City city = agency.Cities.FirstOrDefault((City match) => match.GUID == this.CityGUID);

        if (city == null)
        {
            return(false);
        }
        if (city.BesiegingEmpire != null)
        {
            return(false);
        }
        if (diplomaticContract.EmpireWhichProposes.Index != base.EmpireWhichProvides.Index)
        {
            IGameService service = Services.GetService <IGameService>();
            Diagnostics.Assert(service != null);
            IVisibilityService service2 = service.Game.Services.GetService <IVisibilityService>();
            Diagnostics.Assert(service2 != null);
            District cityCenter = city.GetCityCenter();
            if (cityCenter == null || !service2.IsWorldPositionExploredFor(cityCenter.WorldPosition, base.EmpireWhichReceives))
            {
                return(false);
            }
        }
        if (base.Definition.Name == DiplomaticTermCityExchange.MimicsCityDeal)
        {
            if (agency.MainCity == city)
            {
                return(false);
            }
            if (base.EmpireWhichProvides.Faction.Affinity.Name == base.EmpireWhichReceives.Faction.Affinity.Name)
            {
                return(false);
            }
            if (city.IsInfected)
            {
                return(false);
            }
            if (base.EmpireWhichReceives.GetAgency <DepartmentOfPlanificationAndDevelopment>().HasIntegratedFaction(base.EmpireWhichProvides.Faction))
            {
                return(false);
            }
            if (agency2.InfectedCities.Any((City c) => c.LastNonInfectedOwner != null && (c.LastNonInfectedOwner == base.EmpireWhichProvides || c.LastNonInfectedOwner.Faction == base.EmpireWhichProvides.Faction)))
            {
                return(false);
            }
        }
        int num  = agency.Cities.Count;
        int num2 = agency2.Cities.Count;

        for (int i = 0; i < diplomaticContract.Terms.Count; i++)
        {
            DiplomaticTermCityExchange diplomaticTermCityExchange = diplomaticContract.Terms[i] as DiplomaticTermCityExchange;
            if (diplomaticTermCityExchange != null && !(diplomaticTermCityExchange.CityGUID == this.CityGUID))
            {
                if (base.Definition.Name == DiplomaticTermCityExchange.MimicsCityDeal)
                {
                    return(false);
                }
                if (diplomaticTermCityExchange.EmpireWhichProvides.Index == base.EmpireWhichProvides.Index)
                {
                    num--;
                    num2++;
                }
                else if (diplomaticTermCityExchange.EmpireWhichProvides.Index == base.EmpireWhichReceives.Index)
                {
                    num2--;
                    num++;
                }
                else
                {
                    Diagnostics.LogError("Can't identify the empire which provides the term {0}.", new object[]
                    {
                        diplomaticTermCityExchange
                    });
                }
            }
        }
        num--;
        num2++;
        return(num >= 1 && num2 >= 1);
    }