feat: add player emulator
This commit is contained in:
parent
b22d587f8a
commit
6911ccbb56
@ -38,7 +38,6 @@ RenderSettings:
|
||||
m_ReflectionIntensity: 1
|
||||
m_CustomReflection: {fileID: 0}
|
||||
m_Sun: {fileID: 705507994}
|
||||
m_IndirectSpecularColor: {r: 0.18028326, g: 0.22571333, b: 0.30692202, a: 1}
|
||||
m_UseRadianceAmbientProbe: 0
|
||||
--- !u!157 &3
|
||||
LightmapSettings:
|
||||
@ -1229,7 +1228,7 @@ RectTransform:
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
m_AnchorMin: {x: 1, y: 1}
|
||||
m_AnchorMax: {x: 1, y: 1}
|
||||
m_AnchoredPosition: {x: 49.999756, y: 50}
|
||||
m_AnchoredPosition: {x: 49.999756, y: 50.000122}
|
||||
m_SizeDelta: {x: 500, y: 500}
|
||||
m_Pivot: {x: 1, y: 1}
|
||||
--- !u!114 &190388870
|
||||
@ -2308,6 +2307,7 @@ GameObject:
|
||||
- component: {fileID: 375256415}
|
||||
- component: {fileID: 375256416}
|
||||
- component: {fileID: 375256417}
|
||||
- component: {fileID: 375256418}
|
||||
m_Layer: 0
|
||||
m_Name: '[Managers]'
|
||||
m_TagString: Untagged
|
||||
@ -2433,6 +2433,18 @@ MonoBehaviour:
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
cameraManager: {fileID: 0}
|
||||
--- !u!114 &375256418
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 375256411}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: 6737cec7c8df64e7dbe8de750213a898, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
--- !u!1 &411140634
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
@ -5148,7 +5160,7 @@ RectTransform:
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
m_AnchorMin: {x: 0, y: 0}
|
||||
m_AnchorMax: {x: 1, y: 1}
|
||||
m_AnchoredPosition: {x: 0, y: -47}
|
||||
m_AnchoredPosition: {x: 0, y: -47.000122}
|
||||
m_SizeDelta: {x: -200, y: -200}
|
||||
m_Pivot: {x: 0.5, y: 0.5}
|
||||
--- !u!114 &987875883
|
||||
@ -10009,7 +10021,7 @@ RectTransform:
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
m_AnchorMin: {x: 0, y: 1}
|
||||
m_AnchorMax: {x: 0, y: 1}
|
||||
m_AnchoredPosition: {x: 450, y: 50}
|
||||
m_AnchoredPosition: {x: 450, y: 50.000122}
|
||||
m_SizeDelta: {x: 500, y: 500}
|
||||
m_Pivot: {x: 0, y: 1}
|
||||
--- !u!114 &1813019852
|
||||
|
60
Assets/Scripts/PlayersEmulator.cs
Normal file
60
Assets/Scripts/PlayersEmulator.cs
Normal file
@ -0,0 +1,60 @@
|
||||
using System;
|
||||
using Firebase.Database;
|
||||
using UnityEngine;
|
||||
|
||||
#if UNITY_EDITOR
|
||||
|
||||
/// <summary>
|
||||
/// Class used only in editor in order to be able to test without real players
|
||||
/// </summary>
|
||||
public class PlayersEmulator : MonoBehaviour
|
||||
{
|
||||
private DatabaseReference realtimeDB;
|
||||
private DatabaseReference myOnlineRoom;
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
FirebaseInitializer.Instance.onFirebaseReady += Initialize;
|
||||
}
|
||||
|
||||
private void Initialize()
|
||||
{
|
||||
FirebaseInitializer.Instance.onFirebaseReady -= Initialize;
|
||||
realtimeDB = FirebaseDatabase.DefaultInstance.RootReference;
|
||||
}
|
||||
|
||||
private void Update()
|
||||
{
|
||||
if(Input.GetKeyDown(KeyCode.N))
|
||||
CreateNewFakePlayer();
|
||||
|
||||
if(Input.GetKeyDown(KeyCode.S))
|
||||
StartGame();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Use the context menu to create a new fake player in this game.
|
||||
/// Use it after the room has been created
|
||||
/// </summary>
|
||||
[ContextMenu("Create New Fake Player")]
|
||||
private void CreateNewFakePlayer()
|
||||
{
|
||||
Player fakeP = new Player("fakePlayer", Guid.NewGuid().ToString(), DateTime.Now.ToOADate());
|
||||
string JSON = JsonUtility.ToJson(fakeP);
|
||||
|
||||
myOnlineRoom = realtimeDB.Child("rooms").Child(RoomManager.Instance.myRoom.code);
|
||||
myOnlineRoom.Child("players").Child(fakeP.id).SetRawJsonValueAsync(JSON);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Use the context menu to start the game from the Editor.
|
||||
/// Use it after the room has been created & at least 3 players have joined
|
||||
/// </summary>
|
||||
[ContextMenu("Start Game")]
|
||||
private void StartGame()
|
||||
{
|
||||
myOnlineRoom.Child("currentState").SetValueAsync((int)GameState.Explanation);
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
11
Assets/Scripts/PlayersEmulator.cs.meta
Normal file
11
Assets/Scripts/PlayersEmulator.cs.meta
Normal file
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 6737cec7c8df64e7dbe8de750213a898
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
Loading…
Reference in New Issue
Block a user