Merge branch 'main' of github.com:LeGall29/GGJ2024

This commit is contained in:
Michel Roux 2024-01-28 01:16:57 +01:00
commit fd97887dd7
6 changed files with 562 additions and 70 deletions

View File

@ -749,7 +749,7 @@ GameObject:
m_Component: m_Component:
- component: {fileID: 157938956} - component: {fileID: 157938956}
- component: {fileID: 157938958} - component: {fileID: 157938958}
- component: {fileID: 157938957} - component: {fileID: 157938959}
m_Layer: 5 m_Layer: 5
m_Name: Timer m_Name: Timer
m_TagString: Untagged m_TagString: Untagged
@ -775,9 +775,17 @@ RectTransform:
m_AnchorMin: {x: 1, y: 1} m_AnchorMin: {x: 1, y: 1}
m_AnchorMax: {x: 1, y: 1} m_AnchorMax: {x: 1, y: 1}
m_AnchoredPosition: {x: -43, y: -51} m_AnchoredPosition: {x: -43, y: -51}
m_SizeDelta: {x: 100, y: 100} m_SizeDelta: {x: 200, y: 200}
m_Pivot: {x: 1, y: 1} m_Pivot: {x: 1, y: 1}
--- !u!114 &157938957 --- !u!222 &157938958
CanvasRenderer:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 157938955}
m_CullTransparentMesh: 1
--- !u!114 &157938959
MonoBehaviour: MonoBehaviour:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0} m_CorrespondingSourceObject: {fileID: 0}
@ -786,7 +794,7 @@ MonoBehaviour:
m_GameObject: {fileID: 157938955} m_GameObject: {fileID: 157938955}
m_Enabled: 1 m_Enabled: 1
m_EditorHideFlags: 0 m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 1344c3c82d62a2a41a3576d8abb8e3ea, type: 3} m_Script: {fileID: 11500000, guid: fe87c0e1cc204ed48ad3b37840f39efc, type: 3}
m_Name: m_Name:
m_EditorClassIdentifier: m_EditorClassIdentifier:
m_Material: {fileID: 0} m_Material: {fileID: 0}
@ -797,21 +805,16 @@ MonoBehaviour:
m_OnCullStateChanged: m_OnCullStateChanged:
m_PersistentCalls: m_PersistentCalls:
m_Calls: [] m_Calls: []
m_Texture: {fileID: 0} m_Sprite: {fileID: 21300000, guid: 141de4e4cebc12c489ea471b0df36fd8, type: 3}
m_UVRect: m_Type: 0
serializedVersion: 2 m_PreserveAspect: 0
x: 0 m_FillCenter: 1
y: 0 m_FillMethod: 4
width: 1 m_FillAmount: 1
height: 1 m_FillClockwise: 1
--- !u!222 &157938958 m_FillOrigin: 0
CanvasRenderer: m_UseSpriteMesh: 0
m_ObjectHideFlags: 0 m_PixelsPerUnitMultiplier: 1
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 157938955}
m_CullTransparentMesh: 1
--- !u!1 &183264014 --- !u!1 &183264014
GameObject: GameObject:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0
@ -1377,8 +1380,12 @@ MonoBehaviour:
- {fileID: 340074661} - {fileID: 340074661}
promptList: {fileID: 0} promptList: {fileID: 0}
explanationPage: {fileID: 45150984} explanationPage: {fileID: 45150984}
counter: {fileID: 1798182259} explanationCounter: {fileID: 1798182259}
explanationTime: 4
counterSFX: {fileID: 8300000, guid: 3beaa7f0d20a77649ba21959c91856f8, type: 3}
waitingForPropositionsPage: {fileID: 1730465902} waitingForPropositionsPage: {fileID: 1730465902}
propositionCounter: {fileID: 1996258852}
propositionTime: 60
waitingForPropositionsLabels: waitingForPropositionsLabels:
- {fileID: 972471162} - {fileID: 972471162}
- {fileID: 1374681049} - {fileID: 1374681049}
@ -1388,8 +1395,6 @@ MonoBehaviour:
- {fileID: 1854893636} - {fileID: 1854893636}
- {fileID: 2065109614} - {fileID: 2065109614}
- {fileID: 1197279072} - {fileID: 1197279072}
propositionTime: 59.8
timerGUI: {fileID: 0}
votingTime: 20 votingTime: 20
--- !u!114 &375256413 --- !u!114 &375256413
MonoBehaviour: MonoBehaviour:
@ -4125,6 +4130,7 @@ GameObject:
serializedVersion: 6 serializedVersion: 6
m_Component: m_Component:
- component: {fileID: 1117928115} - component: {fileID: 1117928115}
- component: {fileID: 1117928116}
m_Layer: 5 m_Layer: 5
m_Name: WaitingForPlayersPage m_Name: WaitingForPlayersPage
m_TagString: Untagged m_TagString: Untagged
@ -4160,6 +4166,102 @@ RectTransform:
m_AnchoredPosition: {x: 0, y: 0} m_AnchoredPosition: {x: 0, y: 0}
m_SizeDelta: {x: 0, y: 0} m_SizeDelta: {x: 0, y: 0}
m_Pivot: {x: 0.5, y: 0.5} m_Pivot: {x: 0.5, y: 0.5}
--- !u!82 &1117928116
AudioSource:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1117928114}
m_Enabled: 1
serializedVersion: 4
OutputAudioMixerGroup: {fileID: 0}
m_audioClip: {fileID: 8300000, guid: 7ac3efdb5c840704aafbf19188b3e61e, type: 3}
m_PlayOnAwake: 1
m_Volume: 1
m_Pitch: 1
Loop: 1
Mute: 0
Spatialize: 0
SpatializePostEffects: 0
Priority: 128
DopplerLevel: 1
MinDistance: 1
MaxDistance: 500
Pan2D: 0
rolloffMode: 0
BypassEffects: 0
BypassListenerEffects: 0
BypassReverbZones: 0
rolloffCustomCurve:
serializedVersion: 2
m_Curve:
- serializedVersion: 3
time: 0
value: 1
inSlope: 0
outSlope: 0
tangentMode: 0
weightedMode: 0
inWeight: 0.33333334
outWeight: 0.33333334
- serializedVersion: 3
time: 1
value: 0
inSlope: 0
outSlope: 0
tangentMode: 0
weightedMode: 0
inWeight: 0.33333334
outWeight: 0.33333334
m_PreInfinity: 2
m_PostInfinity: 2
m_RotationOrder: 4
panLevelCustomCurve:
serializedVersion: 2
m_Curve:
- serializedVersion: 3
time: 0
value: 0
inSlope: 0
outSlope: 0
tangentMode: 0
weightedMode: 0
inWeight: 0.33333334
outWeight: 0.33333334
m_PreInfinity: 2
m_PostInfinity: 2
m_RotationOrder: 4
spreadCustomCurve:
serializedVersion: 2
m_Curve:
- serializedVersion: 3
time: 0
value: 0
inSlope: 0
outSlope: 0
tangentMode: 0
weightedMode: 0
inWeight: 0.33333334
outWeight: 0.33333334
m_PreInfinity: 2
m_PostInfinity: 2
m_RotationOrder: 4
reverbZoneMixCustomCurve:
serializedVersion: 2
m_Curve:
- serializedVersion: 3
time: 0
value: 1
inSlope: 0
outSlope: 0
tangentMode: 0
weightedMode: 0
inWeight: 0.33333334
outWeight: 0.33333334
m_PreInfinity: 2
m_PostInfinity: 2
m_RotationOrder: 4
--- !u!1 &1141337195 --- !u!1 &1141337195
GameObject: GameObject:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0
@ -5431,6 +5533,7 @@ GameObject:
serializedVersion: 6 serializedVersion: 6
m_Component: m_Component:
- component: {fileID: 1451481718} - component: {fileID: 1451481718}
- component: {fileID: 1451481719}
m_Layer: 5 m_Layer: 5
m_Name: ScorePictureState m_Name: ScorePictureState
m_TagString: Untagged m_TagString: Untagged
@ -5461,6 +5564,102 @@ RectTransform:
m_AnchoredPosition: {x: 0, y: 0} m_AnchoredPosition: {x: 0, y: 0}
m_SizeDelta: {x: 0, y: 0} m_SizeDelta: {x: 0, y: 0}
m_Pivot: {x: 0.5, y: 0.5} m_Pivot: {x: 0.5, y: 0.5}
--- !u!82 &1451481719
AudioSource:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1451481717}
m_Enabled: 1
serializedVersion: 4
OutputAudioMixerGroup: {fileID: 0}
m_audioClip: {fileID: 8300000, guid: e1135788bf319bd42b6ca512976f9028, type: 3}
m_PlayOnAwake: 1
m_Volume: 1
m_Pitch: 1
Loop: 1
Mute: 0
Spatialize: 0
SpatializePostEffects: 0
Priority: 128
DopplerLevel: 1
MinDistance: 1
MaxDistance: 500
Pan2D: 0
rolloffMode: 0
BypassEffects: 0
BypassListenerEffects: 0
BypassReverbZones: 0
rolloffCustomCurve:
serializedVersion: 2
m_Curve:
- serializedVersion: 3
time: 0
value: 1
inSlope: 0
outSlope: 0
tangentMode: 0
weightedMode: 0
inWeight: 0.33333334
outWeight: 0.33333334
- serializedVersion: 3
time: 1
value: 0
inSlope: 0
outSlope: 0
tangentMode: 0
weightedMode: 0
inWeight: 0.33333334
outWeight: 0.33333334
m_PreInfinity: 2
m_PostInfinity: 2
m_RotationOrder: 4
panLevelCustomCurve:
serializedVersion: 2
m_Curve:
- serializedVersion: 3
time: 0
value: 0
inSlope: 0
outSlope: 0
tangentMode: 0
weightedMode: 0
inWeight: 0.33333334
outWeight: 0.33333334
m_PreInfinity: 2
m_PostInfinity: 2
m_RotationOrder: 4
spreadCustomCurve:
serializedVersion: 2
m_Curve:
- serializedVersion: 3
time: 0
value: 0
inSlope: 0
outSlope: 0
tangentMode: 0
weightedMode: 0
inWeight: 0.33333334
outWeight: 0.33333334
m_PreInfinity: 2
m_PostInfinity: 2
m_RotationOrder: 4
reverbZoneMixCustomCurve:
serializedVersion: 2
m_Curve:
- serializedVersion: 3
time: 0
value: 1
inSlope: 0
outSlope: 0
tangentMode: 0
weightedMode: 0
inWeight: 0.33333334
outWeight: 0.33333334
m_PreInfinity: 2
m_PostInfinity: 2
m_RotationOrder: 4
--- !u!1 &1452182575 --- !u!1 &1452182575
GameObject: GameObject:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0
@ -6089,6 +6288,7 @@ GameObject:
serializedVersion: 6 serializedVersion: 6
m_Component: m_Component:
- component: {fileID: 1730465903} - component: {fileID: 1730465903}
- component: {fileID: 1730465904}
m_Layer: 5 m_Layer: 5
m_Name: WaitingForPropositionPage m_Name: WaitingForPropositionPage
m_TagString: Untagged m_TagString: Untagged
@ -6120,6 +6320,102 @@ RectTransform:
m_AnchoredPosition: {x: 0, y: 0} m_AnchoredPosition: {x: 0, y: 0}
m_SizeDelta: {x: 0, y: 0} m_SizeDelta: {x: 0, y: 0}
m_Pivot: {x: 0.5, y: 0.5} m_Pivot: {x: 0.5, y: 0.5}
--- !u!82 &1730465904
AudioSource:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1730465902}
m_Enabled: 1
serializedVersion: 4
OutputAudioMixerGroup: {fileID: 0}
m_audioClip: {fileID: 8300000, guid: 0e86c0433979a2d4c884b368808d3cdf, type: 3}
m_PlayOnAwake: 1
m_Volume: 1
m_Pitch: 1
Loop: 1
Mute: 0
Spatialize: 0
SpatializePostEffects: 0
Priority: 128
DopplerLevel: 1
MinDistance: 1
MaxDistance: 500
Pan2D: 0
rolloffMode: 0
BypassEffects: 0
BypassListenerEffects: 0
BypassReverbZones: 0
rolloffCustomCurve:
serializedVersion: 2
m_Curve:
- serializedVersion: 3
time: 0
value: 1
inSlope: 0
outSlope: 0
tangentMode: 0
weightedMode: 0
inWeight: 0.33333334
outWeight: 0.33333334
- serializedVersion: 3
time: 1
value: 0
inSlope: 0
outSlope: 0
tangentMode: 0
weightedMode: 0
inWeight: 0.33333334
outWeight: 0.33333334
m_PreInfinity: 2
m_PostInfinity: 2
m_RotationOrder: 4
panLevelCustomCurve:
serializedVersion: 2
m_Curve:
- serializedVersion: 3
time: 0
value: 0
inSlope: 0
outSlope: 0
tangentMode: 0
weightedMode: 0
inWeight: 0.33333334
outWeight: 0.33333334
m_PreInfinity: 2
m_PostInfinity: 2
m_RotationOrder: 4
spreadCustomCurve:
serializedVersion: 2
m_Curve:
- serializedVersion: 3
time: 0
value: 0
inSlope: 0
outSlope: 0
tangentMode: 0
weightedMode: 0
inWeight: 0.33333334
outWeight: 0.33333334
m_PreInfinity: 2
m_PostInfinity: 2
m_RotationOrder: 4
reverbZoneMixCustomCurve:
serializedVersion: 2
m_Curve:
- serializedVersion: 3
time: 0
value: 1
inSlope: 0
outSlope: 0
tangentMode: 0
weightedMode: 0
inWeight: 0.33333334
outWeight: 0.33333334
m_PreInfinity: 2
m_PostInfinity: 2
m_RotationOrder: 4
--- !u!1 &1730898850 --- !u!1 &1730898850
GameObject: GameObject:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0
@ -6921,8 +7217,8 @@ MonoBehaviour:
m_Calls: [] m_Calls: []
m_text: 0000 m_text: 0000
m_isRightToLeft: 0 m_isRightToLeft: 0
m_fontAsset: {fileID: 11400000, guid: 72af27804d5aa49408430b4b2500f877, type: 2} m_fontAsset: {fileID: 11400000, guid: 8f586378b4e144a9851e7b34d9b748ee, type: 2}
m_sharedMaterial: {fileID: 8890805173838430465, guid: 72af27804d5aa49408430b4b2500f877, type: 2} m_sharedMaterial: {fileID: 2180264, guid: 8f586378b4e144a9851e7b34d9b748ee, type: 2}
m_fontSharedMaterials: [] m_fontSharedMaterials: []
m_fontMaterial: {fileID: 0} m_fontMaterial: {fileID: 0}
m_fontMaterials: [] m_fontMaterials: []
@ -6952,7 +7248,7 @@ MonoBehaviour:
m_enableAutoSizing: 0 m_enableAutoSizing: 0
m_fontSizeMin: 18 m_fontSizeMin: 18
m_fontSizeMax: 72 m_fontSizeMax: 72
m_fontStyle: 0 m_fontStyle: 1
m_HorizontalAlignment: 1 m_HorizontalAlignment: 1
m_VerticalAlignment: 256 m_VerticalAlignment: 256
m_textAlignment: 65535 m_textAlignment: 65535
@ -7702,7 +7998,7 @@ GameObject:
- component: {fileID: 1996258853} - component: {fileID: 1996258853}
- component: {fileID: 1996258852} - component: {fileID: 1996258852}
m_Layer: 5 m_Layer: 5
m_Name: Text (TMP) m_Name: Timer.Counter
m_TagString: Untagged m_TagString: Untagged
m_Icon: {fileID: 0} m_Icon: {fileID: 0}
m_NavMeshLayer: 0 m_NavMeshLayer: 0
@ -7722,11 +8018,11 @@ RectTransform:
m_Children: [] m_Children: []
m_Father: {fileID: 157938956} m_Father: {fileID: 157938956}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 1, y: 1} m_AnchorMin: {x: 0, y: 0}
m_AnchorMax: {x: 1, y: 1} m_AnchorMax: {x: 1, y: 1}
m_AnchoredPosition: {x: 128, y: -30} m_AnchoredPosition: {x: -2.5, y: -12.5}
m_SizeDelta: {x: 200, y: 50} m_SizeDelta: {x: -5, y: -25}
m_Pivot: {x: 1, y: 1} m_Pivot: {x: 0.5, y: 0.5}
--- !u!114 &1996258852 --- !u!114 &1996258852
MonoBehaviour: MonoBehaviour:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0
@ -7774,15 +8070,15 @@ MonoBehaviour:
m_faceColor: m_faceColor:
serializedVersion: 2 serializedVersion: 2
rgba: 4294967295 rgba: 4294967295
m_fontSize: 36 m_fontSize: 52
m_fontSizeBase: 36 m_fontSizeBase: 52
m_fontWeight: 400 m_fontWeight: 400
m_enableAutoSizing: 0 m_enableAutoSizing: 0
m_fontSizeMin: 18 m_fontSizeMin: 18
m_fontSizeMax: 72 m_fontSizeMax: 72
m_fontStyle: 0 m_fontStyle: 1
m_HorizontalAlignment: 1 m_HorizontalAlignment: 2
m_VerticalAlignment: 256 m_VerticalAlignment: 512
m_textAlignment: 65535 m_textAlignment: 65535
m_characterSpacing: 0 m_characterSpacing: 0
m_wordSpacing: 0 m_wordSpacing: 0
@ -7810,7 +8106,7 @@ MonoBehaviour:
m_VertexBufferAutoSizeReduction: 0 m_VertexBufferAutoSizeReduction: 0
m_useMaxVisibleDescender: 1 m_useMaxVisibleDescender: 1
m_pageToDisplay: 1 m_pageToDisplay: 1
m_margin: {x: 0, y: 0, z: 157.45232, w: 8.397432} m_margin: {x: 0, y: 0, z: 0, w: 0}
m_isUsingLegacyAnimationComponent: 0 m_isUsingLegacyAnimationComponent: 0
m_isVolumetricText: 0 m_isVolumetricText: 0
m_hasFontAssetChanged: 0 m_hasFontAssetChanged: 0

