public static void ComputeInfiltrationActionGuiElement(Amplitude.Unity.Gui.IGuiService guiService, InfiltrationAction infiltrationAction, out GuiElement guiElement)
 {
     if (!guiService.GuiPanelHelper.TryGetGuiElement("InfiltrationAction" + infiltrationAction.Name, out guiElement))
     {
         guiElement = null;
     }
 }
Ejemplo n.º 2
0
    private void RefreshCostGroup(DepartmentOfScience.ConstructibleElement.State state)
    {
        bool flag = state != DepartmentOfScience.ConstructibleElement.State.Researched && state != DepartmentOfScience.ConstructibleElement.State.ResearchedButUnavailable;

        if (this.ShowCaptionCost && flag)
        {
            Amplitude.Unity.Gui.IGuiService service = Services.GetService <global::IGuiService>();
            Diagnostics.Assert(service != null);
            DepartmentOfTheTreasury agency = this.empire.GetAgency <DepartmentOfTheTreasury>();
            Diagnostics.Assert(agency != null);
            string empty = string.Empty;
            int    num   = 0;
            PanelFeatureCost.ComputeCostAndTurn(service, this.TechnologyDefinition, agency, this.empire, out empty, out num);
            if (string.IsNullOrEmpty(empty))
            {
                this.CaptionCostGroup.Visible = false;
            }
            else
            {
                this.CostLabel.Text           = empty;
                this.CaptionCostGroup.Visible = true;
            }
        }
        else if (this.CaptionCostGroup != null)
        {
            this.CaptionCostGroup.Visible = false;
        }
    }
Ejemplo n.º 3
0
    public void SetupPortrait(Kaiju kaiju, Empire playerEmpire)
    {
        this.Kaiju = kaiju;
        if (this.Portrait != null)
        {
            IGuiPanelHelper guiPanelHelper = Services.GetService <global::IGuiService>().GuiPanelHelper;
            Diagnostics.Assert(guiPanelHelper != null, "Unable to access GuiPanelHelper");
            Texture2D image;
            if (guiPanelHelper.TryGetTextureFromIcon(this.KaijuGuiElement, global::GuiPanel.IconSize.Large, out image))
            {
                this.Portrait.Image = image;
            }
        }
        Amplitude.Unity.Gui.IGuiService service = Services.GetService <global::IGuiService>();
        Diagnostics.Assert(service != null);
        KaijuTameCost kaijuTameCost = KaijuCouncil.GetKaijuTameCost();

        this.CostGroup.Visible = this.Kaiju.IsWild();
        KaijuCouncil agency = this.Kaiju.KaijuEmpire.GetAgency <KaijuCouncil>();

        this.CostValue.Text = GuiFormater.FormatGui(kaijuTameCost.GetValue(playerEmpire), false, true, false, 0) + service.FormatSymbol(ELCPUtilities.UseELCPSymbiosisBuffs ? agency.ELCPResourceName : kaijuTameCost.ResourceName);
        if (this.Background != null)
        {
            this.Background.TintColor = this.Kaiju.Empire.Color;
        }
        this.AgeTransform.AgeTooltip.Content = AgeLocalizer.Instance.LocalizeString(KaijuTechPortrait.PortraitClickTooltip);
    }
Ejemplo n.º 4
0
    public void Bind(KaijuGarrison garrison, Amplitude.Unity.Gui.IGuiService guiService)
    {
        this.Unbind();
        this.KaijuGarrison = garrison;
        this.GuiService    = (guiService as global::IGuiService);
        IGameService service = Services.GetService <IGameService>();

        this.playerControllerRepository = service.Game.Services.GetService <IPlayerControllerRepositoryService>();
        Unit unit2 = (from unit in this.KaijuGarrison.Units
                      where unit.UnitDesign.Tags.Contains(Kaiju.MonsterUnitTag)
                      select unit).First <Unit>();

        if (unit2 != null)
        {
            this.KaijuGuiUnit = new GuiUnit(unit2, null);
        }
        IGuiPanelHelper guiPanelHelper = Services.GetService <global::IGuiService>().GuiPanelHelper;

        Diagnostics.Assert(guiPanelHelper != null, "Unable to access GuiPanelHelper");
        Texture2D image = null;

        if (guiPanelHelper.TryGetTextureFromIcon(this.KaijuGuiElement, global::GuiPanel.IconSize.Small, out image))
        {
            this.KaijuIcon.Image = image;
        }
    }
