diff --git a/Assets/Scenes/PhoneView.unity b/Assets/Scenes/PhoneView.unity index 8fa58c3..f7f6492 100644 --- a/Assets/Scenes/PhoneView.unity +++ b/Assets/Scenes/PhoneView.unity @@ -1049,7 +1049,7 @@ GameObject: m_Icon: {fileID: 0} m_NavMeshLayer: 0 m_StaticEditorFlags: 0 - m_IsActive: 1 + m_IsActive: 0 --- !u!224 &638947074 RectTransform: m_ObjectHideFlags: 0 @@ -1113,7 +1113,19 @@ MonoBehaviour: m_TargetGraphic: {fileID: 638947076} m_OnClick: m_PersistentCalls: - m_Calls: [] + m_Calls: + - m_Target: {fileID: 1202782732} + m_TargetAssemblyTypeName: GameManager, Assembly-CSharp + m_MethodName: StartGame + m_Mode: 1 + m_Arguments: + m_ObjectArgument: {fileID: 0} + m_ObjectArgumentAssemblyTypeName: UnityEngine.Object, UnityEngine + m_IntArgument: 0 + m_FloatArgument: 0 + m_StringArgument: + m_BoolArgument: 0 + m_CallState: 2 --- !u!114 &638947076 MonoBehaviour: m_ObjectHideFlags: 0 @@ -2105,6 +2117,140 @@ Transform: m_Children: [] m_Father: {fileID: 0} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!1 &991600091 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 991600092} + - component: {fileID: 991600094} + - component: {fileID: 991600093} + m_Layer: 5 + m_Name: ErrorCodeLabel + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 0 +--- !u!224 &991600092 +RectTransform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 991600091} + 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: 2023851069} + 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: 2.9758, y: 20.4609} + m_SizeDelta: {x: 154.05, y: 13.5401} + m_Pivot: {x: 0.5, y: 0.5} +--- !u!114 &991600093 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 991600091} + 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: 'Error: the room code is invalide' + 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: 4278190335 + m_fontColor: {r: 1, g: 0, 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: 11.43 + m_fontSizeBase: 11.43 + m_fontWeight: 400 + m_enableAutoSizing: 0 + m_fontSizeMin: 18 + m_fontSizeMax: 72 + m_fontStyle: 0 + m_HorizontalAlignment: 1 + m_VerticalAlignment: 256 + 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.000000025251643, 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 &991600094 +CanvasRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 991600091} + m_CullTransparentMesh: 1 --- !u!1 &1034781733 GameObject: m_ObjectHideFlags: 0 @@ -2596,7 +2742,19 @@ MonoBehaviour: m_TargetGraphic: {fileID: 1158329300} m_OnClick: m_PersistentCalls: - m_Calls: [] + m_Calls: + - m_Target: {fileID: 1202782732} + m_TargetAssemblyTypeName: GameManager, Assembly-CSharp + m_MethodName: PlayerValidateNameAndServerRoom + m_Mode: 1 + m_Arguments: + m_ObjectArgument: {fileID: 0} + m_ObjectArgumentAssemblyTypeName: UnityEngine.Object, UnityEngine + m_IntArgument: 0 + m_FloatArgument: 0 + m_StringArgument: + m_BoolArgument: 0 + m_CallState: 2 --- !u!114 &1158329300 MonoBehaviour: m_ObjectHideFlags: 0 @@ -2668,6 +2826,7 @@ RectTransform: m_Children: - {fileID: 1288753599} - {fileID: 1770783105} + - {fileID: 1224049645} m_Father: {fileID: 2027556832} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_AnchorMin: {x: 0.5, y: 0.5} @@ -2958,7 +3117,7 @@ GameObject: - component: {fileID: 1202782729} - component: {fileID: 1202782728} - component: {fileID: 1202782727} - - component: {fileID: 1202782731} + - component: {fileID: 1202782732} m_Layer: 5 m_Name: Canvas m_TagString: Untagged @@ -3049,7 +3208,7 @@ RectTransform: m_AnchoredPosition: {x: 0, y: 0} m_SizeDelta: {x: 0, y: 0} m_Pivot: {x: 0, y: 0} ---- !u!114 &1202782731 +--- !u!114 &1202782732 MonoBehaviour: m_ObjectHideFlags: 0 m_CorrespondingSourceObject: {fileID: 0} @@ -3058,9 +3217,160 @@ MonoBehaviour: m_GameObject: {fileID: 1202782726} m_Enabled: 1 m_EditorHideFlags: 0 - m_Script: {fileID: 11500000, guid: 77ca3ece4774c244e96dcee6ab926fbb, type: 3} + m_Script: {fileID: 11500000, guid: 27a435387a7644784a6fc6ae538b68e5, type: 3} m_Name: m_EditorClassIdentifier: + isRoomExist: 1 + isPlayerExist: 1 + explanationTime: 4 + roomCodeField: {fileID: 2023851070} + roomError: {fileID: 991600093} + playerNameField: {fileID: 1163479463} + nameError: {fileID: 1224049646} + submitNewPlayer: {fileID: 1158329299} + listPlayersUI: {fileID: 1891690322} + submitStartGame: {fileID: 638947073} + HomeConnection: {fileID: 2027556831} + WaitingRoom: {fileID: 1590939977} + BeforeStart: {fileID: 563000513} + TakePicture: {fileID: 1181392805} + VotePicture: {fileID: 531335861} + WaitingOtherPlayers: {fileID: 2095389711} + EndGame: {fileID: 1850164816} +--- !u!1 &1224049644 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 1224049645} + - component: {fileID: 1224049647} + - component: {fileID: 1224049646} + m_Layer: 5 + m_Name: ErrorNameLabel + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 0 +--- !u!224 &1224049645 +RectTransform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1224049644} + m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1.0029413, y: 1.0029413, z: 0.8627451} + m_ConstrainProportionsScale: 0 + m_Children: [] + m_Father: {fileID: 1163479462} + 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: 2.9845557, y: 18.5} + m_SizeDelta: {x: 154.05, y: 13.5401} + m_Pivot: {x: 0.5, y: 0.5} +--- !u!114 &1224049646 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1224049644} + 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: 'Error: only numbers and letters' + 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: 4278190335 + m_fontColor: {r: 1, g: 0, 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: 11.43 + m_fontSizeBase: 11.43 + m_fontWeight: 400 + m_enableAutoSizing: 0 + m_fontSizeMin: 18 + m_fontSizeMax: 72 + m_fontStyle: 0 + m_HorizontalAlignment: 1 + m_VerticalAlignment: 256 + 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.000000025251643, 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 &1224049647 +CanvasRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1224049644} + m_CullTransparentMesh: 1 --- !u!1 &1266773203 GameObject: m_ObjectHideFlags: 0 @@ -4703,8 +5013,8 @@ RectTransform: 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: 0, y: -38.8} - m_SizeDelta: {x: 200, y: 50} + m_AnchoredPosition: {x: 2.8591, y: -36.5711} + m_SizeDelta: {x: 194.2818, y: 45.5423} m_Pivot: {x: 0.5, y: 0.5} --- !u!114 &1770783106 MonoBehaviour: @@ -5610,6 +5920,7 @@ RectTransform: m_ConstrainProportionsScale: 1 m_Children: - {fileID: 2008743696} + - {fileID: 991600092} m_Father: {fileID: 2027556832} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_AnchorMin: {x: 0.5, y: 0.5} @@ -5768,7 +6079,7 @@ GameObject: m_Icon: {fileID: 0} m_NavMeshLayer: 0 m_StaticEditorFlags: 0 - m_IsActive: 1 + m_IsActive: 0 --- !u!224 &2027556832 RectTransform: m_ObjectHideFlags: 0 diff --git a/Assets/ScriptableObjects/PromptList.asset b/Assets/ScriptableObjects/PromptList.asset index b1b69e2..5cbe679 100644 --- a/Assets/ScriptableObjects/PromptList.asset +++ b/Assets/ScriptableObjects/PromptList.asset @@ -22,3 +22,86 @@ MonoBehaviour: - k__BackingField: 48017744-4552-487a-817a-abd5d03bbbc0 k__BackingField: elle k__BackingField: elle + - k__BackingField: cef08696-352b-4003-85ff-2864996e9949 + k__BackingField: Jacque chirac + k__BackingField: Jacque chirac + - k__BackingField: ecc8ffb1-1965-4169-bd67-b22a9d321951 + k__BackingField: "La 7\xE9me guerre mondiale" + k__BackingField: The 7th world war + - k__BackingField: c3a3c511-a4dc-477e-a04c-76e0b8778fb8 + k__BackingField: Le sujet de ton prochain roman + k__BackingField: The subject of your next novel + - k__BackingField: 4512b17b-454a-481d-b7d4-4765a7f9d23f + k__BackingField: Le futur + k__BackingField: The futur + - k__BackingField: 3e1ec191-9a90-414d-b52e-ac2eb09eebcc + k__BackingField: Le plus vieux + k__BackingField: The oldest + - k__BackingField: 177e7d67-81fc-42b9-ad0c-efa2fe46425a + k__BackingField: "L'\xE9tat de votre gouvernement" + k__BackingField: The state of your government + - k__BackingField: 29c11342-a9fb-4067-b94e-37b292a830d3 + k__BackingField: Dieu + k__BackingField: God + - k__BackingField: 636c16ec-a52b-449f-997c-833c0f8ddf3f + k__BackingField: Le plus petit + k__BackingField: the smallest + - k__BackingField: 64c6279b-0b91-4c2d-9fd4-7e2873172315 + k__BackingField: Le meilleur d'entre nous + k__BackingField: The best of us + - k__BackingField: 9bd4b867-952b-432b-ba66-de9425e4407c + k__BackingField: L'objet le plus doux + k__BackingField: The softest object + - k__BackingField: 7954f378-e003-4a37-8d88-4f92dd9e2afd + k__BackingField: "Un super h\xE9ros" + k__BackingField: A super hero + - k__BackingField: 7f999932-6d98-4c8b-a89b-a335deb0f286 + k__BackingField: Le dernier lien de votre historique internet + k__BackingField: The last link in your internet history + - k__BackingField: e484bb00-291c-4e65-9810-4a11dd0ef57a + k__BackingField: 'Votre passe temps du moment ' + k__BackingField: Your current hobby + - k__BackingField: f91b8236-a6d0-43b7-ae6b-272f36a928c7 + k__BackingField: 'Une jojo pose ' + k__BackingField: A jojo pose + - k__BackingField: a7715b73-8fa2-4073-8e80-768ceceb6c6b + k__BackingField: La nature + k__BackingField: The nature + - k__BackingField: 26ca8ef5-2698-40f2-ac35-9829a3d1c9c0 + k__BackingField: "Cette chose qui vous \xE9nerve un peut" + k__BackingField: That thing that annoys you a little + - k__BackingField: 43e166bb-3ec1-419a-a445-609149a4e62f + k__BackingField: "Une id\xE9e lumineuse" + k__BackingField: A bright idea + - k__BackingField: a502c6c8-d946-449e-b494-2ffc59dc99d9 + k__BackingField: La plus grande star au monde + k__BackingField: 'The biggest star in the world ' + - k__BackingField: b82a8b15-ec9b-4a11-8962-e87994b3c829 + k__BackingField: "Une t\xE9l\xE9commande universel" + k__BackingField: A universal remote control + - k__BackingField: 272fe8c2-4bf2-4ad0-bdb4-fc65d16ae768 + k__BackingField: Un beau bateau + k__BackingField: A nice boat + - k__BackingField: 50f2338f-764d-4ef3-992e-8f632a71ad53 + k__BackingField: Youtube actuellement + k__BackingField: Youtube actually + - k__BackingField: fb09b646-9f27-49fd-9e3f-781b5b915cb2 + k__BackingField: Rond comme un ballon + k__BackingField: 'Round like a balloon ' + - k__BackingField: 59622776-9661-4220-9beb-7e3562a79fe1 + k__BackingField: Qui rend heureux + k__BackingField: Who makes you happy + - k__BackingField: a05ec722-a4a5-4cfa-84ba-464309f3aa1f + k__BackingField: Tortue ninja + k__BackingField: Ninja Turtle + - k__BackingField: f57b973c-d755-42b0-a0f7-48ee2bfa5238 + k__BackingField: Un pokemon + k__BackingField: A pokemon + - k__BackingField: 0eb7bac8-993c-4beb-9fd5-c1136bb337b0 + k__BackingField: "Votre humeur apr\xE8s avoir vue les derni\xE8res nouvelles + sur un de vos r\xE9saux sociaux" + k__BackingField: Your mood after seeing the latest news on one of your social + networks + - k__BackingField: 598d0c4f-da47-4182-946c-c4704f9c8f0b + k__BackingField: La meilleure boisson + k__BackingField: The best drink diff --git a/Assets/Scripts/GameManager.cs b/Assets/Scripts/GameManager.cs index bf2233e..e11fb65 100644 --- a/Assets/Scripts/GameManager.cs +++ b/Assets/Scripts/GameManager.cs @@ -1,3 +1,4 @@ +using System; using System.Collections; using System.Collections.Generic; using Firebase.Database; @@ -5,6 +6,7 @@ using TMPro; using UnityEngine; using UnityEngine.UI; +using UnityEngine.UIElements; /// /// This is the game state manager on the phone side @@ -14,13 +16,45 @@ public class GameManager : MonoBehaviour private GameState currentState; private List players = new List(); + [Header("Temp variables")] + public bool isRoomExist = true; + public bool isPlayerExist = true; + + + [Header("Other component")] public float explanationTime = 4f; private float currentExplanationTime = 0; - public InputField roomCodeField; + [Header("Home Component")] + public TMP_InputField roomCodeField; public TextMeshProUGUI roomError; - public InputField playerNameField; + public TMP_InputField playerNameField; public TextMeshProUGUI nameError; + public UnityEngine.UI.Button submitNewPlayer; + + + [Header("WaitingRoom Component")] + public TextMeshProUGUI listPlayersUI; + public GameObject submitStartGame; + + + [Header("Pages")] + [SerializeField] + public GameObject HomeConnection; + [SerializeField] + public GameObject WaitingRoom; + [SerializeField] + public GameObject BeforeStart; + [SerializeField] + public GameObject TakePicture; + [SerializeField] + public GameObject VotePicture; + [SerializeField] + public GameObject WaitingOtherPlayers; + [SerializeField] + public GameObject EndGame; + + private DatabaseReference realtimeDB; private Room myRoom; @@ -33,6 +67,7 @@ private void Awake() private void Start() { currentExplanationTime = explanationTime; + HomeConnection.SetActive(true); } public GameState GetCurrentState() @@ -77,11 +112,63 @@ public void PlayerValidateNameAndServerRoom(string _name, string _code) } } }); + string playerName = playerNameField.text; + string roomCode = roomCodeField.text; + + // send to the server the room code and the player name + + // MORGANE ENVOIE AU SERV + + // answer isPlayerExist and isRoomExist //if succeed, then the player to the server + if (isPlayerExist && isRoomExist) + { + currentState = GameState.WaitingForOtherPlayersToJoin; + WaitingRoom.SetActive(true); + HomeConnection.SetActive(false); + + + //TEMP + Player player = new Player(); + player.SetName(playerName); + player.id = "1"; + + players.Add(player); + if (players.Count == 1) + { + submitStartGame.SetActive(true); + } + + Player player2 = new Player(); + player2.SetName("3J"); + player2.id = "2"; + Player player3 = new Player(); + player3.SetName("3J"); + player3.id = "3"; + Player player4 = new Player(); + player4.SetName("3J"); + player4.id = "4"; + Player player5 = new Player(); + player5.SetName("3J"); + player5.id = "5"; + Player player6 = new Player(); + player6.SetName("3J"); + player6.id = "6"; + + + players.Add(player2); + players.Add(player3); + players.Add(player4); + players.Add(player5); + players.Add(player6); + UpdateDisplayedListUser(); + } + // else we show the errors + roomError.gameObject.SetActive(!isRoomExist); + nameError.gameObject.SetActive(!isPlayerExist); + - //if succeed, change the state and change page - currentState = GameState.WaitingForOtherPlayersToJoin; } /// @@ -89,6 +176,12 @@ public void PlayerValidateNameAndServerRoom(string _name, string _code) /// public void StartGame() { + // send Start Game + + currentState = GameState.Explanation; + WaitingRoom.SetActive(false); + BeforeStart.SetActive(true); + } @@ -99,7 +192,9 @@ public void StartGame() /// The prompt to display public void MakeAProposition(Prompt _prompt) { + currentState = GameState.MakeProposition; + } /// @@ -143,7 +238,25 @@ public void DisplayEndScreen() private void OnRoomUpdate(object sender, ChildChangedEventArgs e) { myRoom = JsonUtility.FromJson(e.Snapshot.GetRawJsonValue()); + switch (currentState) + { + case GameState.WaitingForOtherPlayersToJoin: + { + // players = new list en fonction de ce qu'envoie fangh + UpdateDisplayedListUser(); + break; + } + } + } + + private void UpdateDisplayedListUser() + { + listPlayersUI.text = string.Empty; + for (int i = 0; i < players.Count; i++) + { + listPlayersUI.text += "\n" + players[i].name; + } } } diff --git a/Assets/Scripts/PhoneLoop.cs b/Assets/Scripts/PhoneLoop.cs index e29bcbd..0580aec 100644 --- a/Assets/Scripts/PhoneLoop.cs +++ b/Assets/Scripts/PhoneLoop.cs @@ -1,13 +1,31 @@ using System.Collections; using System.Collections.Generic; +using Unity.VisualScripting; using UnityEngine; public class PhoneLoop : MonoBehaviour { + + + [SerializeField] + public GameObject homeConnection; + [SerializeField] + public GameObject WaitingRoom; + [SerializeField] + public GameObject BeforeStart; + [SerializeField] + public GameObject TakePicture; + [SerializeField] + public GameObject VotePicture; + [SerializeField] + public GameObject WaitingOtherPlayers; + [SerializeField] + public GameObject EndGame; + // Start is called before the first frame update void Start() { - + homeConnection.SetActive(true); } // Update is called once per frame @@ -15,4 +33,69 @@ void Update() { } + + void ShowWaititngRoom() + { + homeConnection.SetActive(false); + WaitingRoom.SetActive(true); + } + + void ShowBeforeStart() + { + WaitingRoom.SetActive(false); + BeforeStart.SetActive(true); + } + + void ShowTakePicture() + { + BeforeStart.SetActive(false); + TakePicture.SetActive(true); + } + + void showWaitingOtherPlayers() + { + if (TakePicture.activeInHierarchy) + { + TakePicture.SetActive(false); + } + if (VotePicture.activeInHierarchy) + { + VotePicture.SetActive(false); + } + WaitingOtherPlayers.SetActive(true); + } + + void ShowVotePicture() + { + + if (TakePicture.activeInHierarchy) + { + TakePicture.SetActive(false); + } + if (WaitingOtherPlayers.activeInHierarchy) + { + WaitingOtherPlayers.SetActive(false); + } + VotePicture.SetActive(true); + + } + + void ShowEndGame() + { + WaitingOtherPlayers.SetActive(false) ; + EndGame.SetActive(true); + + } + + + + [ContextMenu("Fake Player Connection")] + private void FakePlayerConnection() + { + + } + + + + }