diff --git a/Assets/Audio SFX/1.ogg b/Assets/Audio SFX/1.ogg deleted file mode 100644 index 5dd46a5..0000000 --- a/Assets/Audio SFX/1.ogg +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:58ecc2a3d1528f75ee74d1fed84586afbafce5134a27e1ba1dcc3dcd42074d4d -size 7331 diff --git a/Assets/Audio SFX/2.ogg b/Assets/Audio SFX/2.ogg deleted file mode 100644 index c17108a..0000000 --- a/Assets/Audio SFX/2.ogg +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:9a1577f2e8f3ca95d959bf542553aceb69c4a4d6872d21e862dbf30992472454 -size 7352 diff --git a/Assets/Audio SFX/2.ogg.meta b/Assets/Audio SFX/2.ogg.meta deleted file mode 100644 index a9a3eae..0000000 --- a/Assets/Audio SFX/2.ogg.meta +++ /dev/null @@ -1,23 +0,0 @@ -fileFormatVersion: 2 -guid: e6ae431cc10239b439b12c6836142bb6 -AudioImporter: - externalObjects: {} - serializedVersion: 7 - defaultSettings: - serializedVersion: 2 - loadType: 0 - sampleRateSetting: 0 - sampleRateOverride: 44100 - compressionFormat: 1 - quality: 1 - conversionMode: 0 - preloadAudioData: 0 - platformSettingOverrides: {} - forceToMono: 0 - normalize: 1 - loadInBackground: 0 - ambisonic: 0 - 3D: 1 - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/Audio SFX/3.ogg b/Assets/Audio SFX/3.ogg deleted file mode 100644 index 85ac107..0000000 --- a/Assets/Audio SFX/3.ogg +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:83de2bbeae91edb680df856a947a7f781a737bc20702ebe29acd388541e68b62 -size 8228 diff --git a/Assets/Audio SFX/Decompte.mp3 b/Assets/Audio SFX/Decompte.mp3 new file mode 100644 index 0000000..1a25489 --- /dev/null +++ b/Assets/Audio SFX/Decompte.mp3 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:fd2386e769fd6c160309a0ad936ccbb8162e4514284d106a8734e99d7a36753c +size 133583 diff --git a/Assets/Audio SFX/3.ogg.meta b/Assets/Audio SFX/Decompte.mp3.meta similarity index 91% rename from Assets/Audio SFX/3.ogg.meta rename to Assets/Audio SFX/Decompte.mp3.meta index e4d0adf..764bd17 100644 --- a/Assets/Audio SFX/3.ogg.meta +++ b/Assets/Audio SFX/Decompte.mp3.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: 3beaa7f0d20a77649ba21959c91856f8 +guid: 2ff45dbe56b6a4d08bfa7b103fa4effb AudioImporter: externalObjects: {} serializedVersion: 7 diff --git a/Assets/Music/Voting session.mp3 b/Assets/Music/Voting session.mp3 new file mode 100644 index 0000000..94dccdb --- /dev/null +++ b/Assets/Music/Voting session.mp3 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:56d6b74c703923226c0d225027749ccf8dee0569d6141541b932a89e2a46d3c7 +size 2796623 diff --git a/Assets/Audio SFX/1.ogg.meta b/Assets/Music/Voting session.mp3.meta similarity index 91% rename from Assets/Audio SFX/1.ogg.meta rename to Assets/Music/Voting session.mp3.meta index 01db90d..279e97d 100644 --- a/Assets/Audio SFX/1.ogg.meta +++ b/Assets/Music/Voting session.mp3.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: 59e3c7eac1a310f448b7d3d50ccdf3ed +guid: d782d7e00ee5a0d40a3c005d87c15b3a AudioImporter: externalObjects: {} serializedVersion: 7 diff --git a/Assets/Scenes/ComputerView.unity b/Assets/Scenes/ComputerView.unity index 8c417b0..561ceb2 100644 --- a/Assets/Scenes/ComputerView.unity +++ b/Assets/Scenes/ComputerView.unity @@ -1382,7 +1382,7 @@ MonoBehaviour: explanationPage: {fileID: 45150984} explanationCounter: {fileID: 1798182259} explanationTime: 4 - counterSFX: {fileID: 8300000, guid: 3beaa7f0d20a77649ba21959c91856f8, type: 3} + counterSFX: {fileID: 8300000, guid: 2ff45dbe56b6a4d08bfa7b103fa4effb, type: 3} waitingForPropositionsPage: {fileID: 1730465902} propositionCounter: {fileID: 1996258852} propositionTime: 60 diff --git a/Assets/Scenes/PhoneView.unity b/Assets/Scenes/PhoneView.unity index 114fb49..8ef0472 100644 --- a/Assets/Scenes/PhoneView.unity +++ b/Assets/Scenes/PhoneView.unity @@ -934,7 +934,7 @@ MonoBehaviour: submitNewPlayer: {fileID: 1158329299} listPlayersUI: {fileID: 1891690322} submitStartGame: {fileID: 638947073} - counter: {fileID: 0} + counter: {fileID: 1383251891} HomeConnection: {fileID: 2027556831} WaitingRoom: {fileID: 1590939977} BeforeStart: {fileID: 563000513} diff --git a/Assets/Scripts/GameManager.cs b/Assets/Scripts/GameManager.cs index 766e827..88a240f 100644 --- a/Assets/Scripts/GameManager.cs +++ b/Assets/Scripts/GameManager.cs @@ -4,6 +4,7 @@ using Firebase.Database; using Firebase.Extensions; using Newtonsoft.Json; +using Newtonsoft.Json.Linq; using TMPro; using UnityEngine; @@ -56,6 +57,13 @@ private void Start() { currentExplanationTime = explanationTime; HomeConnection.SetActive(true); + WaitingRoom.SetActive(false); + BeforeStart.SetActive(false); + TakePicture.SetActive(false); + VotePicture.SetActive(false); + WaitingOtherPlayers.SetActive(false); + EndGame.SetActive(false); + submitNewPlayer.interactable = false; } @@ -81,6 +89,7 @@ private void Update() if (duration.TotalMilliseconds <= 0) { Debug.Log("It's time to make proposition !"); + endOfExplanationDate = DateTime.MinValue; } } } @@ -147,12 +156,6 @@ public void PlayerValidateNameAndServerRoom(string _name, string _code) WaitingRoom.SetActive(true); HomeConnection.SetActive(false); - List list = new List - { - currentPlayer - }; - - UpdateDisplayedListUser(list); }); } }); @@ -285,10 +288,12 @@ public void DisplayEndScreen() /// private void OnRoomUpdate(object sender, ValueChangedEventArgs e) { + Debug.Log("begin OnRoomUpdate"); try { - if (e != null) + if (e?.Snapshot?.GetRawJsonValue() != null) { + string JSON = e.Snapshot.GetRawJsonValue(); myRoom = JsonConvert.DeserializeObject(e.Snapshot.GetRawJsonValue()); } @@ -299,6 +304,7 @@ private void OnRoomUpdate(object sender, ValueChangedEventArgs e) } if (myRoom == null) { + Debug.Log("myroom is null"); return; } switch (myRoom.currentState) diff --git a/Assets/Scripts/RoomManager.cs b/Assets/Scripts/RoomManager.cs index f280767..7ff3c24 100644 --- a/Assets/Scripts/RoomManager.cs +++ b/Assets/Scripts/RoomManager.cs @@ -16,6 +16,7 @@ public class RoomManager : MonoBehaviour /// public TextMeshProUGUI roomCodeLabel; public List waitingForPlayersLabels = new List(); + private Dictionary waitingPlayersById = new Dictionary(); public PromptList promptList; [Header("Explanation Page")] @@ -31,6 +32,7 @@ public class RoomManager : MonoBehaviour public float propositionTime = 60; public List waitingForPropositionsLabels = new List(); private DateTime endOfPropositionDate = DateTime.MinValue; + private bool allPlayersHasProposedTwoPictures = false; [Header("Other")] private Room myRoom = null; @@ -72,6 +74,7 @@ private void Update() if (myRoom == null) return; + //While Explanation State if (myRoom.currentState == (int)GameState.Explanation && endOfExplanationDate != DateTime.MinValue) { TimeSpan duration = endOfExplanationDate - DateTime.Now; @@ -85,11 +88,19 @@ 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 (TextMeshProUGUI tmp in waitingForPropositionsLabels) + { + if (tmp.gameObject.activeSelf) + { + + } + } } } @@ -100,6 +111,7 @@ private void SendRoomState(GameState _newState) private void ResetAllPlayerLabels() { + waitingPlayersById.Clear(); for (int i = 0; i < waitingForPlayersLabels.Count; i++) { waitingForPlayersLabels[i].text = $"Waiting for P{i + 1}"; @@ -222,12 +234,18 @@ public void PlayerSendProposition(Proposition _proposition) /// /// Called when the first player clicked "Start" /// - public void HostStartGame() + public void HostHasStartedGame() { waitingForPropositionsPage.SetActive(true); waitingForPlayersPage.SetActive(false); endOfPropositionDate = DateTime.Now.AddSeconds(propositionTime); - AudioSource.PlayClipAtPoint(counterSFX, Vector3.zero); + + for (int i = 0; i < waitingForPropositionsLabels.Count; i++) + { + TextMeshProUGUI tmp = waitingForPropositionsLabels[i]; + tmp.gameObject.SetActive(i < myRoom.players.Count); + } + } /// @@ -350,9 +368,10 @@ private void OnRoomUpdate(object sender, ValueChangedEventArgs value) waitingForPlayersPage.SetActive(false); explanationPage.SetActive(true); endOfExplanationDate = DateTime.Now.AddSeconds(explanationTime); + AudioSource.PlayClipAtPoint(counterSFX, Vector3.zero); break; case (int)GameState.MakeProposition: - HostStartGame(); + HostHasStartedGame(); break; default: break; @@ -368,19 +387,12 @@ private void UpdateConnectedPlayerList(List _players) ResetAllPlayerLabels(); Debug.Log($"players count = {_players.Count}"); - for (int i = 0; i < _players.Count; i++) + List orderedPlayers = _players.OrderBy(x => x.creationDate).ToList(); + for (int i = 0; i < orderedPlayers.Count; i++) { - Debug.Log($"player {i} = {_players[i].name}"); - waitingForPlayersLabels[i].text = _players[i].name; + waitingPlayersById.Add(orderedPlayers[i].id, waitingForPlayersLabels[i]); + Debug.Log($"player {i} = {orderedPlayers[i].name}"); + waitingForPlayersLabels[i].text = orderedPlayers[i].name; } } - - [ContextMenu("Fake Player Connection")] - private void FakePlayerConnection() - { - Player temp = new Player("Momo"); - temp.id = Guid.NewGuid().ToString(); - temp.SetName("Momo"); - } - }