Merge branch 'main' of github.com:LeGall29/GGJ2024

This commit is contained in:
Michel Roux 2024-01-28 02:40:47 +01:00
commit 532d66e1c1
12 changed files with 50 additions and 58 deletions

BIN
Assets/Audio SFX/1.ogg (Stored with Git LFS)

Binary file not shown.

BIN
Assets/Audio SFX/2.ogg (Stored with Git LFS)

Binary file not shown.

View File

@ -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:

BIN
Assets/Audio SFX/3.ogg (Stored with Git LFS)

Binary file not shown.

BIN
Assets/Audio SFX/Decompte.mp3 (Stored with Git LFS) Normal file

Binary file not shown.

View File

@ -1,5 +1,5 @@
fileFormatVersion: 2 fileFormatVersion: 2
guid: 3beaa7f0d20a77649ba21959c91856f8 guid: 2ff45dbe56b6a4d08bfa7b103fa4effb
AudioImporter: AudioImporter:
externalObjects: {} externalObjects: {}
serializedVersion: 7 serializedVersion: 7

BIN
Assets/Music/Voting session.mp3 (Stored with Git LFS) Normal file

Binary file not shown.

View File

@ -1,5 +1,5 @@
fileFormatVersion: 2 fileFormatVersion: 2
guid: 59e3c7eac1a310f448b7d3d50ccdf3ed guid: d782d7e00ee5a0d40a3c005d87c15b3a
AudioImporter: AudioImporter:
externalObjects: {} externalObjects: {}
serializedVersion: 7 serializedVersion: 7

View File

@ -1382,7 +1382,7 @@ MonoBehaviour:
explanationPage: {fileID: 45150984} explanationPage: {fileID: 45150984}
explanationCounter: {fileID: 1798182259} explanationCounter: {fileID: 1798182259}
explanationTime: 4 explanationTime: 4
counterSFX: {fileID: 8300000, guid: 3beaa7f0d20a77649ba21959c91856f8, type: 3} counterSFX: {fileID: 8300000, guid: 2ff45dbe56b6a4d08bfa7b103fa4effb, type: 3}
waitingForPropositionsPage: {fileID: 1730465902} waitingForPropositionsPage: {fileID: 1730465902}
propositionCounter: {fileID: 1996258852} propositionCounter: {fileID: 1996258852}
propositionTime: 60 propositionTime: 60

View File

@ -934,7 +934,7 @@ MonoBehaviour:
submitNewPlayer: {fileID: 1158329299} submitNewPlayer: {fileID: 1158329299}
listPlayersUI: {fileID: 1891690322} listPlayersUI: {fileID: 1891690322}
submitStartGame: {fileID: 638947073} submitStartGame: {fileID: 638947073}
counter: {fileID: 0} counter: {fileID: 1383251891}
HomeConnection: {fileID: 2027556831} HomeConnection: {fileID: 2027556831}
WaitingRoom: {fileID: 1590939977} WaitingRoom: {fileID: 1590939977}
BeforeStart: {fileID: 563000513} BeforeStart: {fileID: 563000513}

View File

