diff --git a/Assets/Scenes/ComputerView.unity b/Assets/Scenes/ComputerView.unity index 21a31da..cf9ac1f 100644 --- a/Assets/Scenes/ComputerView.unity +++ b/Assets/Scenes/ComputerView.unity @@ -2719,7 +2719,7 @@ MonoBehaviour: 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_sharedMaterial: {fileID: 2100000, guid: 9fb4d071241c54841ab116886c83b585, type: 2} m_fontSharedMaterials: [] m_fontMaterial: {fileID: 0} m_fontMaterials: [] @@ -5997,7 +5997,7 @@ MonoBehaviour: m_OnCullStateChanged: m_PersistentCalls: m_Calls: [] - m_Sprite: {fileID: 21300000, guid: 93cf115964d3bfa45ba83a1f465565f0, type: 3} + m_Sprite: {fileID: 21300000, guid: c61e5b2ecf71bd44fa029b05c6f7d0b2, type: 3} m_Type: 0 m_PreserveAspect: 0 m_FillCenter: 1 @@ -7937,7 +7937,7 @@ MonoBehaviour: m_text: 3 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: [] @@ -9079,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.000061} + m_AnchoredPosition: {x: 75, y: 15} m_SizeDelta: {x: 150, y: 512} m_Pivot: {x: 0.5, y: 1} --- !u!114 &1901141296 diff --git a/Assets/Scripts/DatabaseClasses/Room.cs b/Assets/Scripts/DatabaseClasses/Room.cs index 7834fde..be080be 100644 --- a/Assets/Scripts/DatabaseClasses/Room.cs +++ b/Assets/Scripts/DatabaseClasses/Room.cs @@ -3,6 +3,7 @@ using System.Linq; using Newtonsoft.Json; using Newtonsoft.Json.Linq; +using UnityEngine; [Serializable] [JsonObject] @@ -54,9 +55,9 @@ public List GetQuestionsByPlayer(Player player) { List playerQuestions = new(); - foreach (Question question in new List(questions.Values)) + foreach (Question question in questions.Values.ToList()) { - foreach (Proposition proposition in new List(question.propositions.Values)) + foreach (Proposition proposition in question.propositions.Values.ToList()) { if (proposition.owner.id == player.id) { @@ -79,9 +80,9 @@ public List GetPropositionsByPlayer(Player player) { List playerPropositions = new(); - foreach (Question question in new List(questions.Values)) + foreach (Question question in questions.Values.ToList()) { - foreach (Proposition proposition in new List(question.propositions.Values)) + foreach (Proposition proposition in question.propositions.Values.ToList()) { if (proposition.owner.id == player.id) { diff --git a/Assets/Scripts/RoomManager.cs b/Assets/Scripts/RoomManager.cs index 79ba353..a1225b2 100644 --- a/Assets/Scripts/RoomManager.cs +++ b/Assets/Scripts/RoomManager.cs @@ -244,6 +244,7 @@ private void OnRoomUpdate(object sender, ValueChangedEventArgs value) case (int)GameState.Explanation: break; case (int)GameState.MakeProposition: + waitForPropositionsPage.OnRoomUpdate(myRoom); break; default: break; diff --git a/Assets/Scripts/WaitForPropositionsPage.cs b/Assets/Scripts/WaitForPropositionsPage.cs index d889bd2..194fb62 100644 --- a/Assets/Scripts/WaitForPropositionsPage.cs +++ b/Assets/Scripts/WaitForPropositionsPage.cs @@ -27,17 +27,12 @@ public void Initialize(Room _myRoom, Action _onPropositionFinish) ShowPlayerLabels(); } - private void ShowPlayerLabels() + public void OnRoomUpdate(Room _myRoom) { - //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"); - } + myRoom = _myRoom; } + // Update is called once per frame void Update() { @@ -58,6 +53,24 @@ void Update() propositionCounter.text = ((int)duration.TotalSeconds).ToString("D1"); } } + private void ShowPlayerLabels() + { + //display only correct numbers of labels and set names + List players = myRoom.GetOrderedPlayerList(); + for (int i = 0; i < playerLabels.Count; i++) + { + if (i < players.Count) + { + playerLabels[i].gameObject.SetActive(true); + playerLabels[i].text = players[i].name; + } + else + { + playerLabels[i].gameObject.SetActive(false); + } + //Debug.Log($"toggling {playerLabels[i].gameObject.name} accordingly to its player connection"); + } + } private void CheckPlayersWhoHaveProposed() { @@ -68,6 +81,8 @@ private void CheckPlayersWhoHaveProposed() bool playerHasAnsweredBothProposition = true; Proposition[] propositions = myRoom.GetPropositionsByPlayer(player).ToArray(); + //Debug.Log($"I found {propositions.Length} propositions for {player.name}", this); + if (propositions.Length < 2) playerHasAnsweredBothProposition = false; else @@ -76,6 +91,7 @@ private void CheckPlayersWhoHaveProposed() { if (string.IsNullOrEmpty(propositions[i].photoUrl)) { + //Debug.Log($"{player.name}'s proposition {i} has no photoURL", this); playerHasAnsweredBothProposition = false; } } @@ -83,9 +99,11 @@ private void CheckPlayersWhoHaveProposed() if (playerHasAnsweredBothProposition) { + Debug.Log($"{player.name}'s has answered both propositions !", this); playerLabels.Find(x => x.text == player.name).color = Color.green; playersIdWhoHaveProposed.Add(player.id); } + Debug.Log($"{playersIdWhoHaveProposed.Count}/{myRoom.players.Count} players have answered.", this); if(playersIdWhoHaveProposed.Count == myRoom.players.Count) { allPlayersHasProposedTwoPictures = true;