public void StartClient( string host, int port, int initialServerLatency, PlayerSetupData playerSetupData) { Debug.Log($"Connecting to host {host}:{port}..."); this.playerSetupData = playerSetupData; this.initialServerLatency = initialServerLatency; netChannel.ConnectToServer(host, port); LoadGameScene(); }
public async Task StartGameAsListenServer() { Debug.Log("Starting game as a listen server."); await serverLogicController.StartServer(DEFAULT_HOST, DEFAULT_PORT, false); // Fake player data for now. var playerSetupData = new PlayerSetupData { Name = "Player", }; clientLogicController.StartClient("localhost", DEFAULT_PORT, 0, playerSetupData); }
public void StartGameAsClient(Hotel.GameServer serverToJoin, int initialLatency) { Debug.Log($"Joining server {serverToJoin.host}:{serverToJoin.port}..."); serverLogicController.gameObject.SetActive(false); // Fake player data for now. var playerSetupData = new PlayerSetupData { Name = "Player", }; clientLogicController.StartClient( serverToJoin.host, serverToJoin.port, initialLatency, playerSetupData); }
private void LoadGame() { foreach (JoinPanel jp in joinPanels) { if (jp.IsJoined) { PlayerSetupData psd = new PlayerSetupData(); psd.inputType = jp.InputBase; playerSetupData.Add(psd); } } MenuManager.Instance.LoadGame(); }
public void FromBytes(byte[] data, ref int offset) { int id = (int)data[offset++]; int nameLength = (int)data[offset++]; string name = Encoding.UTF8.GetString(data, offset, nameLength); offset += nameLength; int spawnPointID = (int)data[offset++]; PlayerSetupData setup = new PlayerSetupData(data, ref offset); Player = new RoomPlayerInfo(id, name, spawnPointID, setup.Setup); }