Browse Source

Setting up seed

master
JoshuaReason 5 years ago
parent
commit
f116295ffe
6 changed files with 35 additions and 3 deletions
  1. +1
    -1
      Assets/Scenes/ClientScene.unity
  2. +1
    -0
      Assets/Scipts/Multiplayer/Core/LoginProtocol.cs
  3. +25
    -0
      Assets/Scipts/Multiplayer/Core/PlayerProtocol.cs
  4. +3
    -0
      Assets/Scipts/Multiplayer/Server/LoginManager.cs
  5. +3
    -0
      Assets/Scipts/Multiplayer/Server/ServerManager.cs
  6. +2
    -2
      ProjectSettings/ProjectSettings.asset

+ 1
- 1
Assets/Scenes/ClientScene.unity View File

@ -146,7 +146,7 @@ MonoBehaviour:
Port: 4444 Port: 4444
ConnectOnStart: 0 ConnectOnStart: 0
LobbyScene: LobbyScene LobbyScene: LobbyScene
GameScene: TestScene
GameScene: MainScene
Name: The Black Burrito Name: The Black Burrito
IsConnected: 0 IsConnected: 0
ID: 0 ID: 0

+ 1
- 0
Assets/Scipts/Multiplayer/Core/LoginProtocol.cs View File

@ -10,5 +10,6 @@ namespace Multiplayer
public const short Name = 301; public const short Name = 301;
public const short EnterLobby = 302; public const short EnterLobby = 302;
public const short LobbyCount = 303; public const short LobbyCount = 303;
public const short Seed = 304;
} }
} }

+ 25
- 0
Assets/Scipts/Multiplayer/Core/PlayerProtocol.cs View File

@ -93,6 +93,31 @@ namespace Multiplayer
} }
public class longMsg : PlayerMsg
{
public long Long;
public longMsg() { }
public longMsg(byte PlayerID, long Long) : base(PlayerID)
{
this.Long = Long;
}
public override void Serialize(NetworkWriter writer)
{
base.Serialize(writer);
writer.Write(Long);
}
public override void Deserialize(NetworkReader reader)
{
base.Deserialize(reader);
Long = reader.ReadInt64();
}
}
public class StringMsg : PlayerMsg public class StringMsg : PlayerMsg
{ {

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

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

+ 3
- 0
Assets/Scipts/Multiplayer/Server/ServerManager.cs View File

@ -16,6 +16,7 @@ namespace Multiplayer
[SerializeField] [SerializeField]
private int Port = 4444; private int Port = 4444;
public long Seed;
public Dictionary<int, Player> AllPlayers; public Dictionary<int, Player> AllPlayers;
@ -49,6 +50,8 @@ namespace Multiplayer
loginManager = new LoginManager(this); loginManager = new LoginManager(this);
playerManager = new PlayerServerManager(this); playerManager = new PlayerServerManager(this);
Seed = System.DateTime.Now.Ticks;
Server.Listen(Port); Server.Listen(Port);
} }

+ 2
- 2
ProjectSettings/ProjectSettings.asset View File

@ -1,3 +1,3 @@
version https://git-lfs.github.com/spec/v1 version https://git-lfs.github.com/spec/v1
oid sha256:d31e33f772a9cd3cd56ae66a5b981bb456d1201adab8595fc0337bc8261d1cfc
size 17761
oid sha256:04c64ffa91d234bb532dee94ea9a205db3d37fe73723ed630fae3a154ed9266d
size 17790

Loading…
Cancel
Save