Skip to content

Commit

Permalink
chore: testing scene for turnbased
Browse files Browse the repository at this point in the history
  • Loading branch information
momintlh committed Feb 4, 2025
1 parent 2816aef commit c5229ec
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 32 deletions.
File renamed without changes.
File renamed without changes.
47 changes: 15 additions & 32 deletions Assets/Scripts/GameManager.cs
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());
}
}

0 comments on commit c5229ec

Please sign in to comment.