Ejemplo n.º 5
0
 public void Initialize(Amplitude.Unity.Gui.IGuiService guiService, IGuiSimulationParser simulationEffectParser)
 {
     this.guiService             = guiService;
     this.simulationEffectParser = simulationEffectParser;
     this.EffectMapper.Initialize(guiService, true);
     this.AgeTransform = base.GetComponent <AgeTransform>();
 }
Ejemplo n.º 6
0
    private IEnumerator LoadSceneAsync(string levelName)
    {
        if (this.loadLevelAsyncOperation != null)
        {
            yield break;
        }
        Amplitude.Unity.Gui.IGuiService guiService = Services.GetService <Amplitude.Unity.Gui.IGuiService>();
        LoadingScreen loadingScreen = guiService.GetGuiPanel <LoadingScreen>();

        if (loadingScreen != null)
        {
            object dontDisplayAnyLoadingTip = new LoadingScreen.DontDisplayAnyLoadingTip();
            loadingScreen.Show(new object[]
            {
                dontDisplayAnyLoadingTip
            });
        }
        Diagnostics.Log("Loading the outgame view...");
        Diagnostics.Progress.SetProgress(1f, "%GameClientStateLoadingOutgameView");
        this.loadLevelAsyncOperation = SceneManager.LoadSceneAsync(levelName, LoadSceneMode.Additive);
        while (!this.loadLevelAsyncOperation.isDone)
        {
            yield return(null);
        }
        this.SceneObject = GameObject.Find("[OutGameView_Layout]");
        if (this.SceneObject == null)
        {
            Diagnostics.LogError("Cannot locate the root object '{0}' after loading the scene '{1}'.", new object[]
            {
                "[OutGameView_Layout]",
                levelName
            });
        }
        else
        {
            GameObject sceneObject = this.SceneObject;
            sceneObject.name += "(scene: additive, async)";
            this.SceneObject.transform.parent        = base.transform;
            this.SceneObject.transform.localPosition = Vector3.zero;
            this.SceneObject.transform.localRotation = Quaternion.identity;
            this.SceneObject.SetActive(true);
        }
        this.loadLevelAsyncOperation = null;
        Resources.UnloadUnusedAssets();
        if (Amplitude.Unity.Framework.Application.Bootstrapper != null)
        {
            Amplitude.Unity.Framework.Application.Bootstrapper.gameObject.SetActive(false);
        }
        guiService.Hide(typeof(LoadingScreen));
        if (this.Parameters.Length == 1)
        {
            Type typeOfPanelToShow = this.Parameters[0] as Type;
            Diagnostics.Assert(typeOfPanelToShow != null);
            guiService.Show(typeOfPanelToShow, new object[0]);
        }
        Amplitude.Unity.Audio.IAudioLayeredMusicService musicService = Services.GetService <Amplitude.Unity.Audio.IAudioLayeredMusicService>();
        musicService.PlayLayeredMusic("OutGameMusic", OutGameView.OutGameMusicName, 1);
        yield break;
    }