@ -4,6 +4,7 @@
using Firebase.Database; using Firebase.Database;
using Firebase.Extensions; using Firebase.Extensions;
using Newtonsoft.Json; using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using TMPro; using TMPro;
using UnityEngine; using UnityEngine;
@ -56,6 +57,13 @@ private void Start()
{ {
currentExplanationTime = explanationTime; currentExplanationTime = explanationTime;
HomeConnection.SetActive(true); HomeConnection.SetActive(true);
WaitingRoom.SetActive(false);
BeforeStart.SetActive(false);
TakePicture.SetActive(false);
VotePicture.SetActive(false);
WaitingOtherPlayers.SetActive(false);
EndGame.SetActive(false);
submitNewPlayer.interactable = false; submitNewPlayer.interactable = false;
} }
@ -81,6 +89,7 @@ private void Update()
if (duration.TotalMilliseconds <= 0) if (duration.TotalMilliseconds <= 0)
{ {
Debug.Log("It's time to make proposition !"); 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); WaitingRoom.SetActive(true);
HomeConnection.SetActive(false); HomeConnection.SetActive(false);
List<Player> list = new List<Player>
{
currentPlayer
};
UpdateDisplayedListUser(list);
}); });
} }
}); });
@ -285,10 +288,12 @@ public void DisplayEndScreen()
/// </summary> /// </summary>
private void OnRoomUpdate(object sender, ValueChangedEventArgs e) private void OnRoomUpdate(object sender, ValueChangedEventArgs e)
{ {
Debug.Log("begin OnRoomUpdate");
try try
{ {
if (e != null) if (e?.Snapshot?.GetRawJsonValue() != null)
{ {
string JSON = e.Snapshot.GetRawJsonValue();
myRoom = JsonConvert.DeserializeObject<Room>(e.Snapshot.GetRawJsonValue()); myRoom = JsonConvert.DeserializeObject<Room>(e.Snapshot.GetRawJsonValue());
} }
@ -299,6 +304,7 @@ private void OnRoomUpdate(object sender, ValueChangedEventArgs e)
} }
if (myRoom == null) if (myRoom == null)
{ {
Debug.Log("myroom is null");
return; return;
} }
switch (myRoom.currentState) switch (myRoom.currentState)

View File

@ -16,6 +16,7 @@ public class RoomManager : MonoBehaviour
/// </summary> /// </summary>
public TextMeshProUGUI roomCodeLabel; public TextMeshProUGUI roomCodeLabel;
public List<TextMeshProUGUI> waitingForPlayersLabels = new List<TextMeshProUGUI>(); public List<TextMeshProUGUI> waitingForPlayersLabels = new List<TextMeshProUGUI>();
private Dictionary<string, TextMeshProUGUI> waitingPlayersById = new Dictionary<string, TextMeshProUGUI>();
public PromptList promptList; public PromptList promptList;
[Header("Explanation Page")] [Header("Explanation Page")]
@ -31,6 +32,7 @@ public class RoomManager : MonoBehaviour
public float propositionTime = 60; public float propositionTime = 60;
public List<TextMeshProUGUI> waitingForPropositionsLabels = new List<TextMeshProUGUI>(); public List<TextMeshProUGUI> waitingForPropositionsLabels = new List<TextMeshProUGUI>();
private DateTime endOfPropositionDate = DateTime.MinValue; private DateTime endOfPropositionDate = DateTime.MinValue;
private bool allPlayersHasProposedTwoPictures = false;
[Header("Other")] [Header("Other")]
private Room myRoom = null; private Room myRoom = null;
@ -72,6 +74,7 @@ private void Update()
if (myRoom == null) if (myRoom == null)
return; return;
//While Explanation State
if (myRoom.currentState == (int)GameState.Explanation && endOfExplanationDate != DateTime.MinValue) if (myRoom.currentState == (int)GameState.Explanation && endOfExplanationDate != DateTime.MinValue)
{ {
TimeSpan duration = endOfExplanationDate - DateTime.Now; TimeSpan duration = endOfExplanationDate - DateTime.Now;
@ -85,11 +88,19 @@ private void Update()
} }
} }
//while MakeProposition State
if (myRoom.currentState == (int)GameState.MakeProposition && endOfPropositionDate != DateTime.MinValue) if (myRoom.currentState == (int)GameState.MakeProposition && endOfPropositionDate != DateTime.MinValue)
{ {
TimeSpan duration = endOfPropositionDate - DateTime.Now; TimeSpan duration = endOfPropositionDate - DateTime.Now;
propositionCounter.text = ((int)duration.TotalSeconds).ToString("D1"); 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() private void ResetAllPlayerLabels()
{ {
waitingPlayersById.Clear();
for (int i = 0; i < waitingForPlayersLabels.Count; i++) for (int i = 0; i < waitingForPlayersLabels.Count; i++)
{ {
waitingForPlayersLabels[i].text = $"Waiting for P{i + 1}"; waitingForPlayersLabels[i].text = $"Waiting for P{i + 1}";
@ -222,12 +234,18 @@ public void PlayerSendProposition(Proposition _proposition)
/// <summary> /// <summary>
/// Called when the first player clicked "Start" /// Called when the first player clicked "Start"
/// </summary> /// </summary>
public void HostStartGame() public void HostHasStartedGame()
{ {
waitingForPropositionsPage.SetActive(true); waitingForPropositionsPage.SetActive(true);
waitingForPlayersPage.SetActive(false); waitingForPlayersPage.SetActive(false);
endOfPropositionDate = DateTime.Now.AddSeconds(propositionTime); 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);
}
} }
/// <summary> /// <summary>
@ -350,9 +368,10 @@ private void OnRoomUpdate(object sender, ValueChangedEventArgs value)
waitingForPlayersPage.SetActive(false); waitingForPlayersPage.SetActive(false);
explanationPage.SetActive(true); explanationPage.SetActive(true);
endOfExplanationDate = DateTime.Now.AddSeconds(explanationTime); endOfExplanationDate = DateTime.Now.AddSeconds(explanationTime);
AudioSource.PlayClipAtPoint(counterSFX, Vector3.zero);
break; break;
case (int)GameState.MakeProposition: case (int)GameState.MakeProposition:
HostStartGame(); HostHasStartedGame();
break; break;
default: default:
break; break;
@ -368,19 +387,12 @@ private void UpdateConnectedPlayerList(List<Player> _players)
ResetAllPlayerLabels(); ResetAllPlayerLabels();
Debug.Log($"players count = {_players.Count}"); Debug.Log($"players count = {_players.Count}");
for (int i = 0; i < _players.Count; i++) List<Player> orderedPlayers = _players.OrderBy(x => x.creationDate).ToList();
for (int i = 0; i < orderedPlayers.Count; i++)
{ {
Debug.Log($"player {i} = {_players[i].name}"); waitingPlayersById.Add(orderedPlayers[i].id, waitingForPlayersLabels[i]);
waitingForPlayersLabels[i].text = _players[i].name; 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");
}
} }