Beispiel #1
0
    public void OnPlayerWelcome(SocketIOEvent e)
    {
        Debug.Log($"welcomed, current player {(GetLocalPlayer() != null ? "set" : "null")}");

        if (GetLocalPlayer() != null)
        {
            return;
        }

        Assert.That(e.HasPayload());
        Assert.That(e.HasField("x"));
        Assert.That(e.HasField("y"));

        var x = e.GetFloat("x").Value;
        var y = e.GetFloat("y").Value;

        var position = new Vector3(x, 0.5F, y);

        this.localPlayer = CreatePlayer("local", position, Quaternion.identity, false);

        this.socket.EmitIfConnected(SOCKET_EVENTS.PlayerJoin, new JSONObject());
    }