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

This commit is contained in:
Michel Roux 2024-01-28 01:16:57 +01:00
commit fd97887dd7
6 changed files with 562 additions and 70 deletions

View File

@ -749,7 +749,7 @@ GameObject:
m_Component:
- component: {fileID: 157938956}
- component: {fileID: 157938958}
- component: {fileID: 157938957}
- component: {fileID: 157938959}
m_Layer: 5
m_Name: Timer
m_TagString: Untagged
@ -775,9 +775,17 @@ RectTransform:
m_AnchorMin: {x: 1, y: 1}
m_AnchorMax: {x: 1, y: 1}
m_AnchoredPosition: {x: -43, y: -51}
m_SizeDelta: {x: 100, y: 100}
m_SizeDelta: {x: 200, y: 200}
m_Pivot: {x: 1, y: 1}
--- !u!114 &157938957
--- !u!222 &157938958
CanvasRenderer:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 157938955}
m_CullTransparentMesh: 1
--- !u!114 &157938959
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
@ -786,7 +794,7 @@ MonoBehaviour:
m_GameObject: {fileID: 157938955}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 1344c3c82d62a2a41a3576d8abb8e3ea, type: 3}
m_Script: {fileID: 11500000, guid: fe87c0e1cc204ed48ad3b37840f39efc, type: 3}
m_Name:
m_EditorClassIdentifier:
m_Material: {fileID: 0}
@ -797,21 +805,16 @@ MonoBehaviour:
m_OnCullStateChanged:
m_PersistentCalls:
m_Calls: []
m_Texture: {fileID: 0}
m_UVRect:
serializedVersion: 2
x: 0
y: 0
width: 1
height: 1
--- !u!222 &157938958
CanvasRenderer:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 157938955}
m_CullTransparentMesh: 1
m_Sprite: {fileID: 21300000, guid: 141de4e4cebc12c489ea471b0df36fd8, type: 3}
m_Type: 0
m_PreserveAspect: 0
m_FillCenter: 1
m_FillMethod: 4
m_FillAmount: 1
m_FillClockwise: 1
m_FillOrigin: 0
m_UseSpriteMesh: 0
m_PixelsPerUnitMultiplier: 1
--- !u!1 &183264014
GameObject:
m_ObjectHideFlags: 0
@ -1377,8 +1380,12 @@ MonoBehaviour:
- {fileID: 340074661}
promptList: {fileID: 0}
explanationPage: {fileID: 45150984}
counter: {fileID: 1798182259}
explanationCounter: {fileID: 1798182259}
explanationTime: 4
counterSFX: {fileID: 8300000, guid: 3beaa7f0d20a77649ba21959c91856f8, type: 3}
waitingForPropositionsPage: {fileID: 1730465902}
propositionCounter: {fileID: 1996258852}
propositionTime: 60
waitingForPropositionsLabels:
- {fileID: 972471162}
- {fileID: 1374681049}
@ -1388,8 +1395,6 @@ MonoBehaviour:
- {fileID: 1854893636}
- {fileID: 2065109614}
- {fileID: 1197279072}
propositionTime: 59.8
timerGUI: {fileID: 0}
votingTime: 20
--- !u!114 &375256413
MonoBehaviour:
@ -4125,6 +4130,7 @@ GameObject:
serializedVersion: 6
m_Component:
- component: {fileID: 1117928115}
- component: {fileID: 1117928116}
m_Layer: 5
m_Name: WaitingForPlayersPage
m_TagString: Untagged
@ -4160,6 +4166,102 @@ RectTransform:
m_AnchoredPosition: {x: 0, y: 0}
m_SizeDelta: {x: 0, y: 0}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!82 &1117928116
AudioSource:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1117928114}
m_Enabled: 1
serializedVersion: 4
OutputAudioMixerGroup: {fileID: 0}
m_audioClip: {fileID: 8300000, guid: 7ac3efdb5c840704aafbf19188b3e61e, type: 3}
m_PlayOnAwake: 1
m_Volume: 1
m_Pitch: 1
Loop: 1
Mute: 0
Spatialize: 0
SpatializePostEffects: 0
Priority: 128
DopplerLevel: 1
MinDistance: 1
MaxDistance: 500
Pan2D: 0
rolloffMode: 0
BypassEffects: 0
BypassListenerEffects: 0
BypassReverbZones: 0
rolloffCustomCurve:
serializedVersion: 2
m_Curve:
- serializedVersion: 3
time: 0
value: 1
inSlope: 0
outSlope: 0
tangentMode: 0
weightedMode: 0
inWeight: 0.33333334
outWeight: 0.33333334
- serializedVersion: 3
time: 1
value: 0
inSlope: 0
outSlope: 0
tangentMode: 0
weightedMode: 0
inWeight: 0.33333334
outWeight: 0.33333334
m_PreInfinity: 2
m_PostInfinity: 2
m_RotationOrder: 4
panLevelCustomCurve:
serializedVersion: 2
m_Curve:
- serializedVersion: 3
time: 0
value: 0
inSlope: 0
outSlope: 0
tangentMode: 0
weightedMode: 0
inWeight: 0.33333334
outWeight: 0.33333334
m_PreInfinity: 2
m_PostInfinity: 2
m_RotationOrder: 4
spreadCustomCurve:
serializedVersion: 2
m_Curve:
- serializedVersion: 3
time: 0
value: 0
inSlope: 0
outSlope: 0
tangentMode: 0
weightedMode: 0
inWeight: 0.33333334
outWeight: 0.33333334
m_PreInfinity: 2
m_PostInfinity: 2
m_RotationOrder: 4
reverbZoneMixCustomCurve:
serializedVersion: 2
m_Curve:
- serializedVersion: 3
time: 0
value: 1
inSlope: 0
outSlope: 0
tangentMode: 0
weightedMode: 0
inWeight: 0.33333334
outWeight: 0.33333334
m_PreInfinity: 2
m_PostInfinity: 2
m_RotationOrder: 4
--- !u!1 &1141337195
GameObject:
m_ObjectHideFlags: 0
@ -5431,6 +5533,7 @@ GameObject:
serializedVersion: 6
m_Component:
- component: {fileID: 1451481718}
- component: {fileID: 1451481719}
m_Layer: 5
m_Name: ScorePictureState
m_TagString: Untagged
@ -5461,6 +5564,102 @@ RectTransform:
m_AnchoredPosition: {x: 0, y: 0}
m_SizeDelta: {x: 0, y: 0}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!82 &1451481719
AudioSource:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1451481717}
m_Enabled: 1
serializedVersion: 4
OutputAudioMixerGroup: {fileID: 0}
m_audioClip: {fileID: 8300000, guid: e1135788bf319bd42b6ca512976f9028, type: 3}
m_PlayOnAwake: 1
m_Volume: 1
m_Pitch: 1
Loop: 1
Mute: 0
Spatialize: 0
SpatializePostEffects: 0
Priority: 128
DopplerLevel: 1
MinDistance: 1
MaxDistance: 500
Pan2D: 0
rolloffMode: 0
BypassEffects: 0
BypassListenerEffects: 0
BypassReverbZones: 0
rolloffCustomCurve:
serializedVersion: 2
m_Curve:
- serializedVersion: 3
time: 0
value: 1
inSlope: 0
outSlope: 0
tangentMode: 0
weightedMode: 0
inWeight: 0.33333334
outWeight: 0.33333334
- serializedVersion: 3
time: 1
value: 0
inSlope: 0
outSlope: 0
tangentMode: 0
weightedMode: 0
inWeight: 0.33333334
outWeight: 0.33333334
m_PreInfinity: 2
m_PostInfinity: 2
m_RotationOrder: 4
panLevelCustomCurve:
serializedVersion: 2
m_Curve:
- serializedVersion: 3
time: 0
value: 0
inSlope: 0
outSlope: 0
tangentMode: 0
weightedMode: 0
inWeight: 0.33333334
outWeight: 0.33333334
m_PreInfinity: 2
m_PostInfinity: 2
m_RotationOrder: 4
spreadCustomCurve:
serializedVersion: 2
m_Curve:
- serializedVersion: 3
time: 0
value: 0
inSlope: 0
outSlope: 0
tangentMode: 0
weightedMode: 0
inWeight: 0.33333334
outWeight: 0.33333334
m_PreInfinity: 2
m_PostInfinity: 2
m_RotationOrder: 4
reverbZoneMixCustomCurve:
serializedVersion: 2
m_Curve:
- serializedVersion: 3
time: 0
value: 1
inSlope: 0
outSlope: 0
tangentMode: 0
weightedMode: 0
inWeight: 0.33333334
outWeight: 0.33333334
m_PreInfinity: 2
m_PostInfinity: 2
m_RotationOrder: 4
--- !u!1 &1452182575
GameObject:
m_ObjectHideFlags: 0
@ -6089,6 +6288,7 @@ GameObject:
serializedVersion: 6
m_Component:
- component: {fileID: 1730465903}
- component: {fileID: 1730465904}
m_Layer: 5
m_Name: WaitingForPropositionPage
m_TagString: Untagged
@ -6120,6 +6320,102 @@ RectTransform:
m_AnchoredPosition: {x: 0, y: 0}
m_SizeDelta: {x: 0, y: 0}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!82 &1730465904
AudioSource:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1730465902}
m_Enabled: 1
serializedVersion: 4
OutputAudioMixerGroup: {fileID: 0}
m_audioClip: {fileID: 8300000, guid: 0e86c0433979a2d4c884b368808d3cdf, type: 3}
m_PlayOnAwake: 1
m_Volume: 1
m_Pitch: 1
Loop: 1
Mute: 0
Spatialize: 0
SpatializePostEffects: 0
Priority: 128
DopplerLevel: 1
MinDistance: 1
MaxDistance: 500
Pan2D: 0
rolloffMode: 0
BypassEffects: 0
BypassListenerEffects: 0
BypassReverbZones: 0
rolloffCustomCurve:
serializedVersion: 2
m_Curve:
- serializedVersion: 3
time: 0
value: 1
inSlope: 0
outSlope: 0
tangentMode: 0
weightedMode: 0
inWeight: 0.33333334
outWeight: 0.33333334
- serializedVersion: 3
time: 1
value: 0
inSlope: 0
outSlope: 0
tangentMode: 0
weightedMode: 0
inWeight: 0.33333334
outWeight: 0.33333334
m_PreInfinity: 2
m_PostInfinity: 2
m_RotationOrder: 4
panLevelCustomCurve:
serializedVersion: 2
m_Curve:
- serializedVersion: 3
time: 0
value: 0
inSlope: 0
outSlope: 0
tangentMode: 0
weightedMode: 0
inWeight: 0.33333334
outWeight: 0.33333334
m_PreInfinity: 2
m_PostInfinity: 2
m_RotationOrder: 4
spreadCustomCurve:
serializedVersion: 2
m_Curve:
- serializedVersion: 3
time: 0
value: 0
inSlope: 0
outSlope: 0
tangentMode: 0
weightedMode: 0
inWeight: 0.33333334
outWeight: 0.33333334
m_PreInfinity: 2
m_PostInfinity: 2
m_RotationOrder: 4
reverbZoneMixCustomCurve:
serializedVersion: 2
m_Curve:
- serializedVersion: 3
time: 0
value: 1
inSlope: 0
outSlope: 0
tangentMode: 0
weightedMode: 0
inWeight: 0.33333334
outWeight: 0.33333334
m_PreInfinity: 2
m_PostInfinity: 2
m_RotationOrder: 4
--- !u!1 &1730898850
GameObject:
m_ObjectHideFlags: 0
@ -6921,8 +7217,8 @@ MonoBehaviour:
m_Calls: []
m_text: 0000
m_isRightToLeft: 0
m_fontAsset: {fileID: 11400000, guid: 72af27804d5aa49408430b4b2500f877, type: 2}
m_sharedMaterial: {fileID: 8890805173838430465, guid: 72af27804d5aa49408430b4b2500f877, type: 2}
m_fontAsset: {fileID: 11400000, guid: 8f586378b4e144a9851e7b34d9b748ee, type: 2}
m_sharedMaterial: {fileID: 2180264, guid: 8f586378b4e144a9851e7b34d9b748ee, type: 2}
m_fontSharedMaterials: []
m_fontMaterial: {fileID: 0}
m_fontMaterials: []
@ -6952,7 +7248,7 @@ MonoBehaviour:
m_enableAutoSizing: 0
m_fontSizeMin: 18
m_fontSizeMax: 72
m_fontStyle: 0
m_fontStyle: 1
m_HorizontalAlignment: 1
m_VerticalAlignment: 256
m_textAlignment: 65535
@ -7702,7 +7998,7 @@ GameObject:
- component: {fileID: 1996258853}
- component: {fileID: 1996258852}
m_Layer: 5
m_Name: Text (TMP)
m_Name: Timer.Counter
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
@ -7722,11 +8018,11 @@ RectTransform:
m_Children: []
m_Father: {fileID: 157938956}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 1, y: 1}
m_AnchorMin: {x: 0, y: 0}
m_AnchorMax: {x: 1, y: 1}
m_AnchoredPosition: {x: 128, y: -30}
m_SizeDelta: {x: 200, y: 50}
m_Pivot: {x: 1, y: 1}
m_AnchoredPosition: {x: -2.5, y: -12.5}
m_SizeDelta: {x: -5, y: -25}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!114 &1996258852
MonoBehaviour:
m_ObjectHideFlags: 0
@ -7774,15 +8070,15 @@ MonoBehaviour:
m_faceColor:
serializedVersion: 2
rgba: 4294967295
m_fontSize: 36
m_fontSizeBase: 36
m_fontSize: 52
m_fontSizeBase: 52
m_fontWeight: 400
m_enableAutoSizing: 0
m_fontSizeMin: 18
m_fontSizeMax: 72
m_fontStyle: 0
m_HorizontalAlignment: 1
m_VerticalAlignment: 256
m_fontStyle: 1
m_HorizontalAlignment: 2
m_VerticalAlignment: 512
m_textAlignment: 65535
m_characterSpacing: 0
m_wordSpacing: 0
@ -7810,7 +8106,7 @@ MonoBehaviour:
m_VertexBufferAutoSizeReduction: 0
m_useMaxVisibleDescender: 1
m_pageToDisplay: 1
m_margin: {x: 0, y: 0, z: 157.45232, w: 8.397432}
m_margin: {x: 0, y: 0, z: 0, w: 0}
m_isUsingLegacyAnimationComponent: 0
m_isVolumetricText: 0
m_hasFontAssetChanged: 0