Ejemplo n.º 7
0
 public void Bind(TerraformDevice device, Amplitude.Unity.Gui.IGuiService guiService)
 {
     if (this.Device != null && this.Device != device)
     {
         this.Unbind();
     }
     this.Device = device;
 }
 public void RefreshContent()
 {
     Amplitude.Unity.Gui.IGuiService service = Services.GetService <global::IGuiService>();
     if (this.ArePlayersReady && this.Session.SessionMode != SessionMode.Single)
     {
         this.ReadyImage.AgeTransform.Visible = true;
     }
     else
     {
         this.ReadyImage.AgeTransform.Visible = false;
     }
     if (this.MajorEmpire.IsEliminated && !this.MajorEmpire.IsSpectator)
     {
         this.AgeTransform.GetComponent <AgePrimitiveImage>().Image = AgeManager.Instance.FindDynamicTexture("eliminatedLogoSmall", false);
     }
     else if (this.IsInEncounter)
     {
         this.AgeTransform.GetComponent <AgePrimitiveImage>().Image = AgeManager.Instance.FindDynamicTexture("encounterLogoSmall", false);
     }
     else if (!this.IsKnownByActivePlayer && !this.MajorEmpire.IsSpectator)
     {
         this.AgeTransform.GetComponent <AgePrimitiveImage>().Image = AgeManager.Instance.FindDynamicTexture("majorFactionRandomLogoSmall", false);
     }
     else
     {
         this.LogoImage.Image = this.GuiFaction.GetImageTexture(global::GuiPanel.IconSize.LogoSmall, false);
     }
     if (this.IsKnownByActivePlayer)
     {
         this.AgeControlButton.OnMiddleClickMethod = "OnRightClick";
         this.AgeControlButton.OnRightClickMethod  = "OnRightClick";
         this.AgeControlButton.OnMiddleClickObject = service.GetGuiPanel <EndTurnPanel>().gameObject;
         this.AgeControlButton.OnRightClickObject  = service.GetGuiPanel <EndTurnPanel>().gameObject;
         this.AgeTransform.AgeTooltip.Content      = this.MajorEmpire.LocalizedName + " - " + this.MajorEmpire.Faction.LocalizedName;
         if (!this.MajorEmpire.IsControlledByAI && this.MajorEmpire != this.ActivePlayerEmpire)
         {
             AgeTooltip ageTooltip = this.AgeTransform.AgeTooltip;
             ageTooltip.Content = ageTooltip.Content + "\n \n" + AgeLocalizer.Instance.LocalizeString("%ClickToWhisperTooltipContent");
             this.AgeControlButton.OnActivateMethod = "OnWhisperToEmpireCB";
             this.AgeControlButton.OnActivateObject = service.GetGuiPanel <InGameConsolePanel>().gameObject;
             this.AgeControlButton.OnActivateData   = this.MajorEmpire.LocalizedName;
             return;
         }
     }
     else
     {
         GuiElement guiElement;
         if (!service.GuiPanelHelper.TryGetGuiElement(DiplomaticRelationState.Names.Unknown, out guiElement))
         {
             this.AgeTransform.AgeTooltip.Content = "Missing GuiElement " + DiplomaticRelationState.Names.Unknown;
             return;
         }
         this.AgeTransform.AgeTooltip.Content   = guiElement.Title;
         this.AgeControlButton.OnActivateMethod = string.Empty;
         this.AgeControlButton.OnActivateObject = null;
         this.AgeControlButton.OnActivateData   = string.Empty;
     }
 }
Ejemplo n.º 9
0
 public override void Reactivate(params object[] parameters)
 {
     base.Reactivate(parameters);
     if (this.loadLevelAsyncOperation == null)
     {
         Amplitude.Unity.Gui.IGuiService service = Services.GetService <Amplitude.Unity.Gui.IGuiService>();
         service.Hide(typeof(LoadingScreen));
     }
 }
    public static void ComputeInfiltrationActionSubCategoryTexture(Amplitude.Unity.Gui.IGuiService guiService, InfiltrationAction infiltrationAction, out Texture2D subCategoryTexture)
    {
        GuiElement guiElement;

        if (!string.IsNullOrEmpty(infiltrationAction.SubCategory) && guiService.GuiPanelHelper.TryGetGuiElement("InfiltrationActionSubCategory" + infiltrationAction.SubCategory, out guiElement) && guiService.GuiPanelHelper.TryGetTextureFromIcon(guiElement, global::GuiPanel.IconSize.Small, out subCategoryTexture))
        {
            return;
        }
        subCategoryTexture = AgeManager.Instance.FindDynamicTexture("InfiltrationActionSubCategoryUnknown", false);
    }
Ejemplo n.º 11
0
 public static void ComputeCostAndTurn(Amplitude.Unity.Gui.IGuiService guiService, ReadOnlyCollection <Construction> constructibles, DepartmentOfTheTreasury departmentOfTheTreasury, SimulationObjectWrapper context, out string costString, out int turn)
 {
     PanelFeatureCost.costByResource.Clear();
     for (int i = 0; i < constructibles.Count; i++)
     {
         ConstructibleElement constructibleElement = constructibles[i].ConstructibleElement;
         if (constructibleElement.Costs != null)
         {
             if (constructibleElement is TechnologyDefinition && context.SimulationObject.Tags.Contains(FactionTrait.FactionTraitReplicants1) && (constructibleElement as TechnologyDefinition).TechnologyFlags != DepartmentOfScience.ConstructibleElement.TechnologyFlag.OrbUnlock && (constructibleElement as TechnologyDefinition).TechnologyFlags != DepartmentOfScience.ConstructibleElement.TechnologyFlag.KaijuUnlock)
             {
                 costString = string.Empty;
                 turn       = -1;
                 global::Empire empire = context as global::Empire;
                 if (empire == null)
                 {
                     Diagnostics.LogError("Empire is null.");
                     return;
                 }
                 DepartmentOfScience agency = empire.GetAgency <DepartmentOfScience>();
                 if (agency == null)
                 {
                     Diagnostics.LogError("Department of science is null");
                     return;
                 }
                 float buyOutTechnologyCost = agency.GetBuyOutTechnologyCost(constructibleElement);
                 if (buyOutTechnologyCost != 3.40282347E+38f)
                 {
                     costString = GuiFormater.FormatInstantCost(empire, buyOutTechnologyCost, DepartmentOfTheTreasury.Resources.EmpireMoney, true, 0);
                     return;
                 }
                 costString = "-";
                 return;
             }
             else
             {
                 for (int j = 0; j < constructibleElement.Costs.Length; j++)
                 {
                     if (constructibleElement.Costs[j] is PopulationConstructionCost)
                     {
                         PopulationConstructionCost populationConstructionCost = constructibleElement.Costs[j] as PopulationConstructionCost;
                         PanelFeatureCost.AppendCost(SimulationProperties.Population, populationConstructionCost.PopulationValue, true);
                     }
                     else
                     {
                         float productionCostWithBonus = DepartmentOfTheTreasury.GetProductionCostWithBonus(context, constructibleElement, constructibleElement.Costs[j], true);
                         PanelFeatureCost.AppendCost(constructibleElement.Costs[j].ResourceName, productionCostWithBonus, constructibleElement.Costs[j].Instant || constructibleElement.Costs[j].InstantOnCompletion);
                     }
                 }
             }
         }
     }
     PanelFeatureCost.GetCostAndTurn(guiService, departmentOfTheTreasury, context, out costString, out turn);
 }
