예제 #1
0
 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();
 }
예제 #2
0
    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);
    }
예제 #3
0
    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);
    }
예제 #4
0
        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();
        }
예제 #5
0
    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);
    }