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;
     }
 }
Пример #2
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;
    }
Пример #3
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 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);
    }