private void CheckForEliminations(IVictoryManagementService victoryManagementService)
 {
     foreach (Empire empire in base.GameServer.Game.Empires)
     {
         MajorEmpire majorEmpire = empire as MajorEmpire;
         if (majorEmpire == null)
         {
             break;
         }
         if (majorEmpire.SimulationObject.Tags.Contains(Empire.TagEmpireEliminated))
         {
             foreach (Empire empire2 in base.GameServer.Game.Empires)
             {
                 empire2.OnEmpireEliminated(majorEmpire, true);
             }
         }
     }
 }
예제 #2
0
    public override void RefreshContent()
    {
        if (base.Empire == null)
        {
            return;
        }
        IVictoryManagementService service = base.Game.Services.GetService <IVictoryManagementService>();

        this.filteredVictoryConditions = new List <VictoryCondition>();
        foreach (VictoryCondition victoryCondition in service.VictoryConditionsFilteredThisGame)
        {
            if (victoryCondition.Progression != null)
            {
                this.filteredVictoryConditions.Add(victoryCondition);
            }
        }
        this.VictoryTable.Width = 0f;
        this.VictoryTable.ReserveChildren(this.filteredVictoryConditions.Count, this.VictoryStatusItemPrefab, "Item");
        this.VictoryTable.RefreshChildrenIList <VictoryCondition>(this.filteredVictoryConditions, new AgeTransform.RefreshTableItem <VictoryCondition>(this.SetupVictoryCondition), true, false);
        this.VictoryTable.ArrangeChildren();
        this.VictoryScrollview.ResetLeft();
        this.scoreGraphsPanel.RefreshContent();
    }
    public override void Begin(params object[] parameters)
    {
        if (TutorialManager.IsActivated)
        {
            ITutorialService service = TutorialManager.GetService();
            if (service != null && !service.GetValue <bool>(TutorialManager.EnableVictoryKey, true))
            {
                base.GameServer.PostStateChange(typeof(GameServerState_Turn_AI), new object[0]);
                return;
            }
        }
        base.Begin(parameters);
        if (Amplitude.Unity.Framework.Application.Version.Accessibility <= Accessibility.Internal)
        {
            Diagnostics.Log("GameServerState_Turn_CheckForGameEndingConditions.");
        }
        IVictoryManagementService service2 = base.GameServer.Game.Services.GetService <IVictoryManagementService>();

        if (service2 != null)
        {
            this.TurnToCheckTheGameEndingConditionsFor = base.GameServer.Game.Turn - 1;
            bool           flag           = false;
            VictoryManager victoryManager = service2 as VictoryManager;
            if (victoryManager != null)
            {
                victoryManager.OnBeginTurn();
            }
            this.CheckForVictoryConditions(service2, out flag);
            if (flag)
            {
                base.GameServer.PostStateChange(typeof(GameServerState_Turn_DealWithGameEndingConditions), new object[0]);
                return;
            }
        }
        base.GameServer.PostStateChange(typeof(GameServerState_Turn_AI), new object[0]);
    }
예제 #4
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;
    }
 private void CheckForVictoryConditions(IVictoryManagementService victoryManagementService, out bool gameEnding)
 {
     gameEnding = false;
     if (victoryManagementService != null && victoryManagementService.HasAlreadyWon)
     {
         return;
     }
     if (base.GameServer.Game.Turn > 0 && victoryManagementService != null)
     {
         try
         {
             victoryManagementService.VictoryConditionRaised += this.VictoryManagementService_VictoryConditionRaised;
             this.victoryConditionsRaised.Clear();
             victoryManagementService.CheckForVictoryConditions(this.TurnToCheckTheGameEndingConditionsFor);
         }
         catch
         {
         }
         finally
         {
             victoryManagementService.VictoryConditionRaised -= this.VictoryManagementService_VictoryConditionRaised;
         }
         if (this.victoryConditionsRaised.Count > 0)
         {
             Dictionary <string, List <Empire> > dictionary = new Dictionary <string, List <Empire> >();
             foreach (VictoryConditionRaisedEventArgs victoryConditionRaisedEventArgs in this.victoryConditionsRaised)
             {
                 if (!(victoryConditionRaisedEventArgs.VictoryCondition.Category != VictoryCondition.ReadOnlyVictory))
                 {
                     List <Empire> list = null;
                     if (!dictionary.TryGetValue(victoryConditionRaisedEventArgs.VictoryCondition.Name, out list))
                     {
                         list = new List <Empire>();
                         dictionary.Add(victoryConditionRaisedEventArgs.VictoryCondition.Name, list);
                     }
                     list.Add(victoryConditionRaisedEventArgs.Empire);
                 }
             }
             if (dictionary.Count > 0)
             {
                 StringBuilder stringBuilder = new StringBuilder(1024);
                 foreach (KeyValuePair <string, List <Empire> > keyValuePair in dictionary)
                 {
                     if (stringBuilder.Length > 0)
                     {
                         stringBuilder.Append('&');
                     }
                     stringBuilder.Append(keyValuePair.Key);
                     for (int i = 0; i < keyValuePair.Value.Count; i++)
                     {
                         stringBuilder.Append(',');
                         stringBuilder.Append(keyValuePair.Value[i].Index);
                     }
                 }
                 base.GameServer.Session.SetLobbyData("Victory", stringBuilder.ToString(), true);
                 gameEnding = true;
                 victoryManagementService.HasAlreadyWon = true;
             }
         }
     }
 }