View File

@ -3533,6 +3533,43 @@ RectTransform:
m_AnchoredPosition: {x: 0, y: 0} m_AnchoredPosition: {x: 0, y: 0}
m_SizeDelta: {x: 0, y: 0} m_SizeDelta: {x: 0, y: 0}
m_Pivot: {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 --- !u!1 &1224049644
GameObject: GameObject:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0
@ -4096,7 +4133,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

View File

@ -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);
} }

View File

@ -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()
{ {
@ -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() private void Initialize()
{ {
@ -118,11 +137,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,8 +289,12 @@ public void DisplayEndScreen()
private void OnRoomUpdate(object sender, ValueChangedEventArgs e) private void OnRoomUpdate(object sender, ValueChangedEventArgs e)
{ {
try try
{
if (e!= null)
{ {
myRoom = JsonConvert.DeserializeObject<Room>(e.Snapshot.GetRawJsonValue()); myRoom = JsonConvert.DeserializeObject<Room>(e.Snapshot.GetRawJsonValue());
}
} }
catch (Exception ex) catch (Exception ex)
{ {
@ -291,6 +314,9 @@ 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;
} }
@ -323,9 +349,9 @@ private void CheckIfIAmTheFirst(List<Player> players)
if (players.Count > 1) if (players.Count > 1)
{ {
IOrderedEnumerable<Player> sortedList = players.OrderBy(x => x.creationDate); List<Player> sortedList = players.OrderBy(x => x.creationDate).ToList();
if (sortedList.Last().id == currentPlayer.id) if (sortedList[0].id == currentPlayer.id)
{ {
isFirst = true; isFirst = true;
} }

View File

@ -20,16 +20,19 @@ public class RoomManager : MonoBehaviour
[Header("Explanation Page")] [Header("Explanation Page")]
public GameObject explanationPage; public GameObject explanationPage;
public TextMeshProUGUI counter; public TextMeshProUGUI explanationCounter;
public float explanationTime;
private DateTime endOfExplanationDate = DateTime.MinValue; private DateTime endOfExplanationDate = DateTime.MinValue;
public AudioClip counterSFX;
[Header("Waiting For Proposition Page")] [Header("Waiting For Proposition Page")]
public GameObject waitingForPropositionsPage; public GameObject waitingForPropositionsPage;
public List<TextMeshProUGUI> waitingForPropositionsLabels = new List<TextMeshProUGUI>(); public TextMeshProUGUI propositionCounter;
public float propositionTime = 60; public float propositionTime = 60;
private float propositionCurrentTime = 0; public List<TextMeshProUGUI> waitingForPropositionsLabels = new List<TextMeshProUGUI>();
public TextMeshProUGUI timerGUI; private DateTime endOfPropositionDate = DateTime.MinValue;
[Header("Other")]
private Room myRoom = null; private Room myRoom = null;
public float votingTime = 20; public float votingTime = 20;
@ -54,14 +57,12 @@ private void Awake()
FirebaseInitializer.Instance.onFirebaseReady += Initialize; FirebaseInitializer.Instance.onFirebaseReady += Initialize;
} }
private void Start() private void Start()
{ {
explanationPage.SetActive(false); explanationPage.SetActive(false);
waitingForPropositionsPage.SetActive(false); waitingForPropositionsPage.SetActive(false);
waitingForPlayersPage.SetActive(true); waitingForPlayersPage.SetActive(true);
propositionCurrentTime = propositionTime;
votingCurrentTime = votingTime; votingCurrentTime = votingTime;
ResetAllPlayerLabels(); ResetAllPlayerLabels();
} }
@ -74,7 +75,8 @@ private void Update()
if (myRoom.currentState == (int)GameState.Explanation && endOfExplanationDate != DateTime.MinValue) if (myRoom.currentState == (int)GameState.Explanation && endOfExplanationDate != DateTime.MinValue)
{ {
TimeSpan duration = endOfExplanationDate - DateTime.Now; TimeSpan duration = endOfExplanationDate - DateTime.Now;
counter.text = ((int)duration.TotalSeconds).ToString("D1"); explanationCounter.text = ((int)duration.TotalSeconds).ToString("D1");
if (duration.TotalMilliseconds <= 0) if (duration.TotalMilliseconds <= 0)
{ {
@ -82,6 +84,13 @@ private void Update()
SendRoomState(GameState.MakeProposition); SendRoomState(GameState.MakeProposition);
} }
} }
if (myRoom.currentState == (int)GameState.MakeProposition && endOfPropositionDate != DateTime.MinValue)
{
TimeSpan duration = endOfPropositionDate - DateTime.Now;
propositionCounter.text = ((int)duration.TotalSeconds).ToString("D1");
}
} }
private void SendRoomState(GameState _newState) private void SendRoomState(GameState _newState)
@ -217,7 +226,8 @@ public void HostStartGame()
{ {
waitingForPropositionsPage.SetActive(true); waitingForPropositionsPage.SetActive(true);
waitingForPlayersPage.SetActive(false); waitingForPlayersPage.SetActive(false);
propositionCurrentTime = propositionTime; endOfPropositionDate = DateTime.Now.AddSeconds(propositionTime);
AudioSource.PlayClipAtPoint(counterSFX, Vector3.zero);
} }
/// <summary> /// <summary>
@ -339,7 +349,7 @@ private void OnRoomUpdate(object sender, ValueChangedEventArgs value)
case (int)GameState.Explanation: case (int)GameState.Explanation:
waitingForPlayersPage.SetActive(false); waitingForPlayersPage.SetActive(false);
explanationPage.SetActive(true); explanationPage.SetActive(true);
endOfExplanationDate = DateTime.Now.AddSeconds(3); endOfExplanationDate = DateTime.Now.AddSeconds(explanationTime);
break; break;
case (int)GameState.MakeProposition: case (int)GameState.MakeProposition:
HostStartGame(); HostStartGame();

File diff suppressed because one or more lines are too long