Add player profile system
This commit is contained in:
@@ -41,6 +41,7 @@ namespace XGame
|
||||
private MiniGameStageIsolation stageIsolation;
|
||||
private LobbyWorldController lobbyWorld;
|
||||
private WorldChatModule worldChat;
|
||||
private PlayerProfileModule playerProfile;
|
||||
private readonly List<GameInfoMsg> games = new List<GameInfoMsg>();
|
||||
private readonly List<NetMessage> pendingGameMessages = new List<NetMessage>();
|
||||
private readonly HashSet<int> canceledMatchRequestIds = new HashSet<int>();
|
||||
@@ -129,6 +130,7 @@ namespace XGame
|
||||
lobbyActive = false;
|
||||
lobbyWorld?.SendLeave();
|
||||
CloseWorldChat();
|
||||
ClosePlayerProfile();
|
||||
lobbyNet = null;
|
||||
socket?.close();
|
||||
socket = null;
|
||||
@@ -315,6 +317,8 @@ namespace XGame
|
||||
private void EnterLobby()
|
||||
{
|
||||
CloseLoginPanel();
|
||||
SyncPlayerProfile();
|
||||
EnsurePlayerProfileModule();
|
||||
OpenLobby();
|
||||
ConnectLobby();
|
||||
}
|
||||
@@ -886,6 +890,40 @@ namespace XGame
|
||||
}
|
||||
}
|
||||
|
||||
private void EnsurePlayerProfileModule()
|
||||
{
|
||||
if (playerProfile == null)
|
||||
{
|
||||
playerProfile = gameObject.GetComponent<PlayerProfileModule>();
|
||||
if (playerProfile == null)
|
||||
{
|
||||
playerProfile = gameObject.AddComponent<PlayerProfileModule>();
|
||||
}
|
||||
}
|
||||
if (!playerProfile.IsOpen)
|
||||
{
|
||||
XWCoroutine.StartCo(playerProfile.OpenAsync());
|
||||
}
|
||||
}
|
||||
|
||||
private void ClosePlayerProfile()
|
||||
{
|
||||
if (playerProfile != null)
|
||||
{
|
||||
playerProfile.Close();
|
||||
}
|
||||
}
|
||||
|
||||
private void SyncPlayerProfile()
|
||||
{
|
||||
int pid = GetLobbyPlayerId();
|
||||
PlayerProfileStore.SetSessionIdentity(
|
||||
GetLobbyPlayerName(),
|
||||
pid.ToString(CultureInfo.InvariantCulture),
|
||||
pid <= 0 ? 0 : pid % 8 + 1,
|
||||
PlayerRoleType.Adventurer);
|
||||
}
|
||||
|
||||
private static string GetLobbyPlayerName()
|
||||
{
|
||||
string account = XData.GetString(LoginAccountKey, string.Empty);
|
||||
|
||||
Reference in New Issue
Block a user