View File

@ -3533,6 +3533,43 @@ RectTransform:
m_AnchoredPosition: {x: 0, y: 0}
m_SizeDelta: {x: 0, y: 0}
m_Pivot: {x: 0, y: 0}
--- !u!114 &1202782732
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1202782726}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 27a435387a7644784a6fc6ae538b68e5, type: 3}
m_Name:
m_EditorClassIdentifier:
currentPlayer:
name:
id:
creationDate: 0
explanationTime: 4
roomCodeField: {fileID: 2023851070}
roomError: {fileID: 991600093}
playerNameField: {fileID: 1163479463}
nameError: {fileID: 1224049646}
submitNewPlayer: {fileID: 1158329299}
listPlayersUI: {fileID: 1891690322}
submitStartGame: {fileID: 638947073}
counter: {fileID: 1383251891}
HomeConnection: {fileID: 2027556831}
WaitingRoom: {fileID: 1590939977}
BeforeStart: {fileID: 563000513}
TakePicture: {fileID: 1181392805}
VotePicture: {fileID: 531335861}
WaitingOtherPlayers: {fileID: 2095389711}
EndGame: {fileID: 1850164816}
myRoom:
code:
currentQuestion: 0
creationDate: 0
currentState: 0
--- !u!1 &1224049644
GameObject:
m_ObjectHideFlags: 0
@ -4096,7 +4133,7 @@ GameObject:
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 0
m_IsActive: 1
--- !u!224 &1383251890
RectTransform:
m_ObjectHideFlags: 0

