Browse Source

Made clientScene work

master
JoshuaReason 5 years ago
parent
commit
7ea03cf942
4 changed files with 63 additions and 1359 deletions
  1. +49
    -1355
      Assets/Scenes/MainScene.unity
  2. +3
    -3
      Assets/Scipts/HomeScreenManager.cs
  3. +10
    -0
      Assets/Scipts/Multiplayer/Client/ClientLoginManager.cs
  4. +1
    -1
      Assets/Scipts/Multiplayer/Server/LoginManager.cs

+ 49
- 1355
Assets/Scenes/MainScene.unity
File diff suppressed because it is too large
View File


+ 3
- 3
Assets/Scipts/HomeScreenManager.cs View File

@ -30,7 +30,7 @@ public class HomeScreenManager : MonoBehaviour {
bool Succeeded = int.TryParse(Port.text, out intVal);
if (Succeeded)
{
Destroy(ServerManager.Instance.gameObject);
//Destroy(ServerManager.Instance.gameObject);
ClientManager.Instance.StartClient(IP.text, intVal);
}
PlayerPrefs.SetString("IP", IP.text);
@ -54,13 +54,13 @@ public class HomeScreenManager : MonoBehaviour {
Server.SetActive(false);
}
IP.text = "127.0.0.1";
IP.text = IPGrabber.GetIP(ADDRESSFAM.IPv4);
PlayerPrefs.SetString("PORT", Port.text);
PlayerPrefs.SetString("NAME", Name.text);
PlayerPrefs.SetString("IP", IP.text);
Connect();
//Connect();
}
public void ChangeName()

+ 10
- 0
Assets/Scipts/Multiplayer/Client/ClientLoginManager.cs View File

@ -24,6 +24,7 @@ namespace Multiplayer
ClientManager.Client.RegisterHandler(LoginMsgID.QueryName, OnRecieveID);
ClientManager.Client.RegisterHandler(LoginMsgID.EnterLobby, StartLobby);
ClientManager.Client.RegisterHandler(PlayerMsgID.GameStart, StartGame);
ClientManager.Client.RegisterHandler(LoginMsgID.Seed, SetSeed);
}
private void OnConnected(NetworkMessage msg)
@ -65,6 +66,15 @@ namespace Multiplayer
{
UnityEngine.SceneManagement.SceneManager.LoadScene(ClientManager.GameScene);
}
private void SetSeed(NetworkMessage msg)
{
longMsg longMsg;
if (!Utility.ReadMessage<longMsg>(msg, out longMsg))
return;
Random.InitState((int)longMsg.Long);
}
}
}

+ 1
- 1
Assets/Scipts/Multiplayer/Server/LoginManager.cs View File

@ -73,7 +73,7 @@ namespace Multiplayer
{
foreach (Player player in ServerManager.AllPlayers.Values)
{
//player.Connection.Send(LoginMsgID.Seed, new longMsg(player.ID, ServerManager.Seed));
player.Connection.Send(LoginMsgID.Seed, new longMsg(player.ID, ServerManager.Seed));
player.Connection.Send(PlayerMsgID.GameStart, new PlayerMsg(player.ID));
}
}

Loading…
Cancel
Save