-
Notifications
You must be signed in to change notification settings - Fork 2
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
4 changed files
with
58 additions
and
83 deletions.
There are no files selected for viewing
51 changes: 37 additions & 14 deletions
51
Assets/PlayroomKit/modules/MockMode/BrowserMode/BrowserMockPlayerService.cs
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,61 +1,84 @@ | ||
| ||
using System; | ||
using System; | ||
using UBB; | ||
using UnityEngine; | ||
|
||
namespace Playroom | ||
{ | ||
public class BrowserMockPlayerService : PlayroomKit.Player.IPlayerBase | ||
{ | ||
|
||
#region State | ||
private readonly UnityBrowserBridge _ubb; | ||
private string _id; | ||
|
||
public BrowserMockPlayerService(UnityBrowserBridge ubb, string id) | ||
{ | ||
_ubb = ubb; | ||
_id = id; | ||
} | ||
|
||
#region State | ||
|
||
public void SetState(string key, int value, bool reliable = false) | ||
{ | ||
throw new NotImplementedException(); | ||
_ubb.CallJs("SetPlayerStateByPlayerId", null, null, false, _id, key, value.ToString(), | ||
reliable.ToString().ToLower()); | ||
} | ||
|
||
public void SetState(string key, float value, bool reliable = false) | ||
{ | ||
throw new NotImplementedException(); | ||
_ubb.CallJs("SetPlayerStateByPlayerId", null, null, false, _id, key, value.ToString(), | ||
reliable.ToString().ToLower()); | ||
} | ||
|
||
public void SetState(string key, bool value, bool reliable = false) | ||
{ | ||
throw new NotImplementedException(); | ||
_ubb.CallJs("SetPlayerStateByPlayerId", null, null, false, _id, key, value.ToString(), | ||
reliable.ToString().ToLower()); | ||
} | ||
|
||
public void SetState(string key, string value, bool reliable = false) | ||
{ | ||
throw new NotImplementedException(); | ||
_ubb.CallJs("SetPlayerStateByPlayerId", null, null, false, _id, key, value.ToString(), | ||
reliable.ToString().ToLower()); | ||
} | ||
|
||
public void SetState(string key, object value, bool reliable = false) | ||
{ | ||
throw new NotImplementedException(); | ||
_ubb.CallJs("SetPlayerStateByPlayerId", null, null, false, _id, key, value.ToString(), | ||
reliable.ToString().ToLower()); | ||
} | ||
|
||
public T GetState<T>(string key) | ||
{ | ||
throw new NotImplementedException(); | ||
Debug.Log(key); | ||
return _ubb.CallJs<T>(key); | ||
} | ||
|
||
#endregion | ||
|
||
public PlayroomKit.Player.Profile GetProfile() | ||
{ | ||
throw new NotImplementedException(); | ||
string json = _ubb.CallJs<string>("GetProfile", null, null, false, _id); | ||
|
||
Debug.Log(json); | ||
|
||
var profileData = Helpers.ParseProfile(json); | ||
return profileData; | ||
} | ||
|
||
public Action OnQuit(Action<string> callback) | ||
{ | ||
throw new NotImplementedException(); | ||
Debug.LogWarning("OnQuit not supported yet in Browser Mode"); | ||
return default; | ||
} | ||
|
||
public void Kick(Action onKickCallBack = null) | ||
{ | ||
throw new NotImplementedException(); | ||
_ubb.CallJs("Kick", null, null, true, _id); | ||
} | ||
|
||
public void WaitForState(string stateKey, Action<string> onStateSetCallback = null) | ||
{ | ||
throw new NotImplementedException(); | ||
_ubb.CallJs("WaitForPlayerState", null, null, true, _id, stateKey); | ||
} | ||
} | ||
} |
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
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
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