Merge branch 'main' of https://github.com/LeGall29/GGJ2024
This commit is contained in:
commit
723d0d14d2
8
Assets/Music.meta
Normal file
8
Assets/Music.meta
Normal file
@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 23eaa774a3a7d434183a4c336d52891f
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
BIN
Assets/Music/Ending.mp3
(Stored with Git LFS)
Normal file
BIN
Assets/Music/Ending.mp3
(Stored with Git LFS)
Normal file
Binary file not shown.
23
Assets/Music/Ending.mp3.meta
Normal file
23
Assets/Music/Ending.mp3.meta
Normal file
@ -0,0 +1,23 @@
|
||||
fileFormatVersion: 2
|
||||
guid: e1135788bf319bd42b6ca512976f9028
|
||||
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/Music/Menu.mp3
(Stored with Git LFS)
Normal file
BIN
Assets/Music/Menu.mp3
(Stored with Git LFS)
Normal file
Binary file not shown.
23
Assets/Music/Menu.mp3.meta
Normal file
23
Assets/Music/Menu.mp3.meta
Normal file
@ -0,0 +1,23 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 7ac3efdb5c840704aafbf19188b3e61e
|
||||
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/Music/Taking picture.mp3
(Stored with Git LFS)
Normal file
BIN
Assets/Music/Taking picture.mp3
(Stored with Git LFS)
Normal file
Binary file not shown.
23
Assets/Music/Taking picture.mp3.meta
Normal file
23
Assets/Music/Taking picture.mp3.meta
Normal file
@ -0,0 +1,23 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 0e86c0433979a2d4c884b368808d3cdf
|
||||
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:
|
@ -1,5 +1,6 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Firebase.Database;
|
||||
using Firebase.Extensions;
|
||||
using Newtonsoft.Json;
|
||||
@ -11,9 +12,7 @@
|
||||
/// </summary>
|
||||
public class GameManager : MonoBehaviour
|
||||
{
|
||||
private GameState currentState;
|
||||
private List<Player> players = new();
|
||||
private bool isFirst = false;
|
||||
public Player currentPlayer = null;
|
||||
|
||||
[Header("Other component")]
|
||||
@ -57,15 +56,13 @@ private void Start()
|
||||
}
|
||||
private void OnApplicationQuit()
|
||||
{
|
||||
myOnlineRoom.Child("players").Child(currentPlayer.id).RemoveValueAsync();
|
||||
myOnlineRoom.Child("players").Child(currentPlayer.id).RemoveValueAsync().ContinueWithOnMainThread(task =>
|
||||
{
|
||||
Debug.Log($"delete player {currentPlayer.name}");
|
||||
myRoom = null;
|
||||
myOnlineRoom.ValueChanged -= OnRoomUpdate;
|
||||
});
|
||||
}
|
||||
|
||||
public GameState GetCurrentState()
|
||||
{
|
||||
return currentState;
|
||||
}
|
||||
|
||||
private void Initialize()
|
||||
{
|
||||
@ -124,7 +121,7 @@ public void PlayerValidateNameAndServerRoom(string _name, string _code)
|
||||
{
|
||||
//then subscribe to it
|
||||
myOnlineRoom.ValueChanged += OnRoomUpdate;
|
||||
currentState = GameState.WaitingForOtherPlayersToJoin;
|
||||
myRoom.currentState = (int)GameState.WaitingForOtherPlayersToJoin;
|
||||
players.Add(currentPlayer);
|
||||
|
||||
WaitingRoom.SetActive(true);
|
||||
@ -202,19 +199,13 @@ public void StartGame()
|
||||
Debug.Log(JSON);
|
||||
try
|
||||
{
|
||||
myOnlineRoom.Child("currentState").SetValueAsync(2).ContinueWithOnMainThread(task =>
|
||||
{
|
||||
if (task.IsFaulted)
|
||||
{
|
||||
Debug.LogException(task.Exception);
|
||||
}
|
||||
else
|
||||
sendCurrentState(GameState.Explanation, () =>
|
||||
{
|
||||
Debug.Log($"start the game", this);
|
||||
currentState = GameState.Explanation;
|
||||
myRoom.currentState = (int)GameState.Explanation;
|
||||
WaitingRoom.SetActive(false);
|
||||
BeforeStart.SetActive(true);
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
catch (Exception ex)
|
||||
@ -232,7 +223,7 @@ public void StartGame()
|
||||
/// <param name="_prompt">The prompt to display</param>
|
||||
public void MakeAProposition(Prompt _prompt)
|
||||
{
|
||||
currentState = GameState.MakeProposition;
|
||||
//currentState = GameState.MakeProposition;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -282,13 +273,30 @@ private void OnRoomUpdate(object sender, ValueChangedEventArgs e)
|
||||
{
|
||||
Debug.LogException(ex);
|
||||
}
|
||||
|
||||
switch (currentState)
|
||||
if(myRoom == null) {
|
||||
return;
|
||||
}
|
||||
switch (myRoom.currentState)
|
||||
{
|
||||
case GameState.WaitingForOtherPlayersToJoin:
|
||||
case (int)GameState.WaitingForOtherPlayersToJoin:
|
||||
{
|
||||
CheckIfIAmTheFirst(myRoom.GetPlayerList());
|
||||
UpdateDisplayedListUser(myRoom.GetPlayerList());
|
||||
break;
|
||||
}
|
||||
case (int)GameState.Explanation:
|
||||
{
|
||||
|
||||
break;
|
||||
}
|
||||
case (int)GameState.MakeProposition:
|
||||
{
|
||||
if (BeforeStart.activeInHierarchy)
|
||||
{
|
||||
BeforeStart.SetActive(false);
|
||||
TakePicture.SetActive(true);
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -306,16 +314,38 @@ private void UpdateDisplayedListUser(List<Player> players)
|
||||
|
||||
private void CheckIfIAmTheFirst(List<Player> players)
|
||||
{
|
||||
bool isFirst = false;
|
||||
if (players.Count > 1)
|
||||
{
|
||||
|
||||
IOrderedEnumerable<Player> sortedList = players.OrderBy(x=>x.creationDate);
|
||||
|
||||
if(sortedList.Last().id == currentPlayer.id)
|
||||
{
|
||||
isFirst = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (isFirst)
|
||||
{
|
||||
submitStartGame.SetActive(true);
|
||||
}
|
||||
}
|
||||
public void sendCurrentState(GameState state,Action callback_oncCurrentStateSent)
|
||||
{
|
||||
myOnlineRoom.Child("currentState").SetValueAsync((int)state).ContinueWithOnMainThread(task =>
|
||||
{
|
||||
if (task.IsFaulted)
|
||||
{
|
||||
Debug.LogException(task.Exception);
|
||||
}
|
||||
else
|
||||
{
|
||||
callback_oncCurrentStateSent?.Invoke();
|
||||
}
|
||||
}); ;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void OnClickSubmitSignIn()
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user