MB 5 years ago
parent
commit
630e7215ce
5 changed files with 76 additions and 1357 deletions
  1. +49
    -1355
      Assets/Scenes/MainScene.unity
  2. +8
    -1
      Assets/Scipts/HomeScreenManager.cs
  3. +10
    -0
      Assets/Scipts/Multiplayer/Client/ClientLoginManager.cs
  4. +1
    -1
      Assets/Scipts/Multiplayer/Server/LoginManager.cs
  5. +8
    -0
      Assets/Shaders.meta

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


+ 8
- 1
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);
@ -43,6 +43,7 @@ public class HomeScreenManager : MonoBehaviour {
{
Server.SetActive(true);
int intVal = 0;
bool Succeeded = int.TryParse(Port.text, out intVal);
if (Succeeded)
{
@ -52,8 +53,14 @@ public class HomeScreenManager : MonoBehaviour {
{
Server.SetActive(false);
}
IP.text = IPGrabber.GetIP(ADDRESSFAM.IPv4);
PlayerPrefs.SetString("PORT", Port.text);
PlayerPrefs.SetString("NAME", Name.text);
PlayerPrefs.SetString("IP", IP.text);
//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));
}
}

+ 8
- 0
Assets/Shaders.meta View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: f87a054963b01dc4c8aa2e3ffedcca21
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

Loading…
Cancel
Save