View File

@ -9,10 +9,10 @@ public class Player
{
public string name;
public string id;
public float creationDate;
public double creationDate;
[JsonConstructor]
public Player(string _name, string _id, float _creationDate)
public Player(string _name, string _id, double _creationDate)
{
name = _name;
id = _id;
@ -23,7 +23,7 @@ public Player(string _name, string _id, float _creationDate)
public Player(string _name)
{
id = Guid.NewGuid().ToString();
creationDate = Time.time;
creationDate = DateTime.Now.ToOADate();
SetName(_name);
}

View File

@ -6,6 +6,7 @@
using Newtonsoft.Json;
using TMPro;
using UnityEngine;
using static UnityEditor.Experimental.AssetDatabaseExperimental.AssetDatabaseCounters;
/// <summary>
/// This is the game state manager on the phone side
@ -30,6 +31,9 @@ public class GameManager : MonoBehaviour
public TextMeshProUGUI listPlayersUI;
public GameObject submitStartGame;
[Header("Explanation Component")]
public TextMeshProUGUI counter;
[Header("Pages")]
public GameObject HomeConnection;
public GameObject WaitingRoom;
@ -42,6 +46,7 @@ public class GameManager : MonoBehaviour
private DatabaseReference realtimeDB;
public Room myRoom;
private DatabaseReference myOnlineRoom;
private DateTime endOfExplanationDate = DateTime.MinValue;
private void Awake()
{
@ -67,6 +72,20 @@ private void OnApplicationQuit()
});
}
private void Update()
{
if (myRoom.currentState == (int)GameState.Explanation && endOfExplanationDate != DateTime.MinValue )
{
TimeSpan duration = endOfExplanationDate - DateTime.Now;
counter.text = ((int)duration.TotalSeconds).ToString("D1");
if (duration.TotalMilliseconds <= 0)
{
Debug.Log("It's time to make proposition !");
}
}
}
private void Initialize()
{
@ -118,11 +137,11 @@ public void PlayerValidateNameAndServerRoom(string _name, string _code)
else
{
myOnlineRoom = realtimeDB.Child("rooms").Child(_code);
//subscribe to it
myOnlineRoom.ValueChanged += OnRoomUpdate;
//if room exists, join it
JoinRoom(() =>
{
//then subscribe to it
myOnlineRoom.ValueChanged += OnRoomUpdate;
myRoom.currentState = (int)GameState.WaitingForOtherPlayersToJoin;
players.Add(currentPlayer);
@ -271,7 +290,11 @@ private void OnRoomUpdate(object sender, ValueChangedEventArgs e)
{
try
{
myRoom = JsonConvert.DeserializeObject<Room>(e.Snapshot.GetRawJsonValue());
if (e!= null)
{
myRoom = JsonConvert.DeserializeObject<Room>(e.Snapshot.GetRawJsonValue());
}
}
catch (Exception ex)
{
@ -291,6 +314,9 @@ private void OnRoomUpdate(object sender, ValueChangedEventArgs e)
}
case (int)GameState.Explanation:
{
WaitingRoom.SetActive(false);
BeforeStart.SetActive(true);
endOfExplanationDate = DateTime.Now.AddSeconds(3);
break;
}
@ -323,9 +349,9 @@ private void CheckIfIAmTheFirst(List<Player> players)
if (players.Count > 1)
{
IOrderedEnumerable<Player> sortedList = players.OrderBy(x => x.creationDate);
List<Player> sortedList = players.OrderBy(x => x.creationDate).ToList();
if (sortedList.Last().id == currentPlayer.id)
if (sortedList[0].id == currentPlayer.id)
{
isFirst = true;
}

View File

@ -20,16 +20,19 @@ public class RoomManager : MonoBehaviour
[Header("Explanation Page")]
public GameObject explanationPage;
public TextMeshProUGUI counter;
public TextMeshProUGUI explanationCounter;
public float explanationTime;
private DateTime endOfExplanationDate = DateTime.MinValue;
public AudioClip counterSFX;
[Header("Waiting For Proposition Page")]
public GameObject waitingForPropositionsPage;
public List<TextMeshProUGUI> waitingForPropositionsLabels = new List<TextMeshProUGUI>();
public TextMeshProUGUI propositionCounter;
public float propositionTime = 60;
private float propositionCurrentTime = 0;
public TextMeshProUGUI timerGUI;
public List<TextMeshProUGUI> waitingForPropositionsLabels = new List<TextMeshProUGUI>();
private DateTime endOfPropositionDate = DateTime.MinValue;
[Header("Other")]
private Room myRoom = null;
public float votingTime = 20;
@ -54,14 +57,12 @@ private void Awake()
FirebaseInitializer.Instance.onFirebaseReady += Initialize;
}
private void Start()
{
explanationPage.SetActive(false);
waitingForPropositionsPage.SetActive(false);
waitingForPlayersPage.SetActive(true);
propositionCurrentTime = propositionTime;
votingCurrentTime = votingTime;
ResetAllPlayerLabels();
}
@ -74,7 +75,8 @@ private void Update()
if (myRoom.currentState == (int)GameState.Explanation && endOfExplanationDate != DateTime.MinValue)
{
TimeSpan duration = endOfExplanationDate - DateTime.Now;
counter.text = ((int)duration.TotalSeconds).ToString("D1");
explanationCounter.text = ((int)duration.TotalSeconds).ToString("D1");
if (duration.TotalMilliseconds <= 0)
{
@ -82,6 +84,13 @@ private void Update()
SendRoomState(GameState.MakeProposition);
}
}
if (myRoom.currentState == (int)GameState.MakeProposition && endOfPropositionDate != DateTime.MinValue)
{
TimeSpan duration = endOfPropositionDate - DateTime.Now;
propositionCounter.text = ((int)duration.TotalSeconds).ToString("D1");
}
}
private void SendRoomState(GameState _newState)
@ -217,7 +226,8 @@ public void HostStartGame()
{
waitingForPropositionsPage.SetActive(true);
waitingForPlayersPage.SetActive(false);
propositionCurrentTime = propositionTime;
endOfPropositionDate = DateTime.Now.AddSeconds(propositionTime);
AudioSource.PlayClipAtPoint(counterSFX, Vector3.zero);
}
/// <summary>
@ -339,7 +349,7 @@ private void OnRoomUpdate(object sender, ValueChangedEventArgs value)
case (int)GameState.Explanation:
waitingForPlayersPage.SetActive(false);
explanationPage.SetActive(true);
endOfExplanationDate = DateTime.Now.AddSeconds(3);
endOfExplanationDate = DateTime.Now.AddSeconds(explanationTime);
break;
case (int)GameState.MakeProposition:
HostStartGame();

File diff suppressed because one or more lines are too long