fix: phoneView change state
This commit is contained in:
parent
97860e4232
commit
b59ab36b7d
@ -924,7 +924,6 @@ MonoBehaviour:
|
|||||||
m_Script: {fileID: 11500000, guid: 3b41deef4ebd372d5a18eabdb00cfbb4, type: 3}
|
m_Script: {fileID: 11500000, guid: 3b41deef4ebd372d5a18eabdb00cfbb4, type: 3}
|
||||||
m_Name:
|
m_Name:
|
||||||
m_EditorClassIdentifier:
|
m_EditorClassIdentifier:
|
||||||
PicturePlayer: {fileID: 1316036595}
|
|
||||||
Canvas: {fileID: 1202782726}
|
Canvas: {fileID: 1202782726}
|
||||||
--- !u!1 &436596783
|
--- !u!1 &436596783
|
||||||
GameObject:
|
GameObject:
|
||||||
@ -3523,6 +3522,7 @@ MonoBehaviour:
|
|||||||
submitNewPlayer: {fileID: 1158329299}
|
submitNewPlayer: {fileID: 1158329299}
|
||||||
listPlayersUI: {fileID: 1891690322}
|
listPlayersUI: {fileID: 1891690322}
|
||||||
submitStartGame: {fileID: 638947073}
|
submitStartGame: {fileID: 638947073}
|
||||||
|
counter: {fileID: 1383251891}
|
||||||
HomeConnection: {fileID: 2027556831}
|
HomeConnection: {fileID: 2027556831}
|
||||||
WaitingRoom: {fileID: 1590939977}
|
WaitingRoom: {fileID: 1590939977}
|
||||||
BeforeStart: {fileID: 563000513}
|
BeforeStart: {fileID: 563000513}
|
||||||
@ -4098,7 +4098,7 @@ GameObject:
|
|||||||
m_Icon: {fileID: 0}
|
m_Icon: {fileID: 0}
|
||||||
m_NavMeshLayer: 0
|
m_NavMeshLayer: 0
|
||||||
m_StaticEditorFlags: 0
|
m_StaticEditorFlags: 0
|
||||||
m_IsActive: 0
|
m_IsActive: 1
|
||||||
--- !u!224 &1383251890
|
--- !u!224 &1383251890
|
||||||
RectTransform:
|
RectTransform:
|
||||||
m_ObjectHideFlags: 0
|
m_ObjectHideFlags: 0
|
||||||
|
@ -9,10 +9,10 @@ public class Player
|
|||||||
{
|
{
|
||||||
public string name;
|
public string name;
|
||||||
public string id;
|
public string id;
|
||||||
public float creationDate;
|
public double creationDate;
|
||||||
|
|
||||||
[JsonConstructor]
|
[JsonConstructor]
|
||||||
public Player(string _name, string _id, float _creationDate)
|
public Player(string _name, string _id, double _creationDate)
|
||||||
{
|
{
|
||||||
name = _name;
|
name = _name;
|
||||||
id = _id;
|
id = _id;
|
||||||
@ -23,7 +23,7 @@ public Player(string _name, string _id, float _creationDate)
|
|||||||
public Player(string _name)
|
public Player(string _name)
|
||||||
{
|
{
|
||||||
id = Guid.NewGuid().ToString();
|
id = Guid.NewGuid().ToString();
|
||||||
creationDate = Time.time;
|
creationDate = DateTime.Now.ToOADate();
|
||||||
SetName(_name);
|
SetName(_name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -6,6 +6,7 @@
|
|||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
using TMPro;
|
using TMPro;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
using static UnityEditor.Experimental.AssetDatabaseExperimental.AssetDatabaseCounters;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// This is the game state manager on the phone side
|
/// This is the game state manager on the phone side
|
||||||
@ -30,6 +31,9 @@ public class GameManager : MonoBehaviour
|
|||||||
public TextMeshProUGUI listPlayersUI;
|
public TextMeshProUGUI listPlayersUI;
|
||||||
public GameObject submitStartGame;
|
public GameObject submitStartGame;
|
||||||
|
|
||||||
|
[Header("Explanation Component")]
|
||||||
|
public TextMeshProUGUI counter;
|
||||||
|
|
||||||
[Header("Pages")]
|
[Header("Pages")]
|
||||||
public GameObject HomeConnection;
|
public GameObject HomeConnection;
|
||||||
public GameObject WaitingRoom;
|
public GameObject WaitingRoom;
|
||||||
@ -42,6 +46,7 @@ public class GameManager : MonoBehaviour
|
|||||||
private DatabaseReference realtimeDB;
|
private DatabaseReference realtimeDB;
|
||||||
public Room myRoom;
|
public Room myRoom;
|
||||||
private DatabaseReference myOnlineRoom;
|
private DatabaseReference myOnlineRoom;
|
||||||
|
private DateTime endOfExplanationDate = DateTime.MinValue;
|
||||||
|
|
||||||
private void Awake()
|
private void Awake()
|
||||||
{
|
{
|
||||||
@ -66,6 +71,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()
|
private void Initialize()
|
||||||
{
|
{
|
||||||
@ -117,11 +136,11 @@ public void PlayerValidateNameAndServerRoom(string _name, string _code)
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
myOnlineRoom = realtimeDB.Child("rooms").Child(_code);
|
myOnlineRoom = realtimeDB.Child("rooms").Child(_code);
|
||||||
|
//subscribe to it
|
||||||
|
myOnlineRoom.ValueChanged += OnRoomUpdate;
|
||||||
//if room exists, join it
|
//if room exists, join it
|
||||||
JoinRoom(() =>
|
JoinRoom(() =>
|
||||||
{
|
{
|
||||||
//then subscribe to it
|
|
||||||
myOnlineRoom.ValueChanged += OnRoomUpdate;
|
|
||||||
myRoom.currentState = (int)GameState.WaitingForOtherPlayersToJoin;
|
myRoom.currentState = (int)GameState.WaitingForOtherPlayersToJoin;
|
||||||
players.Add(currentPlayer);
|
players.Add(currentPlayer);
|
||||||
|
|
||||||
@ -270,7 +289,11 @@ private void OnRoomUpdate(object sender, ValueChangedEventArgs e)
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
myRoom = JsonConvert.DeserializeObject<Room>(e.Snapshot.GetRawJsonValue());
|
if (e!= null)
|
||||||
|
{
|
||||||
|
myRoom = JsonConvert.DeserializeObject<Room>(e.Snapshot.GetRawJsonValue());
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
@ -289,7 +312,10 @@ private void OnRoomUpdate(object sender, ValueChangedEventArgs e)
|
|||||||
}
|
}
|
||||||
case (int)GameState.Explanation:
|
case (int)GameState.Explanation:
|
||||||
{
|
{
|
||||||
|
WaitingRoom.SetActive(false);
|
||||||
|
BeforeStart.SetActive(true);
|
||||||
|
endOfExplanationDate = DateTime.Now.AddSeconds(3);
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case (int)GameState.MakeProposition:
|
case (int)GameState.MakeProposition:
|
||||||
|
Loading…
Reference in New Issue
Block a user