Ejemplo n.º 12
0
    public static void FormatVersionAndModulePlaylist(AgeControlButton buttonLastPlaylist, AgePrimitiveLabel currentModulePlaylistLabel, AgePrimitiveLabel versionLabel)
    {
        if (currentModulePlaylistLabel != null)
        {
            currentModulePlaylistLabel.Text = "%ModDefaultTitle";
            currentModulePlaylistLabel.GetComponentInParent <AgeTooltip>().Content = string.Empty;
        }
        if (buttonLastPlaylist != null)
        {
            buttonLastPlaylist.AgeTransform.Enable = false;
        }
        if (versionLabel != null)
        {
            versionLabel.Text = Amplitude.Unity.Framework.Application.Name.ToString() + " " + Amplitude.Unity.Framework.Application.Version.ToString();
            string a;
            if (global::Application.ResolveChineseLanguage(out a))
            {
                if (a == "schinese")
                {
                    versionLabel.Text = AgeLocalizer.Instance.LocalizeString("%SChineseApplicationName") + " " + Amplitude.Unity.Framework.Application.Version.ToString();
                }
                else if (a == "tchinese")
                {
                    versionLabel.Text = AgeLocalizer.Instance.LocalizeString("%TChineseApplicationName") + " " + Amplitude.Unity.Framework.Application.Version.ToString();
                }
            }
            versionLabel.AgeTransform.AgeTooltip.Content = string.Empty;
        }
        Amplitude.Unity.Gui.IGuiService service = Services.GetService <Amplitude.Unity.Gui.IGuiService>();
        IRuntimeService service2       = Services.GetService <IRuntimeService>();
        ModulePlaylist  modulePlaylist = Services.GetService <IRuntimeModulePlaylistService>().CurrentModulePlaylist;

        if (modulePlaylist != null && modulePlaylist.Name == "VanillaModulePlaylist")
        {
            modulePlaylist = null;
        }
        if (modulePlaylist != null && modulePlaylist.Configuration.Length == 1 && modulePlaylist.Configuration[0].ModuleName == service2.VanillaModuleName)
        {
            modulePlaylist = null;
        }
        if (modulePlaylist == null)
        {
            string empty  = string.Empty;
            string empty2 = string.Empty;
            if (Amplitude.Unity.Framework.Application.Registry.TryGetValue(global::Application.Registers.LastModulePlaylistActivated, out empty) && Amplitude.Unity.Framework.Application.Registry.TryGetValue(global::Application.Registers.LastModulePlaylistActivatedUrl, out empty2) && empty != "VanillaModulePlaylist")
            {
                if (buttonLastPlaylist != null)
                {
                    buttonLastPlaylist.AgeTransform.Enable = true;
                }
                if (currentModulePlaylistLabel != null)
                {
                    GuiElement guiElement;
                    if (service.GuiPanelHelper.TryGetGuiElement(empty, out guiElement))
                    {
                        currentModulePlaylistLabel.Text = AgeLocalizer.Instance.LocalizeString("%OutgameLastPlaylistTitle").Replace("$PlaylistName", AgeLocalizer.Instance.LocalizeString(guiElement.Title));
                    }
                    else
                    {
                        currentModulePlaylistLabel.Text = AgeLocalizer.Instance.LocalizeString("%OutgameLastPlaylistTitle").Replace("$PlaylistName", empty);
                    }
                    ModulePlaylist modulePlaylist2 = new ModulePlaylist(empty, string.Empty, null, ModulePlaylist.ParseConfigurationUrl(empty2));
                    modulePlaylist2.RepairPlaylistIfInvalid();
                    string newValue = string.Join("\n - ", MenuMainScreen.GetPlaylistModuleTitles(modulePlaylist2));
                    currentModulePlaylistLabel.GetComponentInParent <AgeTooltip>().Content = AgeLocalizer.Instance.LocalizeString("%OutgameLastPlaylistDescription").Replace("$ModuleNames", newValue);
                    return;
                }
            }
        }
        else if (service2 != null && service2.Runtime != null)
        {
            modulePlaylist.RepairPlaylistIfInvalid();
            string newValue2 = modulePlaylist.Name;
            if (modulePlaylist.IsAnonymous)
            {
                newValue2 = AgeLocalizer.Instance.LocalizeString("%AnonymousActiveModulePlaylist");
            }
            string content = string.Join("\n", MenuMainScreen.GetPlaylistModuleTitles(modulePlaylist));
            if (currentModulePlaylistLabel != null)
            {
                currentModulePlaylistLabel.Text = AgeLocalizer.Instance.LocalizeString("%ModPlaylistActiveFormat").Replace("$Playlist", newValue2);
                currentModulePlaylistLabel.GetComponentInParent <AgeTooltip>().Content = content;
            }
            if (versionLabel != null)
            {
                string text = AgeLocalizer.Instance.LocalizeString("%GameMenuPlaylistFormat").Replace("$Playlist", newValue2);
                if (!string.IsNullOrEmpty(text))
                {
                    versionLabel.Text = versionLabel.Text + "\n" + text;
                    versionLabel.AgeTransform.AgeTooltip.Content = content;
                }
            }
        }
    }
    public override void Begin(params object[] parameters)
    {
        base.Begin(parameters);
        IMouseCursorService service = Services.GetService <IMouseCursorService>();

        if (service != null)
        {
            service.AddKey("Loading");
        }
        Diagnostics.Log("GameClientState_GameLaunched.");
        int             num      = 0;
        ISessionService service2 = Services.GetService <ISessionService>();

        Diagnostics.Assert(service2 != null);
        Diagnostics.Assert(service2.Session != null);
        Diagnostics.Assert(service2.Session.IsOpened);
        string text = service2.Session.SteamIDUser.ToString();

        Diagnostics.Assert(service2.Session.SteamIDUser.AccountID == Amplitude.Unity.Framework.Application.UserUniqueID);
        PlayerController playerController = new PlayerController(base.GameClient)
        {
            PlayerID = "player#" + service2.Session.SteamIDUser.AccountID
        };

        for (;;)
        {
            string x         = string.Format("Empire{0}", num);
            string lobbyData = service2.Session.GetLobbyData <string>(x, null);
            if (string.IsNullOrEmpty(lobbyData))
            {
                break;
            }
            if (lobbyData.Contains(text))
            {
                goto IL_113;
            }
            num++;
        }
        Diagnostics.LogError("Player doesn't belong here (SteamUserID: {0}).", new object[]
        {
            text
        });
        goto IL_12C;
IL_113:
        playerController.Empire = base.GameClient.Game.Empires[num];
IL_12C:
        int num2 = 0;

        for (;;)
        {
            string x2         = string.Format("Empire{0}", num2);
            string lobbyData2 = service2.Session.GetLobbyData <string>(x2, null);
            if (string.IsNullOrEmpty(lobbyData2))
            {
                break;
            }
            base.GameClient.Game.Empires[num2].IsControlledByAI = true;
            MajorEmpire majorEmpire = base.GameClient.Game.Empires[num2] as MajorEmpire;
            if (majorEmpire != null)
            {
                if (!lobbyData2.StartsWith("AI"))
                {
                    majorEmpire.IsControlledByAI = false;
                    if (Steamworks.SteamAPI.IsSteamRunning)
                    {
                        string[] array = lobbyData2.Split(Amplitude.String.Separators, StringSplitOptions.RemoveEmptyEntries);
                        for (int i = 0; i < array.Length; i++)
                        {
                            Steamworks.SteamID steamID = new Steamworks.SteamID(Convert.ToUInt64(array[i], 16));
                            if (!service2.Session.GetLobbyMemberData <bool>(steamID, "Ready", false) && base.GameClient.Session.SessionMode != SessionMode.Single)
                            {
                                majorEmpire.BindPlayer(new Player(majorEmpire)
                                {
                                    Type          = PlayerType.AI,
                                    Location      = ((base.GameClient.Session.GameServer == null) ? PlayerLocation.Remote : PlayerLocation.Local),
                                    LocalizedName = MajorEmpire.GenerateBasicAIName(majorEmpire.Index)
                                });
                            }
                            else
                            {
                                string text2 = Steamworks.SteamAPI.SteamFriends.GetFriendPersonaName(steamID);
                                if (text2 == null)
                                {
                                    text2 = AgeLocalizer.Instance.LocalizeString("%DefaultPlayerName");
                                }
                                majorEmpire.BindPlayer(new Player(majorEmpire)
                                {
                                    Type          = PlayerType.Human,
                                    Location      = ((!(steamID == base.GameClient.SteamIDUser)) ? PlayerLocation.Remote : PlayerLocation.Local),
                                    LocalizedName = text2,
                                    SteamID       = steamID
                                });
                            }
                        }
                    }
                    else
                    {
                        Diagnostics.LogWarning("Steam is not running, cannot get player's name, setting a default one.");
                        majorEmpire.BindPlayer(new Player(majorEmpire)
                        {
                            Type          = PlayerType.Human,
                            Location      = PlayerLocation.Local,
                            LocalizedName = AgeLocalizer.Instance.LocalizeString("%DefaultPlayerName"),
                            SteamID       = Steamworks.SteamID.Zero
                        });
                    }
                }
                else
                {
                    majorEmpire.BindPlayer(new Player(majorEmpire)
                    {
                        Type          = PlayerType.AI,
                        Location      = ((base.GameClient.Session.GameServer == null) ? PlayerLocation.Remote : PlayerLocation.Local),
                        LocalizedName = MajorEmpire.GenerateBasicAIName(majorEmpire.Index)
                    });
                }
            }
            num2++;
        }
        IPlayerControllerRepositoryService service3 = base.GameClient.Game.GetService <IPlayerControllerRepositoryService>();

        if (service3 != null)
        {
            for (int j = 0; j < base.GameClient.Game.Empires.Length; j++)
            {
                PlayerController playerController2 = new PlayerController(base.GameClient)
                {
                    Empire   = base.GameClient.Game.Empires[j],
                    PlayerID = base.GameClient.Game.Empires[j].PlayerID
                };
                service3.Register(playerController2);
                base.GameClient.Game.Empires[j].PlayerController         = playerController2;
                base.GameClient.Game.Empires[j].PlayerControllers.Client = playerController2;
            }
        }
        if (service3 != null)
        {
            service3.Register(playerController);
            service3.SetActivePlayerController(playerController);
        }
        Ticket.ResetCounter(0UL);
        Amplitude.Unity.View.IViewService service4 = Services.GetService <Amplitude.Unity.View.IViewService>();
        if (service4 != null)
        {
            WorldView worldView = (WorldView)service4.FindByType(typeof(WorldView));
            if (worldView != null)
            {
                worldView.WorldViewTechniqueChange += this.WorldView_WorldViewTechniqueChange;
            }
            service4.PostViewChange(typeof(WorldView), new object[0]);
        }
        Amplitude.Unity.Gui.IGuiService service5 = Services.GetService <Amplitude.Unity.Gui.IGuiService>();
        Diagnostics.Assert(service5 != null);
        ConsolePanel guiPanel = service5.GetGuiPanel <ConsolePanel>();

        Diagnostics.Assert(guiPanel != null);
        guiPanel.Load();
        guiPanel.Hide(false);
    }
