From 5130a1dc4b3372f22e127bb3ae00c10b8a616643 Mon Sep 17 00:00:00 2001 From: Michel Roux Date: Sat, 27 Jan 2024 22:55:04 +0100 Subject: [PATCH 1/4] feat: generatePrompt --- Assets/Scripts/DatabaseClasses/Question.cs | 5 ++- Assets/Scripts/GameManager.cs | 1 - Assets/Scripts/PromptListLoader.cs | 1 + Assets/Scripts/RoomManager.cs | 45 +++++++++++++++------- 4 files changed, 36 insertions(+), 16 deletions(-) diff --git a/Assets/Scripts/DatabaseClasses/Question.cs b/Assets/Scripts/DatabaseClasses/Question.cs index 12f3c6b..db6666e 100644 --- a/Assets/Scripts/DatabaseClasses/Question.cs +++ b/Assets/Scripts/DatabaseClasses/Question.cs @@ -1,11 +1,12 @@ using Newtonsoft.Json; using System; +using System.Collections.Generic; [Serializable] [JsonObject] public class Question { public string promptId; - public Proposition propositions; - public int creationDate; + public Dictionary propositions; + public double creationDate; } diff --git a/Assets/Scripts/GameManager.cs b/Assets/Scripts/GameManager.cs index c3edb8f..38a0d60 100644 --- a/Assets/Scripts/GameManager.cs +++ b/Assets/Scripts/GameManager.cs @@ -13,7 +13,6 @@ public class GameManager : MonoBehaviour private GameState currentState; private List players = new(); public Player currentPlayer = null; - public Question currentQuestion = null; [Header("Other component")] public float explanationTime = 4f; diff --git a/Assets/Scripts/PromptListLoader.cs b/Assets/Scripts/PromptListLoader.cs index 8f4d619..879bd51 100644 --- a/Assets/Scripts/PromptListLoader.cs +++ b/Assets/Scripts/PromptListLoader.cs @@ -25,6 +25,7 @@ private void Initialize() { FirebaseInitializer.Instance.onFirebaseReady -= Initialize; db = FirebaseFirestore.DefaultInstance; + LoadPromptsFromFirestore(); } /// diff --git a/Assets/Scripts/RoomManager.cs b/Assets/Scripts/RoomManager.cs index 5693d9a..4f4022d 100644 --- a/Assets/Scripts/RoomManager.cs +++ b/Assets/Scripts/RoomManager.cs @@ -5,7 +5,6 @@ using TMPro; using UnityEngine; using Newtonsoft.Json; -using Newtonsoft.Json.Linq; using System.Linq; public class RoomManager : MonoBehaviour @@ -15,6 +14,7 @@ public class RoomManager : MonoBehaviour private RoomState currentState; private Room myRoom = null; private List players; + public PromptList promptList; public float propositionTime = 60; public float votingTime = 20; @@ -231,22 +231,41 @@ public void OnPropositionUpdate() } - /// - /// Will generate a question with a prompt and two owners - /// - public void GenerateQuestion() + public void GeneratePrompts() { + System.Random rnd = new(); + List prompts = promptList.prompts.OrderBy(x => rnd.Next()).Take(players.Count() * 2).ToList(); + List fullPlayers = players.Concat(players).OrderBy(x => rnd.Next()).ToList(); + Dictionary questions = new(); - } + foreach (Prompt prompt in prompts) + { + Dictionary propositions = new(); + Player basePlayer = fullPlayers[0]; + propositions.Add(Guid.NewGuid().ToString(), new Proposition() { owner = basePlayer }); - /// - /// Generate all the player pairs - /// (players should not play against themself. - /// (players should not play twice with the same person) - /// - public void GenerateCouples() - { + for (int i = 1; i < fullPlayers.Count(); i++) + { + Player secondPlayer = fullPlayers[i]; + if (basePlayer.id != secondPlayer.id) + { + propositions.Add(Guid.NewGuid().ToString(), new Proposition() { owner = secondPlayer }); + fullPlayers.RemoveAt(0); + break; + } + } + + questions.Add(Guid.NewGuid().ToString(), new Question() + { + promptId = prompt.id, + propositions = propositions, + creationDate = DateTime.Now.ToOADate(), + }); + } + + string JSON = JsonConvert.SerializeObject(questions); + realtimeDB.Child("rooms").Child(myRoom.code).Child("questions").SetRawJsonValueAsync(JSON); } /// From 927e0dfbb953841795433b871f98cb628899dcb1 Mon Sep 17 00:00:00 2001 From: Michel Roux Date: Sat, 27 Jan 2024 23:05:27 +0100 Subject: [PATCH 2/4] fix: add creationDate on proposition --- Assets/Scripts/DatabaseClasses/Proposition.cs | 1 + Assets/Scripts/RoomManager.cs | 14 ++++++++++++-- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/Assets/Scripts/DatabaseClasses/Proposition.cs b/Assets/Scripts/DatabaseClasses/Proposition.cs index 2fe170c..b63278b 100644 --- a/Assets/Scripts/DatabaseClasses/Proposition.cs +++ b/Assets/Scripts/DatabaseClasses/Proposition.cs @@ -8,4 +8,5 @@ public class Proposition public string photoUrl; public Player owner; public string[] voters; + public double creationDate; } diff --git a/Assets/Scripts/RoomManager.cs b/Assets/Scripts/RoomManager.cs index e8b3204..4742796 100644 --- a/Assets/Scripts/RoomManager.cs +++ b/Assets/Scripts/RoomManager.cs @@ -244,7 +244,12 @@ public void GeneratePrompts() { Dictionary propositions = new(); Player basePlayer = fullPlayers[0]; - propositions.Add(Guid.NewGuid().ToString(), new Proposition() { owner = basePlayer }); + + propositions.Add(Guid.NewGuid().ToString(), new Proposition() + { + owner = basePlayer, + creationDate = DateTime.Now.ToOADate() + }); for (int i = 1; i < fullPlayers.Count(); i++) { @@ -252,7 +257,12 @@ public void GeneratePrompts() if (basePlayer.id != secondPlayer.id) { - propositions.Add(Guid.NewGuid().ToString(), new Proposition() { owner = secondPlayer }); + propositions.Add(Guid.NewGuid().ToString(), new Proposition() + { + owner = secondPlayer, + creationDate = DateTime.Now.ToOADate() + }); + fullPlayers.RemoveAt(0); break; } From e13f094914fc6ecd241ce4f56707c1bf9a93f78d Mon Sep 17 00:00:00 2001 From: Morgan - 6 Freedom Date: Sat, 27 Jan 2024 23:07:41 +0100 Subject: [PATCH 3/4] explanation page on PC --- Assets/Scenes/ComputerView.unity | 453 ++++++++++++++++++++++++++++--- Assets/Scripts/RoomManager.cs | 39 ++- 2 files changed, 452 insertions(+), 40 deletions(-) diff --git a/Assets/Scenes/ComputerView.unity b/Assets/Scenes/ComputerView.unity index 283eb78..ae760c4 100644 --- a/Assets/Scenes/ComputerView.unity +++ b/Assets/Scenes/ComputerView.unity @@ -263,6 +263,44 @@ CanvasRenderer: m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 9253746} m_CullTransparentMesh: 1 +--- !u!1 &45150984 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 45150985} + m_Layer: 5 + m_Name: ExplanationPage + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 0 +--- !u!224 &45150985 +RectTransform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 45150984} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_ConstrainProportionsScale: 0 + m_Children: + - {fileID: 500028487} + - {fileID: 619055281} + - {fileID: 1798182258} + m_Father: {fileID: 610087870} + 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: 0} + m_SizeDelta: {x: 0, y: 0} + m_Pivot: {x: 0.5, y: 0.5} --- !u!1 &58343404 GameObject: m_ObjectHideFlags: 0 @@ -464,10 +502,10 @@ RectTransform: m_Children: [] m_Father: {fileID: 987875882} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} - m_AnchorMin: {x: 0, y: 0} - m_AnchorMax: {x: 0, y: 0} - m_AnchoredPosition: {x: 0, y: 0} - m_SizeDelta: {x: 0, y: 0} + m_AnchorMin: {x: 0, y: 1} + m_AnchorMax: {x: 0, y: 1} + m_AnchoredPosition: {x: 1200, y: -200} + m_SizeDelta: {x: 400, y: 400} m_Pivot: {x: 0, y: 0.5} --- !u!114 &130058895 MonoBehaviour: @@ -1326,6 +1364,7 @@ MonoBehaviour: m_Name: m_EditorClassIdentifier: waitingForPlayersPage: {fileID: 1117928114} + roomCodeLabel: {fileID: 1805240027} waitingForPlayersLabels: - {fileID: 1794849355} - {fileID: 1452182577} @@ -1335,6 +1374,8 @@ MonoBehaviour: - {fileID: 496953434} - {fileID: 2137991537} - {fileID: 340074661} + explanationPage: {fileID: 0} + counter: {fileID: 0} waitingForPropositionsPage: {fileID: 1730465902} waitingForPropositionsLabels: - {fileID: 972471162} @@ -1346,8 +1387,8 @@ MonoBehaviour: - {fileID: 2065109614} - {fileID: 1197279072} propositionTime: 59.8 + timerGUI: {fileID: 0} votingTime: 20 - roomCodeLabel: {fileID: 1805240027} --- !u!114 &375256413 MonoBehaviour: m_ObjectHideFlags: 0 @@ -1649,6 +1690,78 @@ CanvasRenderer: m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 496953432} m_CullTransparentMesh: 0 +--- !u!1 &500028486 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 500028487} + - component: {fileID: 500028489} + - component: {fileID: 500028488} + m_Layer: 5 + m_Name: Background + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!224 &500028487 +RectTransform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 500028486} + m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_ConstrainProportionsScale: 0 + m_Children: [] + m_Father: {fileID: 45150985} + 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: 0} + m_SizeDelta: {x: 0, y: 0} + m_Pivot: {x: 0.5, y: 0.5} +--- !u!114 &500028488 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 500028486} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 1344c3c82d62a2a41a3576d8abb8e3ea, type: 3} + m_Name: + m_EditorClassIdentifier: + m_Material: {fileID: 0} + m_Color: {r: 1, g: 1, b: 1, a: 1} + m_RaycastTarget: 1 + m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0} + m_Maskable: 1 + m_OnCullStateChanged: + m_PersistentCalls: + m_Calls: [] + m_Texture: {fileID: 2800000, guid: 51cab6d235722024da1a1ba85f4d2e99, type: 3} + m_UVRect: + serializedVersion: 2 + x: 0 + y: 0 + width: 1 + height: 1 +--- !u!222 &500028489 +CanvasRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 500028486} + m_CullTransparentMesh: 1 --- !u!1 &581333953 GameObject: m_ObjectHideFlags: 0 @@ -1902,6 +2015,7 @@ RectTransform: m_ConstrainProportionsScale: 0 m_Children: - {fileID: 1117928115} + - {fileID: 45150985} - {fileID: 1730465903} - {fileID: 1660260834} - {fileID: 1451481718} @@ -1913,6 +2027,141 @@ RectTransform: m_AnchoredPosition: {x: 0, y: 0} m_SizeDelta: {x: 0, y: 0} m_Pivot: {x: 0, y: 0} +--- !u!1 &619055280 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 619055281} + - component: {fileID: 619055283} + - component: {fileID: 619055282} + m_Layer: 5 + m_Name: Explanation + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!224 &619055281 +RectTransform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 619055280} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_ConstrainProportionsScale: 0 + m_Children: [] + m_Father: {fileID: 45150985} + 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: 210.61394} + m_SizeDelta: {x: 0, y: -421.2278} + m_Pivot: {x: 0.5, y: 0.5} +--- !u!114 &619055282 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 619055280} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: f4688fdb7df04437aeb418b961361dc5, type: 3} + m_Name: + m_EditorClassIdentifier: + m_Material: {fileID: 0} + m_Color: {r: 1, g: 1, b: 1, a: 1} + m_RaycastTarget: 1 + m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0} + m_Maskable: 1 + m_OnCullStateChanged: + m_PersistentCalls: + m_Calls: [] + m_text: "You will have some prompts \nand you will have to take pictures of what + is asked.\n\n Are you Ready ?" + m_isRightToLeft: 0 + m_fontAsset: {fileID: 11400000, guid: 72af27804d5aa49408430b4b2500f877, type: 2} + m_sharedMaterial: {fileID: 8890805173838430465, guid: 72af27804d5aa49408430b4b2500f877, type: 2} + m_fontSharedMaterials: [] + m_fontMaterial: {fileID: 0} + m_fontMaterials: [] + m_fontColor32: + serializedVersion: 2 + rgba: 4278250239 + m_fontColor: {r: 1, g: 0.91909254, b: 0, a: 1} + m_enableVertexGradient: 0 + m_colorMode: 3 + m_fontColorGradient: + topLeft: {r: 1, g: 1, b: 1, a: 1} + topRight: {r: 1, g: 1, b: 1, a: 1} + bottomLeft: {r: 1, g: 1, b: 1, a: 1} + bottomRight: {r: 1, g: 1, b: 1, a: 1} + m_fontColorGradientPreset: {fileID: 0} + m_spriteAsset: {fileID: 0} + m_tintAllSprites: 0 + m_StyleSheet: {fileID: 0} + m_TextStyleHashCode: -1183493901 + m_overrideHtmlColors: 0 + m_faceColor: + serializedVersion: 2 + rgba: 4294967295 + m_fontSize: 96 + m_fontSizeBase: 96 + m_fontWeight: 400 + m_enableAutoSizing: 0 + m_fontSizeMin: 18 + m_fontSizeMax: 72 + m_fontStyle: 0 + m_HorizontalAlignment: 2 + m_VerticalAlignment: 512 + m_textAlignment: 65535 + m_characterSpacing: 0 + m_wordSpacing: 0 + m_lineSpacing: 0 + m_lineSpacingMax: 0 + m_paragraphSpacing: 0 + m_charWidthMaxAdj: 0 + m_enableWordWrapping: 1 + m_wordWrappingRatios: 0.4 + m_overflowMode: 0 + m_linkedTextComponent: {fileID: 0} + parentLinkedComponent: {fileID: 0} + m_enableKerning: 1 + m_enableExtraPadding: 0 + checkPaddingRequired: 0 + m_isRichText: 1 + m_parseCtrlCharacters: 1 + m_isOrthographic: 1 + m_isCullingEnabled: 0 + m_horizontalMapping: 0 + m_verticalMapping: 0 + m_uvLineOffset: 0 + m_geometrySortingOrder: 0 + m_IsTextObjectScaleStatic: 0 + m_VertexBufferAutoSizeReduction: 0 + m_useMaxVisibleDescender: 1 + m_pageToDisplay: 1 + m_margin: {x: 0, y: 0, z: 0, w: 0} + m_isUsingLegacyAnimationComponent: 0 + m_isVolumetricText: 0 + m_hasFontAssetChanged: 0 + m_baseMaterial: {fileID: 0} + m_maskOffset: {x: 0, y: 0, z: 0, w: 0} +--- !u!222 &619055283 +CanvasRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 619055280} + m_CullTransparentMesh: 1 --- !u!1 &655174605 GameObject: m_ObjectHideFlags: 0 @@ -2213,10 +2462,10 @@ RectTransform: m_Children: [] m_Father: {fileID: 987875882} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} - m_AnchorMin: {x: 0, y: 0} - m_AnchorMax: {x: 0, y: 0} - m_AnchoredPosition: {x: 0, y: 0} - m_SizeDelta: {x: 0, y: 0} + m_AnchorMin: {x: 0, y: 1} + m_AnchorMax: {x: 0, y: 1} + m_AnchoredPosition: {x: 0, y: -600} + m_SizeDelta: {x: 400, y: 400} m_Pivot: {x: 0, y: 0.5} --- !u!114 &680005431 MonoBehaviour: @@ -2946,10 +3195,10 @@ RectTransform: m_Children: [] m_Father: {fileID: 987875882} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} - m_AnchorMin: {x: 0, y: 0} - m_AnchorMax: {x: 0, y: 0} - m_AnchoredPosition: {x: 0, y: 0} - m_SizeDelta: {x: 0, y: 0} + m_AnchorMin: {x: 0, y: 1} + m_AnchorMax: {x: 0, y: 1} + m_AnchoredPosition: {x: 0, y: -200} + m_SizeDelta: {x: 400, y: 400} m_Pivot: {x: 0, y: 0.5} --- !u!114 &972471162 MonoBehaviour: @@ -3941,10 +4190,10 @@ RectTransform: m_Children: [] m_Father: {fileID: 987875882} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} - m_AnchorMin: {x: 0, y: 0} - m_AnchorMax: {x: 0, y: 0} - m_AnchoredPosition: {x: 0, y: 0} - m_SizeDelta: {x: 0, y: 0} + m_AnchorMin: {x: 0, y: 1} + m_AnchorMax: {x: 0, y: 1} + m_AnchoredPosition: {x: 800, y: -200} + m_SizeDelta: {x: 400, y: 400} m_Pivot: {x: 0, y: 0.5} --- !u!114 &1141337197 MonoBehaviour: @@ -4209,10 +4458,10 @@ RectTransform: m_Children: [] m_Father: {fileID: 987875882} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} - m_AnchorMin: {x: 0, y: 0} - m_AnchorMax: {x: 0, y: 0} - m_AnchoredPosition: {x: 0, y: 0} - m_SizeDelta: {x: 0, y: 0} + m_AnchorMin: {x: 0, y: 1} + m_AnchorMax: {x: 0, y: 1} + m_AnchoredPosition: {x: 1200, y: -600} + m_SizeDelta: {x: 400, y: 400} m_Pivot: {x: 0, y: 0.5} --- !u!114 &1197279072 MonoBehaviour: @@ -4860,10 +5109,10 @@ RectTransform: m_Children: [] m_Father: {fileID: 987875882} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} - m_AnchorMin: {x: 0, y: 0} - m_AnchorMax: {x: 0, y: 0} - m_AnchoredPosition: {x: 0, y: 0} - m_SizeDelta: {x: 0, y: 0} + m_AnchorMin: {x: 0, y: 1} + m_AnchorMax: {x: 0, y: 1} + m_AnchoredPosition: {x: 400, y: -200} + m_SizeDelta: {x: 400, y: 400} m_Pivot: {x: 0, y: 0.5} --- !u!114 &1374681049 MonoBehaviour: @@ -5764,12 +6013,12 @@ GameObject: m_Component: - component: {fileID: 1730465903} m_Layer: 5 - m_Name: WiatingForPropositionPage + m_Name: WaitingForPropositionPage m_TagString: Untagged m_Icon: {fileID: 0} m_NavMeshLayer: 0 m_StaticEditorFlags: 0 - m_IsActive: 1 + m_IsActive: 0 --- !u!224 &1730465903 RectTransform: m_ObjectHideFlags: 0 @@ -6196,6 +6445,140 @@ CanvasRenderer: m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 1794849353} m_CullTransparentMesh: 0 +--- !u!1 &1798182257 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 1798182258} + - component: {fileID: 1798182260} + - component: {fileID: 1798182259} + m_Layer: 5 + m_Name: Counter + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!224 &1798182258 +RectTransform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1798182257} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_ConstrainProportionsScale: 0 + m_Children: [] + m_Father: {fileID: 45150985} + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} + m_AnchorMin: {x: 0, y: 0} + m_AnchorMax: {x: 1, y: 0} + m_AnchoredPosition: {x: 0, y: 0} + m_SizeDelta: {x: 0, y: 540} + m_Pivot: {x: 0.5, y: 0} +--- !u!114 &1798182259 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1798182257} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: f4688fdb7df04437aeb418b961361dc5, type: 3} + m_Name: + m_EditorClassIdentifier: + m_Material: {fileID: 0} + m_Color: {r: 1, g: 1, b: 1, a: 1} + m_RaycastTarget: 1 + m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0} + m_Maskable: 1 + m_OnCullStateChanged: + m_PersistentCalls: + m_Calls: [] + m_text: 3 + m_isRightToLeft: 0 + m_fontAsset: {fileID: 11400000, guid: 72af27804d5aa49408430b4b2500f877, type: 2} + m_sharedMaterial: {fileID: 8890805173838430465, guid: 72af27804d5aa49408430b4b2500f877, type: 2} + m_fontSharedMaterials: [] + m_fontMaterial: {fileID: 0} + m_fontMaterials: [] + m_fontColor32: + serializedVersion: 2 + rgba: 4278254591 + m_fontColor: {r: 1, g: 0.98475426, b: 0, a: 1} + m_enableVertexGradient: 0 + m_colorMode: 3 + m_fontColorGradient: + topLeft: {r: 1, g: 1, b: 1, a: 1} + topRight: {r: 1, g: 1, b: 1, a: 1} + bottomLeft: {r: 1, g: 1, b: 1, a: 1} + bottomRight: {r: 1, g: 1, b: 1, a: 1} + m_fontColorGradientPreset: {fileID: 0} + m_spriteAsset: {fileID: 0} + m_tintAllSprites: 0 + m_StyleSheet: {fileID: 0} + m_TextStyleHashCode: -1183493901 + m_overrideHtmlColors: 0 + m_faceColor: + serializedVersion: 2 + rgba: 4294967295 + m_fontSize: 200 + m_fontSizeBase: 200 + m_fontWeight: 400 + m_enableAutoSizing: 0 + m_fontSizeMin: 18 + m_fontSizeMax: 72 + m_fontStyle: 0 + m_HorizontalAlignment: 2 + m_VerticalAlignment: 512 + m_textAlignment: 65535 + m_characterSpacing: 0 + m_wordSpacing: 0 + m_lineSpacing: 0 + m_lineSpacingMax: 0 + m_paragraphSpacing: 0 + m_charWidthMaxAdj: 0 + m_enableWordWrapping: 1 + m_wordWrappingRatios: 0.4 + m_overflowMode: 0 + m_linkedTextComponent: {fileID: 0} + parentLinkedComponent: {fileID: 0} + m_enableKerning: 1 + m_enableExtraPadding: 0 + checkPaddingRequired: 0 + m_isRichText: 1 + m_parseCtrlCharacters: 1 + m_isOrthographic: 1 + m_isCullingEnabled: 0 + m_horizontalMapping: 0 + m_verticalMapping: 0 + m_uvLineOffset: 0 + m_geometrySortingOrder: 0 + m_IsTextObjectScaleStatic: 0 + m_VertexBufferAutoSizeReduction: 0 + m_useMaxVisibleDescender: 1 + m_pageToDisplay: 1 + m_margin: {x: 0, y: 0, z: 0, w: 0} + m_isUsingLegacyAnimationComponent: 0 + m_isVolumetricText: 0 + m_hasFontAssetChanged: 0 + m_baseMaterial: {fileID: 0} + m_maskOffset: {x: 0, y: 0, z: 0, w: 0} +--- !u!222 &1798182260 +CanvasRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1798182257} + m_CullTransparentMesh: 1 --- !u!1 &1803918109 GameObject: m_ObjectHideFlags: 0 @@ -6774,10 +7157,10 @@ RectTransform: m_Children: [] m_Father: {fileID: 987875882} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} - m_AnchorMin: {x: 0, y: 0} - m_AnchorMax: {x: 0, y: 0} - m_AnchoredPosition: {x: 0, y: 0} - m_SizeDelta: {x: 0, y: 0} + m_AnchorMin: {x: 0, y: 1} + m_AnchorMax: {x: 0, y: 1} + m_AnchoredPosition: {x: 400, y: -600} + m_SizeDelta: {x: 400, y: 400} m_Pivot: {x: 0, y: 0.5} --- !u!114 &1854893636 MonoBehaviour: @@ -7664,10 +8047,10 @@ RectTransform: m_Children: [] m_Father: {fileID: 987875882} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} - m_AnchorMin: {x: 0, y: 0} - m_AnchorMax: {x: 0, y: 0} - m_AnchoredPosition: {x: 0, y: 0} - m_SizeDelta: {x: 0, y: 0} + m_AnchorMin: {x: 0, y: 1} + m_AnchorMax: {x: 0, y: 1} + m_AnchoredPosition: {x: 800, y: -600} + m_SizeDelta: {x: 400, y: 400} m_Pivot: {x: 0, y: 0.5} --- !u!114 &2065109614 MonoBehaviour: diff --git a/Assets/Scripts/RoomManager.cs b/Assets/Scripts/RoomManager.cs index 4742796..f046b60 100644 --- a/Assets/Scripts/RoomManager.cs +++ b/Assets/Scripts/RoomManager.cs @@ -18,6 +18,11 @@ public class RoomManager : MonoBehaviour public List waitingForPlayersLabels = new List(); public PromptList promptList; + [Header("Explanation Page")] + public GameObject explanationPage; + public TextMeshProUGUI counter; + private DateTime endOfExplanationDate = DateTime.MinValue; + [Header("Waiting For Proposition Page")] public GameObject waitingForPropositionsPage; public List waitingForPropositionsLabels = new List(); @@ -57,11 +62,26 @@ private void Start() { propositionCurrentTime = propositionTime; votingCurrentTime = votingTime; - DisableAllPlayerLabels(); + ResetAllPlayerLabels(); currentState = GameState.WaitingForOtherPlayersToJoin; } - private void DisableAllPlayerLabels() + private void Update() + { + if (currentState == GameState.Explanation && endOfExplanationDate != DateTime.MinValue) + { + TimeSpan duration = endOfExplanationDate - DateTime.Now; + counter.text = duration.TotalSeconds.ToString("D1"); + + if (duration.TotalMilliseconds <= 0) + { + Debug.Log("It's time to make proposition !", this); + currentState = GameState.MakeProposition; + } + } + } + + private void ResetAllPlayerLabels() { for (int i = 0; i < waitingForPlayersLabels.Count; i++) { @@ -71,9 +91,12 @@ private void DisableAllPlayerLabels() private void OnApplicationQuit() { - realtimeDB.Child("rooms").Child(myRoom.code).RemoveValueAsync(); Debug.Log($"delete room {myRoom.code}"); - myRoom = null; + realtimeDB.Child("rooms").Child(myRoom.code).RemoveValueAsync().ContinueWithOnMainThread(task => + { + Debug.Log($"room {myRoom.code} has been deleted"); + myRoom = null; + }); } private void Initialize() @@ -137,7 +160,6 @@ public void CreateNewRoom() { WhichCodesAreAlreadyUsed(codes => { - Debug.Log("coucou"); Room newRoom = new Room(GenerateRandomAvailableCode(codes).ToString("D4")); myRoom = newRoom; try @@ -307,6 +329,11 @@ private void OnRoomUpdate(object sender, ValueChangedEventArgs value) case GameState.WaitingForOtherPlayersToJoin: UpdateConnectedPlayerList(myRoom.GetPlayerList()); break; + case GameState.Explanation: + waitingForPlayersPage.SetActive(false); + explanationPage.SetActive(true); + endOfExplanationDate = DateTime.Now.AddSeconds(30); + break; case GameState.MakeProposition: HostStartGame(); break; @@ -321,6 +348,8 @@ private void OnRoomUpdate(object sender, ValueChangedEventArgs value) /// private void UpdateConnectedPlayerList(List _players) { + ResetAllPlayerLabels(); + Debug.Log($"players count = {_players.Count}"); for (int i = 0; i < _players.Count; i++) { From 9da21988718947dbe53030c70d64504a7ea0ba7a Mon Sep 17 00:00:00 2001 From: Morgan - 6 Freedom Date: Sat, 27 Jan 2024 23:12:47 +0100 Subject: [PATCH 4/4] add logo --- ...ra_inference-img2img_3_1706347967.png.meta | 18 +-- Assets/Scenes/ComputerView.unity | 143 ++++++++++++++---- 2 files changed, 119 insertions(+), 42 deletions(-) diff --git a/Assets/2DAssets/Neon Fantasy + Surreal_aerhTa9ZQ2CueA82RYbJaA_logo, stylized, pop, video game, camera_inference-img2img_3_1706347967.png.meta b/Assets/2DAssets/Neon Fantasy + Surreal_aerhTa9ZQ2CueA82RYbJaA_logo, stylized, pop, video game, camera_inference-img2img_3_1706347967.png.meta index a645cce..f9a5607 100644 --- a/Assets/2DAssets/Neon Fantasy + Surreal_aerhTa9ZQ2CueA82RYbJaA_logo, stylized, pop, video game, camera_inference-img2img_3_1706347967.png.meta +++ b/Assets/2DAssets/Neon Fantasy + Surreal_aerhTa9ZQ2CueA82RYbJaA_logo, stylized, pop, video game, camera_inference-img2img_3_1706347967.png.meta @@ -6,7 +6,7 @@ TextureImporter: serializedVersion: 12 mipmaps: mipMapMode: 0 - enableMipMap: 1 + enableMipMap: 0 sRGBTexture: 1 linearTexture: 0 fadeOut: 0 @@ -37,13 +37,13 @@ TextureImporter: filterMode: 1 aniso: 1 mipBias: 0 - wrapU: 0 - wrapV: 0 + wrapU: 1 + wrapV: 1 wrapW: 0 - nPOTScale: 1 + nPOTScale: 0 lightmap: 0 compressionQuality: 50 - spriteMode: 0 + spriteMode: 1 spriteExtrude: 1 spriteMeshType: 1 alignment: 0 @@ -52,9 +52,9 @@ TextureImporter: spriteBorder: {x: 0, y: 0, z: 0, w: 0} spriteGenerateFallbackPhysicsShape: 1 alphaUsage: 1 - alphaIsTransparency: 0 + alphaIsTransparency: 1 spriteTessellationDetail: -1 - textureType: 0 + textureType: 8 textureShape: 1 singleChannelComponent: 0 flipbookRows: 1 @@ -74,7 +74,7 @@ TextureImporter: textureFormat: -1 textureCompression: 1 compressionQuality: 50 - crunchedCompression: 0 + crunchedCompression: 1 allowsAlphaSplitting: 0 overridden: 0 ignorePlatformSupport: 0 @@ -151,7 +151,7 @@ TextureImporter: outline: [] physicsShape: [] bones: [] - spriteID: + spriteID: 5e97eb03825dee720800000000000000 internalID: 0 vertices: [] indices: diff --git a/Assets/Scenes/ComputerView.unity b/Assets/Scenes/ComputerView.unity index ae760c4..559fe3c 100644 --- a/Assets/Scenes/ComputerView.unity +++ b/Assets/Scenes/ComputerView.unity @@ -294,6 +294,7 @@ RectTransform: - {fileID: 500028487} - {fileID: 619055281} - {fileID: 1798182258} + - {fileID: 1350310808} m_Father: {fileID: 610087870} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_AnchorMin: {x: 0, y: 0} @@ -636,10 +637,10 @@ RectTransform: m_Children: [] m_Father: {fileID: 6747543} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} - m_AnchorMin: {x: 0, y: 1} - m_AnchorMax: {x: 0, y: 1} - m_AnchoredPosition: {x: 150, y: -300} - m_SizeDelta: {x: 300, y: 200} + m_AnchorMin: {x: 0, y: 0} + m_AnchorMax: {x: 0, y: 0} + m_AnchoredPosition: {x: 0, y: 0} + m_SizeDelta: {x: 0, y: 0} m_Pivot: {x: 0.5, y: 0.5} --- !u!114 &132605380 MonoBehaviour: @@ -1231,10 +1232,10 @@ RectTransform: m_Children: [] m_Father: {fileID: 6747543} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} - m_AnchorMin: {x: 0, y: 1} - m_AnchorMax: {x: 0, y: 1} - m_AnchoredPosition: {x: 1050, y: -300} - m_SizeDelta: {x: 300, y: 200} + m_AnchorMin: {x: 0, y: 0} + m_AnchorMax: {x: 0, y: 0} + m_AnchoredPosition: {x: 0, y: 0} + m_SizeDelta: {x: 0, y: 0} m_Pivot: {x: 0, y: 0.5} --- !u!114 &340074661 MonoBehaviour: @@ -1374,6 +1375,7 @@ MonoBehaviour: - {fileID: 496953434} - {fileID: 2137991537} - {fileID: 340074661} + promptList: {fileID: 0} explanationPage: {fileID: 0} counter: {fileID: 0} waitingForPropositionsPage: {fileID: 1730465902} @@ -1588,10 +1590,10 @@ RectTransform: m_Children: [] m_Father: {fileID: 6747543} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} - m_AnchorMin: {x: 0, y: 1} - m_AnchorMax: {x: 0, y: 1} - m_AnchoredPosition: {x: 350, y: -300} - m_SizeDelta: {x: 300, y: 200} + m_AnchorMin: {x: 0, y: 0} + m_AnchorMax: {x: 0, y: 0} + m_AnchoredPosition: {x: 0, y: 0} + m_SizeDelta: {x: 0, y: 0} m_Pivot: {x: 0, y: 0.5} --- !u!114 &496953434 MonoBehaviour: @@ -3329,10 +3331,10 @@ RectTransform: m_Children: [] m_Father: {fileID: 6747543} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} - m_AnchorMin: {x: 0, y: 1} - m_AnchorMax: {x: 0, y: 1} - m_AnchoredPosition: {x: 1050, y: -100} - m_SizeDelta: {x: 300, y: 200} + m_AnchorMin: {x: 0, y: 0} + m_AnchorMax: {x: 0, y: 0} + m_AnchoredPosition: {x: 0, y: 0} + m_SizeDelta: {x: 0, y: 0} m_Pivot: {x: 0, y: 0.5} --- !u!114 &983174567 MonoBehaviour: @@ -3799,10 +3801,10 @@ RectTransform: m_Children: [] m_Father: {fileID: 6747543} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} - m_AnchorMin: {x: 0, y: 1} - m_AnchorMax: {x: 0, y: 1} - m_AnchoredPosition: {x: 700, y: -100} - m_SizeDelta: {x: 300, y: 200} + m_AnchorMin: {x: 0, y: 0} + m_AnchorMax: {x: 0, y: 0} + m_AnchoredPosition: {x: 0, y: 0} + m_SizeDelta: {x: 0, y: 0} m_Pivot: {x: 0, y: 0.5} --- !u!114 &1018720202 MonoBehaviour: @@ -4129,7 +4131,7 @@ GameObject: m_Icon: {fileID: 0} m_NavMeshLayer: 0 m_StaticEditorFlags: 0 - m_IsActive: 0 + m_IsActive: 1 --- !u!224 &1117928115 RectTransform: m_ObjectHideFlags: 0 @@ -5077,6 +5079,81 @@ CanvasRenderer: m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 1318111281} m_CullTransparentMesh: 0 +--- !u!1 &1350310807 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 1350310808} + - component: {fileID: 1350310810} + - component: {fileID: 1350310809} + m_Layer: 5 + m_Name: Logo + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!224 &1350310808 +RectTransform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1350310807} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_ConstrainProportionsScale: 0 + m_Children: [] + m_Father: {fileID: 45150985} + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} + m_AnchorMin: {x: 0.5, y: 0.5} + m_AnchorMax: {x: 0.5, y: 0.5} + m_AnchoredPosition: {x: 633, y: -188} + m_SizeDelta: {x: 559.7728, y: 559.7728} + m_Pivot: {x: 0.5, y: 0.5} +--- !u!114 &1350310809 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1350310807} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: fe87c0e1cc204ed48ad3b37840f39efc, type: 3} + m_Name: + m_EditorClassIdentifier: + m_Material: {fileID: 0} + m_Color: {r: 1, g: 1, b: 1, a: 1} + m_RaycastTarget: 1 + m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0} + m_Maskable: 1 + m_OnCullStateChanged: + m_PersistentCalls: + m_Calls: [] + m_Sprite: {fileID: 21300000, guid: 93cf115964d3bfa45ba83a1f465565f0, type: 3} + m_Type: 0 + m_PreserveAspect: 0 + m_FillCenter: 1 + m_FillMethod: 4 + m_FillAmount: 1 + m_FillClockwise: 1 + m_FillOrigin: 0 + m_UseSpriteMesh: 0 + m_PixelsPerUnitMultiplier: 1 +--- !u!222 &1350310810 +CanvasRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1350310807} + m_CullTransparentMesh: 1 --- !u!1 &1374681047 GameObject: m_ObjectHideFlags: 0 @@ -5416,10 +5493,10 @@ RectTransform: m_Children: [] m_Father: {fileID: 6747543} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} - m_AnchorMin: {x: 0, y: 1} - m_AnchorMax: {x: 0, y: 1} - m_AnchoredPosition: {x: 350, y: -100} - m_SizeDelta: {x: 300, y: 200} + m_AnchorMin: {x: 0, y: 0} + m_AnchorMax: {x: 0, y: 0} + m_AnchoredPosition: {x: 0, y: 0} + m_SizeDelta: {x: 0, y: 0} m_Pivot: {x: 0, y: 0.5} --- !u!114 &1452182577 MonoBehaviour: @@ -6343,10 +6420,10 @@ RectTransform: m_Children: [] m_Father: {fileID: 6747543} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} - m_AnchorMin: {x: 0, y: 1} - m_AnchorMax: {x: 0, y: 1} - m_AnchoredPosition: {x: 150, y: -100} - m_SizeDelta: {x: 300, y: 200} + m_AnchorMin: {x: 0, y: 0} + m_AnchorMax: {x: 0, y: 0} + m_AnchoredPosition: {x: 0, y: 0} + m_SizeDelta: {x: 0, y: 0} m_Pivot: {x: 0.5, y: 0.5} --- !u!114 &1794849355 MonoBehaviour: @@ -8181,10 +8258,10 @@ RectTransform: m_Children: [] m_Father: {fileID: 6747543} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} - m_AnchorMin: {x: 0, y: 1} - m_AnchorMax: {x: 0, y: 1} - m_AnchoredPosition: {x: 700, y: -300} - m_SizeDelta: {x: 300, y: 200} + m_AnchorMin: {x: 0, y: 0} + m_AnchorMax: {x: 0, y: 0} + m_AnchoredPosition: {x: 0, y: 0} + m_SizeDelta: {x: 0, y: 0} m_Pivot: {x: 0, y: 0.5} --- !u!114 &2137991537 MonoBehaviour: