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 c6a8073..26942e1 100644 --- a/Assets/Scenes/ComputerView.unity +++ b/Assets/Scenes/ComputerView.unity @@ -263,6 +263,45 @@ 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} + - {fileID: 1350310808} + 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 @@ -1336,6 +1375,9 @@ MonoBehaviour: - {fileID: 496953434} - {fileID: 2137991537} - {fileID: 340074661} + promptList: {fileID: 0} + explanationPage: {fileID: 0} + counter: {fileID: 0} waitingForPropositionsPage: {fileID: 1730465902} waitingForPropositionsLabels: - {fileID: 972471162} @@ -1650,6 +1692,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 @@ -1903,6 +2017,7 @@ RectTransform: m_ConstrainProportionsScale: 0 m_Children: - {fileID: 1117928115} + - {fileID: 45150985} - {fileID: 1730465903} - {fileID: 1660260834} - {fileID: 1451481718} @@ -1914,6 +2029,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 @@ -4829,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 @@ -5765,7 +6090,7 @@ 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 @@ -6197,6 +6522,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 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/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 b711e5a..437117b 100644 --- a/Assets/Scripts/GameManager.cs +++ b/Assets/Scripts/GameManager.cs @@ -15,7 +15,6 @@ public class GameManager : MonoBehaviour private List players = new(); private bool isFirst = false; 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 88a55fb..f046b60 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 @@ -17,7 +16,12 @@ public class RoomManager : MonoBehaviour /// public TextMeshProUGUI roomCodeLabel; 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; @@ -58,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++) { @@ -72,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() @@ -138,7 +160,6 @@ public void CreateNewRoom() { WhichCodesAreAlreadyUsed(codes => { - Debug.Log("coucou"); Room newRoom = new Room(GenerateRandomAvailableCode(codes).ToString("D4")); myRoom = newRoom; try @@ -234,22 +255,51 @@ 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(myRoom.players.Count() * 2).ToList(); + List fullPlayers = myRoom.players.Values.ToList().Concat(myRoom.players.Values.ToList()).OrderBy(x => rnd.Next()).ToList(); + Dictionary questions = new(); - } + foreach (Prompt prompt in prompts) + { + Dictionary propositions = new(); + Player basePlayer = fullPlayers[0]; - /// - /// Generate all the player pairs - /// (players should not play against themself. - /// (players should not play twice with the same person) - /// - public void GenerateCouples() - { + propositions.Add(Guid.NewGuid().ToString(), new Proposition() + { + owner = basePlayer, + creationDate = DateTime.Now.ToOADate() + }); + 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, + creationDate = DateTime.Now.ToOADate() + }); + + 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); } /// @@ -279,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; @@ -293,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++) {