Merge branch 'main' of https://github.com/LeGall29/GGJ2024
This commit is contained in:
commit
e876034c80
@ -3534,6 +3534,43 @@ RectTransform:
|
||||
m_AnchoredPosition: {x: 0, y: 0}
|
||||
m_SizeDelta: {x: 0, y: 0}
|
||||
m_Pivot: {x: 0, y: 0}
|
||||
--- !u!114 &1202782732
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 1202782726}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: 27a435387a7644784a6fc6ae538b68e5, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
currentPlayer:
|
||||
name:
|
||||
id:
|
||||
creationDate: 0
|
||||
explanationTime: 4
|
||||
roomCodeField: {fileID: 2023851070}
|
||||
roomError: {fileID: 991600093}
|
||||
playerNameField: {fileID: 1163479463}
|
||||
nameError: {fileID: 1224049646}
|
||||
submitNewPlayer: {fileID: 1158329299}
|
||||
listPlayersUI: {fileID: 1891690322}
|
||||
submitStartGame: {fileID: 638947073}
|
||||
counter: {fileID: 1383251891}
|
||||
HomeConnection: {fileID: 2027556831}
|
||||
WaitingRoom: {fileID: 1590939977}
|
||||
BeforeStart: {fileID: 563000513}
|
||||
TakePicture: {fileID: 1181392805}
|
||||
VotePicture: {fileID: 531335861}
|
||||
WaitingOtherPlayers: {fileID: 2095389711}
|
||||
EndGame: {fileID: 1850164816}
|
||||
myRoom:
|
||||
code:
|
||||
currentQuestion: 0
|
||||
creationDate: 0
|
||||
currentState: 0
|
||||
--- !u!1 &1224049644
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
@ -4097,7 +4134,7 @@ GameObject:
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
m_StaticEditorFlags: 0
|
||||
m_IsActive: 0
|
||||
m_IsActive: 1
|
||||
--- !u!224 &1383251890
|
||||
RectTransform:
|
||||
m_ObjectHideFlags: 0
|
||||
|
@ -9,10 +9,10 @@ public class Player
|
||||
{
|
||||
public string name;
|
||||
public string id;
|
||||
public float creationDate;
|
||||
public double creationDate;
|
||||
|
||||
[JsonConstructor]
|
||||
public Player(string _name, string _id, float _creationDate)
|
||||
public Player(string _name, string _id, double _creationDate)
|
||||
{
|
||||
name = _name;
|
||||
id = _id;
|
||||
@ -23,7 +23,7 @@ public Player(string _name, string _id, float _creationDate)
|
||||
public Player(string _name)
|
||||
{
|
||||
id = Guid.NewGuid().ToString();
|
||||
creationDate = Time.time;
|
||||
creationDate = DateTime.Now.ToOADate();
|
||||
SetName(_name);
|
||||
}
|
||||
|
||||
|
@ -6,6 +6,7 @@
|
||||
using Newtonsoft.Json;
|
||||
using TMPro;
|
||||
using UnityEngine;
|
||||
using static UnityEditor.Experimental.AssetDatabaseExperimental.AssetDatabaseCounters;
|
||||
|
||||
/// <summary>
|
||||
/// This is the game state manager on the phone side
|
||||
@ -30,6 +31,9 @@ public class GameManager : MonoBehaviour
|
||||
public TextMeshProUGUI listPlayersUI;
|
||||
public GameObject submitStartGame;
|
||||
|
||||
[Header("Explanation Component")]
|
||||
public TextMeshProUGUI counter;
|
||||
|
||||
[Header("Pages")]
|
||||
public GameObject HomeConnection;
|
||||
public GameObject WaitingRoom;
|
||||
@ -42,6 +46,7 @@ public class GameManager : MonoBehaviour
|
||||
private DatabaseReference realtimeDB;
|
||||
public Room myRoom;
|
||||
private DatabaseReference myOnlineRoom;
|
||||
private DateTime endOfExplanationDate = DateTime.MinValue;
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
@ -67,6 +72,20 @@ private void OnApplicationQuit()
|
||||
});
|
||||
}
|
||||
|
||||
private void Update()
|
||||
{
|
||||
if (myRoom.currentState == (int)GameState.Explanation && endOfExplanationDate != DateTime.MinValue )
|
||||
{
|
||||
TimeSpan duration = endOfExplanationDate - DateTime.Now;
|
||||
counter.text = ((int)duration.TotalSeconds).ToString("D1");
|
||||
|
||||
if (duration.TotalMilliseconds <= 0)
|
||||
{
|
||||
Debug.Log("It's time to make proposition !");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void Initialize()
|
||||
{
|
||||
@ -118,11 +137,11 @@ public void PlayerValidateNameAndServerRoom(string _name, string _code)
|
||||
else
|
||||
{
|
||||
myOnlineRoom = realtimeDB.Child("rooms").Child(_code);
|
||||
//subscribe to it
|
||||
myOnlineRoom.ValueChanged += OnRoomUpdate;
|
||||
//if room exists, join it
|
||||
JoinRoom(() =>
|
||||
{
|
||||
//then subscribe to it
|
||||
myOnlineRoom.ValueChanged += OnRoomUpdate;
|
||||
myRoom.currentState = (int)GameState.WaitingForOtherPlayersToJoin;
|
||||
players.Add(currentPlayer);
|
||||
|
||||
@ -270,8 +289,12 @@ public void DisplayEndScreen()
|
||||
private void OnRoomUpdate(object sender, ValueChangedEventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (e!= null)
|
||||
{
|
||||
myRoom = JsonConvert.DeserializeObject<Room>(e.Snapshot.GetRawJsonValue());
|
||||
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
@ -291,6 +314,9 @@ private void OnRoomUpdate(object sender, ValueChangedEventArgs e)
|
||||
}
|
||||
case (int)GameState.Explanation:
|
||||
{
|
||||
WaitingRoom.SetActive(false);
|
||||
BeforeStart.SetActive(true);
|
||||
endOfExplanationDate = DateTime.Now.AddSeconds(3);
|
||||
|
||||
break;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user