Ejemplo n.º 14
0
    public static void GetCostAndTurn(Amplitude.Unity.Gui.IGuiService guiService, DepartmentOfTheTreasury departmentOfTheTreasury, SimulationObjectWrapper context, out string costString, out int turn)
    {
        turn = 0;
        StringBuilder stringBuilder = new StringBuilder();

        if (PanelFeatureCost.costByResource.Count > 0)
        {
            bool flag = false;
            IDatabase <ResourceDefinition> database = Databases.GetDatabase <ResourceDefinition>(false);
            foreach (KeyValuePair <StaticString, PanelFeatureCost.CostResume> keyValuePair in PanelFeatureCost.costByResource)
            {
                if (keyValuePair.Key == SimulationProperties.Population)
                {
                    stringBuilder.Append(GuiFormater.FormatGui(keyValuePair.Value.Cost, false, true, false, 1));
                    stringBuilder.Append(guiService.FormatSymbol(keyValuePair.Key));
                }
                else if (keyValuePair.Key == DepartmentOfTheTreasury.Resources.FreeBorough)
                {
                    stringBuilder.Append(GuiFormater.FormatGui(keyValuePair.Value.Cost, false, true, false, 1));
                    stringBuilder.Append(guiService.FormatSymbol(keyValuePair.Key));
                    float num;
                    if (!departmentOfTheTreasury.TryGetResourceStockValue(context.SimulationObject, DepartmentOfTheTreasury.Resources.QueuedFreeBorough, out num, true))
                    {
                        Diagnostics.Log("Can't get resource stock value {0} on simulation object {1}.", new object[]
                        {
                            DepartmentOfTheTreasury.Resources.QueuedFreeBorough,
                            context.SimulationObject.Name
                        });
                    }
                    else
                    {
                        stringBuilder.Append(string.Format(AgeLocalizer.Instance.LocalizeString("%CityFreeBoroughsLeft"), num));
                    }
                }
                else
                {
                    float              cost = keyValuePair.Value.Cost;
                    StaticString       key  = keyValuePair.Key;
                    ResourceDefinition resourceDefinition;
                    if (!database.TryGetValue(key, out resourceDefinition))
                    {
                        Diagnostics.LogError("Invalid resource name. The resource {0} does not exist in the resource database.", new object[]
                        {
                            key
                        });
                    }
                    else
                    {
                        string value = guiService.FormatSymbol(resourceDefinition.GetName(departmentOfTheTreasury.Empire));
                        if (!string.IsNullOrEmpty(value))
                        {
                            global::Empire empire = null;
                            if (context is City)
                            {
                                empire = (context as City).Empire;
                            }
                            else if (context is global::Empire)
                            {
                                empire = (context as global::Empire);
                            }
                            if (empire.SimulationObject.Tags.Contains(FactionTrait.FactionTraitMimics2) && key == DepartmentOfTheTreasury.Resources.Production)
                            {
                                ResourceDefinition resourceDefinition2;
                                if (!database.TryGetValue(SimulationProperties.CityGrowth, out resourceDefinition2))
                                {
                                    Diagnostics.LogError("Invalid resource name. The resource {0} does not exist in the resource database.", new object[]
                                    {
                                        key
                                    });
                                    continue;
                                }
                                value = guiService.FormatSymbol(resourceDefinition2.GetName(departmentOfTheTreasury.Empire));
                                if (string.IsNullOrEmpty(value))
                                {
                                    continue;
                                }
                            }
                            float num2;
                            if (!departmentOfTheTreasury.TryGetResourceStockValue(context.SimulationObject, key, out num2, true))
                            {
                                num2 = 0f;
                            }
                            if (keyValuePair.Value.Instant && num2 < cost)
                            {
                                AgeUtils.ColorToHexaKey(Color.red, ref stringBuilder, false);
                                flag = true;
                            }
                            stringBuilder.Append(GuiFormater.FormatGui(cost, false, true, false, 1));
                            stringBuilder.Append(value);
                            if (flag)
                            {
                                stringBuilder.Append("#REVERT#");
                                flag = false;
                            }
                            if (!keyValuePair.Value.Instant)
                            {
                                float num3;
                                if (!departmentOfTheTreasury.TryGetNetResourceValue(context.SimulationObject, key, out num3, true))
                                {
                                    num3 = 0f;
                                }
                                if (cost > num2)
                                {
                                    if (num3 <= 0f)
                                    {
                                        turn = int.MaxValue;
                                    }
                                    else
                                    {
                                        int num4 = Mathf.CeilToInt((cost - num2) / num3);
                                        if (num4 > turn)
                                        {
                                            turn = num4;
                                        }
                                    }
                                }
                            }
                            stringBuilder.Append(" ");
                        }
                    }
                }
            }
        }
        costString = stringBuilder.ToString();
        if (string.IsNullOrEmpty(costString))
        {
            costString = "-";
        }
    }
