diff --git a/Assets/Scenes/ComputerView.unity b/Assets/Scenes/ComputerView.unity index daf72aa..21a31da 100644 --- a/Assets/Scenes/ComputerView.unity +++ b/Assets/Scenes/ComputerView.unity @@ -38,7 +38,7 @@ RenderSettings: m_ReflectionIntensity: 1 m_CustomReflection: {fileID: 0} m_Sun: {fileID: 705507994} - m_IndirectSpecularColor: {r: 0.18018535, g: 0.22559482, b: 0.30677685, a: 1} + m_IndirectSpecularColor: {r: 0.18028378, g: 0.22571412, b: 0.30692285, a: 1} m_UseRadianceAmbientProbe: 0 --- !u!157 &3 LightmapSettings: @@ -812,7 +812,7 @@ MonoBehaviour: m_text: 01234567890123456 m_isRightToLeft: 0 m_fontAsset: {fileID: 11400000, guid: 72af27804d5aa49408430b4b2500f877, type: 2} - m_sharedMaterial: {fileID: 8890805173838430465, guid: 72af27804d5aa49408430b4b2500f877, type: 2} + m_sharedMaterial: {fileID: 2100000, guid: 9fb4d071241c54841ab116886c83b585, type: 2} m_fontSharedMaterials: [] m_fontMaterial: {fileID: 0} m_fontMaterials: [] @@ -836,8 +836,8 @@ MonoBehaviour: m_faceColor: serializedVersion: 2 rgba: 4294967295 - m_fontSize: 32 - m_fontSizeBase: 32 + m_fontSize: 44 + m_fontSizeBase: 44 m_fontWeight: 400 m_enableAutoSizing: 0 m_fontSizeMin: 0 @@ -1031,6 +1031,7 @@ GameObject: - component: {fileID: 157938956} - component: {fileID: 157938958} - component: {fileID: 157938959} + - component: {fileID: 157938960} m_Layer: 5 m_Name: Timer m_TagString: Untagged @@ -1086,7 +1087,7 @@ MonoBehaviour: m_OnCullStateChanged: m_PersistentCalls: m_Calls: [] - m_Sprite: {fileID: 21300000, guid: 141de4e4cebc12c489ea471b0df36fd8, type: 3} + m_Sprite: {fileID: 21300000, guid: 8ce21f9a93b91764ea7ce3f5f295c927, type: 3} m_Type: 0 m_PreserveAspect: 0 m_FillCenter: 1 @@ -1096,6 +1097,21 @@ MonoBehaviour: m_FillOrigin: 0 m_UseSpriteMesh: 0 m_PixelsPerUnitMultiplier: 1 +--- !u!114 &157938960 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 157938955} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: cfabb0440166ab443bba8876756fdfa9, type: 3} + m_Name: + m_EditorClassIdentifier: + m_EffectColor: {r: 0, g: 0, b: 0, a: 0.5} + m_EffectDistance: {x: 10, y: -10} + m_UseGraphicAlpha: 1 --- !u!1 &183264014 GameObject: m_ObjectHideFlags: 0 @@ -1825,18 +1841,7 @@ MonoBehaviour: explanationCounter: {fileID: 1798182259} explanationTime: 4 counterSFX: {fileID: 8300000, guid: 2ff45dbe56b6a4d08bfa7b103fa4effb, type: 3} - waitingForPropositionsPage: {fileID: 1730465902} - propositionCounter: {fileID: 1996258852} - propositionTime: 60 - waitingForPropositionsLabels: - - {fileID: 972471162} - - {fileID: 1374681049} - - {fileID: 1141337197} - - {fileID: 130058895} - - {fileID: 680005431} - - {fileID: 1854893636} - - {fileID: 2065109614} - - {fileID: 1197279072} + waitForPropositionsPage: {fileID: 1730465904} votingPage: {fileID: 1660260835} promptList: {fileID: 11400000, guid: 21907abc84e40403ca34c4fb9ab30b06, type: 2} --- !u!114 &375256413 @@ -3116,7 +3121,7 @@ MonoBehaviour: m_text: 01234567890123456 m_isRightToLeft: 0 m_fontAsset: {fileID: 11400000, guid: 72af27804d5aa49408430b4b2500f877, type: 2} - m_sharedMaterial: {fileID: 8890805173838430465, guid: 72af27804d5aa49408430b4b2500f877, type: 2} + m_sharedMaterial: {fileID: 2100000, guid: 9fb4d071241c54841ab116886c83b585, type: 2} m_fontSharedMaterials: [] m_fontMaterial: {fileID: 0} m_fontMaterials: [] @@ -3140,8 +3145,8 @@ MonoBehaviour: m_faceColor: serializedVersion: 2 rgba: 4294967295 - m_fontSize: 32 - m_fontSizeBase: 32 + m_fontSize: 44 + m_fontSizeBase: 44 m_fontWeight: 400 m_enableAutoSizing: 0 m_fontSizeMin: 0 @@ -3917,7 +3922,7 @@ MonoBehaviour: m_text: 01234567890123456 m_isRightToLeft: 0 m_fontAsset: {fileID: 11400000, guid: 72af27804d5aa49408430b4b2500f877, type: 2} - m_sharedMaterial: {fileID: 8890805173838430465, guid: 72af27804d5aa49408430b4b2500f877, type: 2} + m_sharedMaterial: {fileID: 2100000, guid: 9fb4d071241c54841ab116886c83b585, type: 2} m_fontSharedMaterials: [] m_fontMaterial: {fileID: 0} m_fontMaterials: [] @@ -3941,8 +3946,8 @@ MonoBehaviour: m_faceColor: serializedVersion: 2 rgba: 4294967295 - m_fontSize: 32 - m_fontSizeBase: 32 + m_fontSize: 44 + m_fontSizeBase: 44 m_fontWeight: 400 m_enableAutoSizing: 0 m_fontSizeMin: 0 @@ -4166,7 +4171,7 @@ RectTransform: 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_AnchoredPosition: {x: 0, y: -47} m_SizeDelta: {x: -200, y: -200} m_Pivot: {x: 0.5, y: 0.5} --- !u!114 &987875883 @@ -5020,7 +5025,7 @@ MonoBehaviour: m_text: 01234567890123456 m_isRightToLeft: 0 m_fontAsset: {fileID: 11400000, guid: 72af27804d5aa49408430b4b2500f877, type: 2} - m_sharedMaterial: {fileID: 8890805173838430465, guid: 72af27804d5aa49408430b4b2500f877, type: 2} + m_sharedMaterial: {fileID: 2100000, guid: 9fb4d071241c54841ab116886c83b585, type: 2} m_fontSharedMaterials: [] m_fontMaterial: {fileID: 0} m_fontMaterials: [] @@ -5044,8 +5049,8 @@ MonoBehaviour: m_faceColor: serializedVersion: 2 rgba: 4294967295 - m_fontSize: 32 - m_fontSizeBase: 32 + m_fontSize: 44 + m_fontSizeBase: 44 m_fontWeight: 400 m_enableAutoSizing: 0 m_fontSizeMin: 0 @@ -5151,10 +5156,10 @@ MonoBehaviour: m_OnCullStateChanged: m_PersistentCalls: m_Calls: [] - m_text: waiting for player pictures + m_text: waiting for players pictures... m_isRightToLeft: 0 m_fontAsset: {fileID: 11400000, guid: 72af27804d5aa49408430b4b2500f877, type: 2} - m_sharedMaterial: {fileID: 8890805173838430465, guid: 72af27804d5aa49408430b4b2500f877, type: 2} + m_sharedMaterial: {fileID: 2100000, guid: 9fb4d071241c54841ab116886c83b585, type: 2} m_fontSharedMaterials: [] m_fontMaterial: {fileID: 0} m_fontMaterials: [] @@ -5288,7 +5293,7 @@ MonoBehaviour: m_text: 01234567890123456 m_isRightToLeft: 0 m_fontAsset: {fileID: 11400000, guid: 72af27804d5aa49408430b4b2500f877, type: 2} - m_sharedMaterial: {fileID: 8890805173838430465, guid: 72af27804d5aa49408430b4b2500f877, type: 2} + m_sharedMaterial: {fileID: 2100000, guid: 9fb4d071241c54841ab116886c83b585, type: 2} m_fontSharedMaterials: [] m_fontMaterial: {fileID: 0} m_fontMaterials: [] @@ -5312,8 +5317,8 @@ MonoBehaviour: m_faceColor: serializedVersion: 2 rgba: 4294967295 - m_fontSize: 32 - m_fontSizeBase: 32 + m_fontSize: 44 + m_fontSizeBase: 44 m_fontWeight: 400 m_enableAutoSizing: 0 m_fontSizeMin: 0 @@ -6204,7 +6209,7 @@ MonoBehaviour: m_text: 01234567890123456 m_isRightToLeft: 0 m_fontAsset: {fileID: 11400000, guid: 72af27804d5aa49408430b4b2500f877, type: 2} - m_sharedMaterial: {fileID: 8890805173838430465, guid: 72af27804d5aa49408430b4b2500f877, type: 2} + m_sharedMaterial: {fileID: 2100000, guid: 9fb4d071241c54841ab116886c83b585, type: 2} m_fontSharedMaterials: [] m_fontMaterial: {fileID: 0} m_fontMaterials: [] @@ -6228,8 +6233,8 @@ MonoBehaviour: m_faceColor: serializedVersion: 2 rgba: 4294967295 - m_fontSize: 32 - m_fontSizeBase: 32 + m_fontSize: 44 + m_fontSizeBase: 44 m_fontWeight: 400 m_enableAutoSizing: 0 m_fontSizeMin: 0 @@ -7415,6 +7420,7 @@ GameObject: serializedVersion: 6 m_Component: - component: {fileID: 1730465903} + - component: {fileID: 1730465904} m_Layer: 5 m_Name: WaitingForPropositionPage m_TagString: Untagged @@ -7446,6 +7452,29 @@ RectTransform: m_AnchoredPosition: {x: 0, y: 0} m_SizeDelta: {x: 0, y: 0} m_Pivot: {x: 0.5, y: 0.5} +--- !u!114 &1730465904 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1730465902} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 64daf56939ea63b4b80e588da220e61b, type: 3} + m_Name: + m_EditorClassIdentifier: + propositionCounter: {fileID: 1996258852} + propositionTime: 60 + playerLabels: + - {fileID: 972471162} + - {fileID: 1374681049} + - {fileID: 1141337197} + - {fileID: 130058895} + - {fileID: 680005431} + - {fileID: 1854893636} + - {fileID: 2065109614} + - {fileID: 1197279072} --- !u!1 &1730898850 GameObject: m_ObjectHideFlags: 0 @@ -7478,11 +7507,11 @@ RectTransform: m_Children: [] m_Father: {fileID: 1730465903} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} - m_AnchorMin: {x: 1, y: 0} + m_AnchorMin: {x: 0, y: 0} m_AnchorMax: {x: 1, y: 0} - m_AnchoredPosition: {x: -60, y: 185} - m_SizeDelta: {x: 200, y: 50} - m_Pivot: {x: 1, y: 0} + m_AnchoredPosition: {x: 0, y: 50} + m_SizeDelta: {x: 0, y: 100} + m_Pivot: {x: 0.5, y: 0} --- !u!114 &1730898852 MonoBehaviour: m_ObjectHideFlags: 0 @@ -7505,15 +7534,15 @@ MonoBehaviour: m_Calls: [] m_text: Don't forget that one sentence can be interpreted in many different ways! m_isRightToLeft: 0 - m_fontAsset: {fileID: 11400000, guid: 8f586378b4e144a9851e7b34d9b748ee, type: 2} - m_sharedMaterial: {fileID: 2180264, guid: 8f586378b4e144a9851e7b34d9b748ee, type: 2} + m_fontAsset: {fileID: 11400000, guid: 72af27804d5aa49408430b4b2500f877, type: 2} + m_sharedMaterial: {fileID: 2100000, guid: 9fb4d071241c54841ab116886c83b585, type: 2} m_fontSharedMaterials: [] m_fontMaterial: {fileID: 0} m_fontMaterials: [] m_fontColor32: serializedVersion: 2 - rgba: 4278190080 - m_fontColor: {r: 0, g: 0, b: 0, a: 1} + rgba: 4278250751 + m_fontColor: {r: 1, g: 0.9271426, b: 0, a: 1} m_enableVertexGradient: 0 m_colorMode: 3 m_fontColorGradient: @@ -7530,15 +7559,15 @@ MonoBehaviour: m_faceColor: serializedVersion: 2 rgba: 4294967295 - m_fontSize: 36 - m_fontSizeBase: 36 + m_fontSize: 54 + m_fontSizeBase: 54 m_fontWeight: 400 m_enableAutoSizing: 0 m_fontSizeMin: 18 m_fontSizeMax: 72 m_fontStyle: 0 m_HorizontalAlignment: 2 - m_VerticalAlignment: 256 + m_VerticalAlignment: 512 m_textAlignment: 65535 m_characterSpacing: 0 m_wordSpacing: 0 @@ -7566,7 +7595,7 @@ MonoBehaviour: m_VertexBufferAutoSizeReduction: 0 m_useMaxVisibleDescender: 1 m_pageToDisplay: 1 - m_margin: {x: -249.66222, y: 0, z: 0, w: -103.841736} + m_margin: {x: 0, y: 0, z: 0, w: 0} m_isUsingLegacyAnimationComponent: 0 m_isVolumetricText: 0 m_hasFontAssetChanged: 0 @@ -8588,7 +8617,7 @@ MonoBehaviour: m_text: 01234567890123456 m_isRightToLeft: 0 m_fontAsset: {fileID: 11400000, guid: 72af27804d5aa49408430b4b2500f877, type: 2} - m_sharedMaterial: {fileID: 8890805173838430465, guid: 72af27804d5aa49408430b4b2500f877, type: 2} + m_sharedMaterial: {fileID: 2100000, guid: 9fb4d071241c54841ab116886c83b585, type: 2} m_fontSharedMaterials: [] m_fontMaterial: {fileID: 0} m_fontMaterials: [] @@ -8612,8 +8641,8 @@ MonoBehaviour: m_faceColor: serializedVersion: 2 rgba: 4294967295 - m_fontSize: 32 - m_fontSizeBase: 32 + m_fontSize: 44 + m_fontSizeBase: 44 m_fontWeight: 400 m_enableAutoSizing: 0 m_fontSizeMin: 0 @@ -9050,7 +9079,7 @@ RectTransform: m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_AnchorMin: {x: 0, y: 1} m_AnchorMax: {x: 1, y: 1} - m_AnchoredPosition: {x: 75, y: 15} + m_AnchoredPosition: {x: 75, y: 15.000061} m_SizeDelta: {x: 150, y: 512} m_Pivot: {x: 0.5, y: 1} --- !u!114 &1901141296 @@ -9643,8 +9672,8 @@ RectTransform: m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_AnchorMin: {x: 0, y: 0} m_AnchorMax: {x: 1, y: 1} - m_AnchoredPosition: {x: -2.5, y: -12.5} - m_SizeDelta: {x: -5, y: -25} + m_AnchoredPosition: {x: -6.25, y: -7.5} + m_SizeDelta: {x: -12.5, y: -35} m_Pivot: {x: 0.5, y: 0.5} --- !u!114 &1996258852 MonoBehaviour: @@ -9937,7 +9966,7 @@ MonoBehaviour: m_text: 01234567890123456 m_isRightToLeft: 0 m_fontAsset: {fileID: 11400000, guid: 72af27804d5aa49408430b4b2500f877, type: 2} - m_sharedMaterial: {fileID: 8890805173838430465, guid: 72af27804d5aa49408430b4b2500f877, type: 2} + m_sharedMaterial: {fileID: 2100000, guid: 9fb4d071241c54841ab116886c83b585, type: 2} m_fontSharedMaterials: [] m_fontMaterial: {fileID: 0} m_fontMaterials: [] @@ -9961,8 +9990,8 @@ MonoBehaviour: m_faceColor: serializedVersion: 2 rgba: 4294967295 - m_fontSize: 32 - m_fontSizeBase: 32 + m_fontSize: 44 + m_fontSizeBase: 44 m_fontWeight: 400 m_enableAutoSizing: 0 m_fontSizeMin: 0 diff --git a/Assets/Scripts/RoomManager.cs b/Assets/Scripts/RoomManager.cs index e96f6bd..79ba353 100644 --- a/Assets/Scripts/RoomManager.cs +++ b/Assets/Scripts/RoomManager.cs @@ -30,14 +30,7 @@ public class RoomManager : MonoBehaviour public AudioClip counterSFX; [Header("Waiting For Proposition Page")] - public GameObject waitingForPropositionsPage; - public TextMeshProUGUI propositionCounter; - public float propositionTime = 60; - public List waitingForPropositionsLabels = new List(); - private Dictionary propositionLabelsByID = new Dictionary(); - private DateTime endOfPropositionDate = DateTime.MinValue; - private bool allPlayersHasProposedTwoPictures = false; - private Dictionary propositionsPerPlayers = new Dictionary(); + public WaitForPropositionsPage waitForPropositionsPage; [Header("Waiting For Proposition Page")] public VotingPage votingPage; @@ -56,7 +49,8 @@ private void Awake() private void Start() { explanationPage.SetActive(false); - waitingForPropositionsPage.SetActive(false); + waitForPropositionsPage.gameObject.SetActive(false); + votingPage.gameObject.SetActive(false); waitingForPlayersPage.SetActive(true); ResetAllPlayerLabels(); } @@ -79,52 +73,6 @@ private void Update() } } - //while MakeProposition State - if (myRoom.currentState == (int)GameState.MakeProposition && endOfPropositionDate != DateTime.MinValue) - { - TimeSpan duration = endOfPropositionDate - DateTime.Now; - propositionCounter.text = ((int)duration.TotalSeconds).ToString("D1"); - - //foreach labels - foreach (var labelByID in propositionLabelsByID) - { - //if the label is connected to a player - if (labelByID.Value.gameObject.activeSelf) - { - //check if this player has send 2 propositions - bool playerHasAnswerBoth = true; - //Debug.Log($"trying to check if player {labelByID.Key} has send 2 propositions"); - //Debug.Log($"player {labelByID.Key} has send {propositionsPerPlayers[labelByID.Key].Length} propositions"); - if (propositionsPerPlayers[labelByID.Key].Length < 2) - { - playerHasAnswerBoth = false; - } - else - { - foreach (Proposition p in propositionsPerPlayers[labelByID.Key]) - { - if (string.IsNullOrEmpty(p.photoUrl)) - { - //Debug.Log($"player {labelByID.Key} proposition URL : {p.photoUrl}"); - playerHasAnswerBoth = false; - } - } - } - //if its the case - if (playerHasAnswerBoth) - { - Debug.Log($"player {labelByID.Key} has made 2 propositions", this); - //put player label in green if finished - labelByID.Value.color = Color.green; - } - } - } - - if (allPlayersHasProposedTwoPictures || duration.TotalMilliseconds <= 0) - { - SendRoomState(GameState.MakeVote); - } - } } private void SendRoomState(GameState _newState) @@ -220,43 +168,6 @@ private int GenerateRandomAvailableCode(List _impossibleCodes) return random; } - /// - /// Called when the first player clicked "Start" - /// - public void HostHasStartedGame() - { - waitingForPropositionsPage.SetActive(true); - waitingForPlayersPage.SetActive(false); - endOfPropositionDate = DateTime.Now.AddSeconds(propositionTime); - - propositionLabelsByID.Clear(); - - //display only correct numbers of labels - for (int i = 0; i < waitingForPropositionsLabels.Count; i++) - { - TextMeshProUGUI tmp = waitingForPropositionsLabels[i]; - tmp.gameObject.SetActive(i < myRoom.players.Count); - Debug.Log($"toggling {tmp.gameObject.name} accordingly to its player connection"); - } - - //registers the labels per player ID - List orderedPlayers = myRoom.GetPlayerList().OrderBy(x => x.creationDate).ToList(); - for (int i = 0; i < orderedPlayers.Count; i++) - { - propositionLabelsByID.Add(orderedPlayers[i].id, waitingForPropositionsLabels[i]); - waitingForPropositionsLabels[i].text = orderedPlayers[i].name; - Debug.Log($"{waitingForPropositionsLabels[i].name} label should be {orderedPlayers[i].name}"); - } - - //Register all propositions of each players - foreach (Player p in myRoom.GetOrderedPlayerList()) - { - List propositionsForPlayer = myRoom.GetPropositionsByPlayer(p); - propositionsPerPlayers.Add(p.id, propositionsForPlayer.ToArray()); - Debug.Log($"registering propositions for player {p.name}"); - } - } - public void GeneratePrompts() { System.Random rnd = new(); @@ -333,7 +244,6 @@ private void OnRoomUpdate(object sender, ValueChangedEventArgs value) case (int)GameState.Explanation: break; case (int)GameState.MakeProposition: - CheckPlayersPropositions(); break; default: break; @@ -367,7 +277,8 @@ private void OnNewGameStateStarted() case (int)GameState.MakeProposition: Debug.Log("New State : MakeProposition"); AudioManager.Instance.ChangeMusic(MusicTitle.TakingPicture); - HostHasStartedGame(); + waitForPropositionsPage.Initialize(myRoom, () => SendRoomState(GameState.MakeVote)); + waitingForPlayersPage.SetActive(false); break; case (int)GameState.MakeVote: @@ -388,29 +299,6 @@ private void OnNewGameStateStarted() } } - /// - /// Will update allPlayersHasProposedTwoPictures to true or false - /// - private void CheckPlayersPropositions() - { - Debug.Log("Check every Players Propositions"); - allPlayersHasProposedTwoPictures = true; - - foreach (var propositionsByPlayer in propositionsPerPlayers) - { - Debug.Log("proposition"); - foreach (Proposition p in propositionsByPlayer.Value) - { - if (string.IsNullOrEmpty(p.photoUrl)) - { - Debug.Log($"player {p.owner.name} has a proposition without an URL"); - allPlayersHasProposedTwoPictures = false; - } - } - } - } - - /// /// Update the player labels on the WaitingForPlayer page /// diff --git a/Assets/Scripts/WaitForPropositionsPage.cs b/Assets/Scripts/WaitForPropositionsPage.cs new file mode 100644 index 0000000..d889bd2 --- /dev/null +++ b/Assets/Scripts/WaitForPropositionsPage.cs @@ -0,0 +1,96 @@ +using System; +using System.Collections; +using System.Collections.Generic; +using TMPro; +using UnityEngine; + +public class WaitForPropositionsPage : MonoBehaviour +{ + public TextMeshProUGUI propositionCounter; + public float propositionTime = 60; + public List playerLabels = new List(); + + private DateTime endOfPropositionDate = DateTime.MinValue; + private bool allPlayersHasProposedTwoPictures = false; + + private event Action OnPropositionFinish; + private Room myRoom; + + private List playersIdWhoHaveProposed = new List(); + + public void Initialize(Room _myRoom, Action _onPropositionFinish) + { + endOfPropositionDate = DateTime.Now.AddSeconds(propositionTime); + gameObject.SetActive(true); + OnPropositionFinish = _onPropositionFinish; + myRoom = _myRoom; + ShowPlayerLabels(); + } + + private void ShowPlayerLabels() + { + //display only correct numbers of labels + for (int i = 0; i < playerLabels.Count; i++) + { + TextMeshProUGUI tmp = playerLabels[i]; + tmp.gameObject.SetActive(i < myRoom.players.Count); + Debug.Log($"toggling {tmp.gameObject.name} accordingly to its player connection"); + } + } + + // Update is called once per frame + void Update() + { + + //while MakeProposition State + if (endOfPropositionDate != DateTime.MinValue) + { + TimeSpan duration = endOfPropositionDate - DateTime.Now; + + + if (duration.TotalMilliseconds <= 0 || allPlayersHasProposedTwoPictures) + { + OnPropositionFinish?.Invoke(); + return; + } + + CheckPlayersWhoHaveProposed(); + propositionCounter.text = ((int)duration.TotalSeconds).ToString("D1"); + } + } + + private void CheckPlayersWhoHaveProposed() + { + foreach (Player player in myRoom.GetPlayerList()) + { + if (playersIdWhoHaveProposed.Contains(player.id)) + continue; + + bool playerHasAnsweredBothProposition = true; + Proposition[] propositions = myRoom.GetPropositionsByPlayer(player).ToArray(); + if (propositions.Length < 2) + playerHasAnsweredBothProposition = false; + else + { + for (int i = 0; i < propositions.Length; i++) + { + if (string.IsNullOrEmpty(propositions[i].photoUrl)) + { + playerHasAnsweredBothProposition = false; + } + } + } + + if (playerHasAnsweredBothProposition) + { + playerLabels.Find(x => x.text == player.name).color = Color.green; + playersIdWhoHaveProposed.Add(player.id); + } + if(playersIdWhoHaveProposed.Count == myRoom.players.Count) + { + allPlayersHasProposedTwoPictures = true; + } + } + + } +} diff --git a/Assets/Scripts/WaitForPropositionsPage.cs.meta b/Assets/Scripts/WaitForPropositionsPage.cs.meta new file mode 100644 index 0000000..df83309 --- /dev/null +++ b/Assets/Scripts/WaitForPropositionsPage.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 64daf56939ea63b4b80e588da220e61b +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: