-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
15 additions
and
32 deletions.
There are no files selected for viewing
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,55 +1,38 @@ | ||
using System; | ||
using Playroom; | ||
using UnityEngine; | ||
|
||
public class GameManager : MonoBehaviour | ||
{ | ||
private PlayroomKit _kit; | ||
|
||
private void Start() | ||
private void Awake() | ||
{ | ||
_kit = new(); | ||
} | ||
|
||
private void Start() | ||
{ | ||
_kit.InsertCoin(new InitOptions() | ||
{ | ||
gameId = "[my game id]", | ||
maxPlayersPerRoom = 8, | ||
discord = true | ||
}, () => | ||
{ | ||
// same event multiple RPCs | ||
_kit.RpcRegister("A", A); | ||
_kit.RpcRegister("A", A2); | ||
|
||
// RPC Call From Another RPC | ||
_kit.RpcRegister("host", (data, sender) => | ||
{ | ||
Debug.Log("Host RPC CALLED"); | ||
_kit.RpcCall("client", 1, PlayroomKit.RpcMode.ALL); | ||
} | ||
); | ||
_kit.RpcRegister("client", (data, sender) => | ||
{ | ||
Debug.Log("client rpc called"); | ||
}); | ||
}); | ||
turnBased = true, | ||
maxPlayersPerRoom = 2, | ||
}, OnLaunchCallBack); | ||
} | ||
|
||
private void Update() | ||
private void OnLaunchCallBack() | ||
{ | ||
if (Input.GetMouseButtonDown(0)) | ||
_kit.RpcCall("A", 1, PlayroomKit.RpcMode.HOST); | ||
|
||
if (Input.GetMouseButtonDown(1)) | ||
_kit.RpcCall("host", 1, PlayroomKit.RpcMode.HOST); | ||
_kit.OnPlayerJoin(CreatePlayer); | ||
|
||
// _kit.get | ||
} | ||
|
||
private void A(string data, string sender) | ||
private void CreatePlayer(PlayroomKit.Player player) | ||
{ | ||
Debug.Log($"[Unity] A called"); | ||
Debug.Log($"{player.id} joined the room!"); | ||
} | ||
|
||
private void A2(string data, string sender) | ||
private void Update() | ||
{ | ||
Debug.LogWarning("[Unity] A2 data: " + data.ToString()); | ||
} | ||
} |