Ejemplo n.º 15
0
    public override void Focus(bool focused)
    {
        base.Focus(focused);
        ICameraService service = Services.GetService <ICameraService>();

        if (service != null)
        {
            service.Camera.gameObject.SetActive(!focused);
        }
        if (this.SceneObject != null)
        {
            this.SceneObject.SetActive(focused);
        }
        Amplitude.Unity.Gui.IGuiService service2 = Services.GetService <Amplitude.Unity.Gui.IGuiService>();
        if (this.Parameters != null && this.Parameters.Length > 0)
        {
            string text = this.Parameters[0] as string;
            if (!string.IsNullOrEmpty(text))
            {
                string text2 = text;
                if (text2 != null)
                {
                    if (OutGameView.< > f__switch$map20 == null)
                    {
                        OutGameView.< > f__switch$map20 = new Dictionary <string, int>(1)
                        {
                            {
                                "GameEnded",
                                0
                            }
                        };
                    }
                    int num;
                    if (OutGameView.< > f__switch$map20.TryGetValue(text2, out num))
                    {
                        if (num == 0)
                        {
                            Diagnostics.Assert(this.Parameters.Length == 2);
                            Diagnostics.Assert(this.Parameters[1] is EmpireInfo[]);
                            service2.GetGuiPanel <MenuScoreScreen>().Show(new object[]
                            {
                                this.Parameters[1]
                            });
                            return;
                        }
                    }
                }
            }
        }
        if (service2 != null)
        {
            if (focused)
            {
                service2.Show("01-MenuMainScreen", new object[0]);
            }
            else
            {
                service2.Hide("01-MenuMainScreen");
            }
        }
    }
    public void RefreshActionAvailability(DepartmentOfTheTreasury departmentOfTheTreasury, int infiltrationLevel, InterpreterContext interpreterContext, Amplitude.Unity.Gui.IGuiService guiService)
    {
        this.CurrentAction = this.InfiltrationActions.FirstOrDefault((InfiltrationAction infiltrationAction) => infiltrationAction.Level == infiltrationLevel);
        if (this.CurrentAction == null)
        {
            this.CurrentAction = (from infiltrationAction in this.InfiltrationActions
                                  where infiltrationAction.Level < infiltrationLevel
                                  select infiltrationAction).LastOrDefault <InfiltrationAction>();
            if (this.CurrentAction == null)
            {
                this.CurrentAction = (from infiltrationAction in this.InfiltrationActions
                                      where infiltrationAction.Level > infiltrationLevel
                                      select infiltrationAction).FirstOrDefault <InfiltrationAction>();
            }
        }
        this.FailuresFlags.Clear();
        if (interpreterContext != null)
        {
            this.IsValid = this.CurrentAction.CanExecute(interpreterContext, ref this.failuresFlags, new object[0]);
            if (!this.IsValid)
            {
                this.IsValid = !this.failuresFlags.Contains(ConstructionFlags.Discard);
            }
            this.IsValid &= (this.CurrentAction.Level <= infiltrationLevel);
        }
        else
        {
            this.failuresFlags.Add(InfiltrationAction.NoCanDoWithoutInfiltratedSpy);
            this.IsValid = false;
        }
        GuiInfiltrationActionGroup.ComputeInfiltrationActionGuiElement(guiService, this.CurrentAction, out this.actionGuiElement);
        GuiInfiltrationActionGroup.ComputeInfiltrationActionSubCategoryTexture(guiService, this.CurrentAction, out this.subCategoryTexture);
        this.InfiltrationActionCostString.Clear();
        List <string> list = new List <string>();
        int           i    = 0;

        while (i < this.InfiltrationActions.Count)
        {
            list.Clear();
            if (interpreterContext == null || departmentOfTheTreasury == null)
            {
                goto IL_228;
            }
            this.InfiltrationActions[i].ComputeConstructionCost(interpreterContext);
            if (InfiltrationAction.Context.ConstructionCosts == null)
            {
                goto IL_228;
            }
            for (int j = 0; j < InfiltrationAction.Context.ConstructionCosts.Length; j++)
            {
                ConstructionCost constructionCost = InfiltrationAction.Context.ConstructionCosts[j];
                string           item             = ((!departmentOfTheTreasury.CanAfford(constructionCost.Value, constructionCost.ResourceName)) ? "#DF1010#" : string.Empty) + string.Format("{0}{1}", GuiFormater.FormatGui(constructionCost.Value, false, true, false, 1), guiService.FormatSymbol(constructionCost.ResourceName));
                list.Add(item);
            }
            this.InfiltrationActionCostString.Add(string.Join(" ", list.ToArray()));
IL_238:
            i++;
            continue;
IL_228:
            this.InfiltrationActionCostString.Add("-");
            goto IL_238;
        }
    }
 public override string FormatDescription(string baseFormat, Amplitude.Unity.Gui.IGuiService guiService)
 {
     Diagnostics.Assert(this.EnemyGuiGarrisons.Count > 0);
     return(string.Format(AgeLocalizer.Instance.LocalizeString(baseFormat), this.EnemyGuiGarrisons[0].GetLocalizedNameAndFaction(this.playerEmpire, true)));
 }