update music manager and fix voting page
This commit is contained in:
parent
e105360132
commit
f5a938f314
@ -1788,6 +1788,7 @@ GameObject:
|
||||
- component: {fileID: 375256414}
|
||||
- component: {fileID: 375256413}
|
||||
- component: {fileID: 375256412}
|
||||
- component: {fileID: 375256415}
|
||||
m_Layer: 0
|
||||
m_Name: '[Managers]'
|
||||
m_TagString: Untagged
|
||||
@ -1835,7 +1836,7 @@ MonoBehaviour:
|
||||
- {fileID: 1854893636}
|
||||
- {fileID: 2065109614}
|
||||
- {fileID: 1197279072}
|
||||
votingPage: {fileID: 0}
|
||||
votingPage: {fileID: 1660260835}
|
||||
promptList: {fileID: 11400000, guid: 21907abc84e40403ca34c4fb9ab30b06, type: 2}
|
||||
--- !u!114 &375256413
|
||||
MonoBehaviour:
|
||||
@ -1866,6 +1867,29 @@ Transform:
|
||||
- {fileID: 1937957482}
|
||||
m_Father: {fileID: 0}
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
--- !u!114 &375256415
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 375256411}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: ccc6142918f2946509e0c02fbe0df427, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
musicSource: {fileID: 1277491651}
|
||||
sfxSource: {fileID: 1937957483}
|
||||
musics:
|
||||
- title: 0
|
||||
clip: {fileID: 8300000, guid: 7ac3efdb5c840704aafbf19188b3e61e, type: 3}
|
||||
- title: 1
|
||||
clip: {fileID: 8300000, guid: 0e86c0433979a2d4c884b368808d3cdf, type: 3}
|
||||
- title: 2
|
||||
clip: {fileID: 8300000, guid: d782d7e00ee5a0d40a3c005d87c15b3a, type: 3}
|
||||
- title: 3
|
||||
clip: {fileID: 8300000, guid: e1135788bf319bd42b6ca512976f9028, type: 3}
|
||||
--- !u!1 &411140634
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
@ -5641,9 +5665,8 @@ GameObject:
|
||||
m_Component:
|
||||
- component: {fileID: 1277491650}
|
||||
- component: {fileID: 1277491651}
|
||||
- component: {fileID: 1277491652}
|
||||
m_Layer: 0
|
||||
m_Name: MusicManager
|
||||
m_Name: MusicSource
|
||||
m_TagString: Untagged
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
@ -5760,27 +5783,6 @@ AudioSource:
|
||||
m_PreInfinity: 2
|
||||
m_PostInfinity: 2
|
||||
m_RotationOrder: 4
|
||||
--- !u!114 &1277491652
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 1277491649}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: ccc6142918f2946509e0c02fbe0df427, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
musics:
|
||||
- title: 0
|
||||
clip: {fileID: 8300000, guid: 7ac3efdb5c840704aafbf19188b3e61e, type: 3}
|
||||
- title: 1
|
||||
clip: {fileID: 8300000, guid: 0e86c0433979a2d4c884b368808d3cdf, type: 3}
|
||||
- title: 2
|
||||
clip: {fileID: 8300000, guid: d782d7e00ee5a0d40a3c005d87c15b3a, type: 3}
|
||||
- title: 3
|
||||
clip: {fileID: 8300000, guid: e1135788bf319bd42b6ca512976f9028, type: 3}
|
||||
--- !u!1 &1318111281
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
@ -9238,7 +9240,7 @@ GameObject:
|
||||
- component: {fileID: 1937957482}
|
||||
- component: {fileID: 1937957483}
|
||||
m_Layer: 0
|
||||
m_Name: SFXManager
|
||||
m_Name: SFXSource
|
||||
m_TagString: Untagged
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
|
@ -18,6 +18,7 @@ private void Awake()
|
||||
|
||||
public void ChangeMusic(MusicTitle _title)
|
||||
{
|
||||
Debug.Log($"changing music to {_title}");
|
||||
musicSource.clip = musics.Find(x => x.title == _title).clip;
|
||||
musicSource.Play();
|
||||
}
|
||||
@ -29,6 +30,7 @@ public void StopMusic()
|
||||
|
||||
public void PlaySFX(AudioClip _clip)
|
||||
{
|
||||
Debug.Log($"playing {_clip.name} SFX");
|
||||
sfxSource.PlayOneShot(_clip);
|
||||
}
|
||||
}
|
||||
|
@ -6,17 +6,8 @@
|
||||
[JsonObject]
|
||||
public class Question
|
||||
{
|
||||
public string id;
|
||||
public int index;
|
||||
public string promptId;
|
||||
public Dictionary<int, Proposition> propositions;
|
||||
public double creationDate;
|
||||
|
||||
public Proposition GetFirstProposition()
|
||||
{
|
||||
return propositions[0];
|
||||
}
|
||||
public Proposition GetSecondProposition()
|
||||
{
|
||||
return propositions[1];
|
||||
}
|
||||
}
|
||||
|
@ -304,7 +304,7 @@ public void GeneratePrompts()
|
||||
|
||||
questions.Add(i, new Question()
|
||||
{
|
||||
id = Guid.NewGuid().ToString(),
|
||||
index = i,
|
||||
promptId = prompts[i].id,
|
||||
propositions = propositions,
|
||||
creationDate = DateTime.Now.ToOADate(),
|
||||
|
@ -1,6 +1,7 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Firebase.Database;
|
||||
using TMPro;
|
||||
using UnityEngine;
|
||||
@ -66,14 +67,16 @@ public void ShowVotingPage(DatabaseReference _roomRef, Dictionary<string, Player
|
||||
currentPlayers = _currentPlayers;
|
||||
OnVoteEnded = _callback_OnVoteEnded;
|
||||
|
||||
foreach (Dictionary<int, Question> QuestionByID in _questions)
|
||||
Question[] _questionArray = _questions.Values.ToArray();
|
||||
|
||||
for (int i = 0; i < _questionArray.Length; i++)
|
||||
{
|
||||
remainingQuestions.Enqueue(QuestionByID.Value);
|
||||
roomRef.Child("questions").Child(QuestionByID.Key).ValueChanged += OnQuestionChanged;
|
||||
remainingQuestions.Enqueue(_questionArray[i]);
|
||||
roomRef.Child("questions").Child(i.ToString()).ValueChanged += OnQuestionChanged;
|
||||
}
|
||||
|
||||
currentQuestion = remainingQuestions.Dequeue();
|
||||
roomRef.Child("currentQuestion").SetValueAsync(currentQuestion.id);
|
||||
roomRef.Child("currentQuestion").SetValueAsync(currentQuestion.index);
|
||||
ShowQuestion();
|
||||
}
|
||||
|
||||
@ -85,8 +88,8 @@ void ShowQuestion()
|
||||
|
||||
Debug.Log($"Prompt is {currentPromptLabel.text}", this);
|
||||
|
||||
proposition1.Initialize(currentQuestion.GetFirstProposition());
|
||||
proposition1.Initialize(currentQuestion.GetSecondProposition());
|
||||
proposition1.Initialize(currentQuestion.propositions[0]);
|
||||
proposition1.Initialize(currentQuestion.propositions[1]);
|
||||
endOfTimer = DateTime.Now.AddSeconds(votingTime);
|
||||
}
|
||||
|
||||
@ -102,10 +105,10 @@ private void OnQuestionChanged(object sender, ValueChangedEventArgs _questionRef
|
||||
Question question = Newtonsoft.Json.JsonConvert.DeserializeObject<Question>(JSON);
|
||||
|
||||
//if someone succeeded to vote for another question than the one that is displayed => yeet
|
||||
if (question.id != currentQuestion.id)
|
||||
if (question.index != currentQuestion.index)
|
||||
return;
|
||||
|
||||
Debug.Log($"someone has voted for {question.id}", this);
|
||||
Debug.Log($"someone has voted for {question.index}", this);
|
||||
currentQuestion.propositions = question.propositions;
|
||||
UpdateVoters();
|
||||
|
||||
@ -114,13 +117,13 @@ private void OnQuestionChanged(object sender, ValueChangedEventArgs _questionRef
|
||||
private void UpdateVoters()
|
||||
{
|
||||
List<Player> playersThatHasVotedForFirstProposition = new List<Player>();
|
||||
foreach (string playerId in currentQuestion.GetFirstProposition().voters)
|
||||
foreach (string playerId in currentQuestion.propositions[0].voters)
|
||||
{
|
||||
playersThatHasVotedForFirstProposition.Add(currentPlayers[playerId]);
|
||||
}
|
||||
|
||||
List<Player> playersThatHasVotedForSecondProposition = new List<Player>();
|
||||
foreach (string playerId in currentQuestion.GetSecondProposition().voters)
|
||||
foreach (string playerId in currentQuestion.propositions[1].voters)
|
||||
{
|
||||
playersThatHasVotedForSecondProposition.Add(currentPlayers[playerId]);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user