Compare commits

..

No commits in common. "8c825b0d0c49946edab3e6c5b68b25d5edd4ce98" and "937006e07c6f2f1b7886e9927021b3c08667204b" have entirely different histories.

24 changed files with 3332 additions and 1059 deletions

View File

@ -48,8 +48,8 @@ TextureImporter:
spriteMeshType: 1 spriteMeshType: 1
alignment: 0 alignment: 0
spritePivot: {x: 0.5, y: 0.5} spritePivot: {x: 0.5, y: 0.5}
spritePixelsToUnits: 500 spritePixelsToUnits: 100
spriteBorder: {x: 100, y: 100, z: 100, w: 100} spriteBorder: {x: 0, y: 0, z: 0, w: 0}
spriteGenerateFallbackPhysicsShape: 1 spriteGenerateFallbackPhysicsShape: 1
alphaUsage: 1 alphaUsage: 1
alphaIsTransparency: 1 alphaIsTransparency: 1
@ -139,7 +139,7 @@ TextureImporter:
physicsShape: [] physicsShape: []
bones: [] bones: []
spriteID: 5e97eb03825dee720800000000000000 spriteID: 5e97eb03825dee720800000000000000
internalID: 1537655665 internalID: 0
vertices: [] vertices: []
indices: indices:
edges: [] edges: []

View File

@ -48,8 +48,8 @@ TextureImporter:
spriteMeshType: 1 spriteMeshType: 1
alignment: 0 alignment: 0
spritePivot: {x: 0.5, y: 0.5} spritePivot: {x: 0.5, y: 0.5}
spritePixelsToUnits: 500 spritePixelsToUnits: 100
spriteBorder: {x: 100, y: 100, z: 100, w: 100} spriteBorder: {x: 0, y: 0, z: 0, w: 0}
spriteGenerateFallbackPhysicsShape: 1 spriteGenerateFallbackPhysicsShape: 1
alphaUsage: 1 alphaUsage: 1
alphaIsTransparency: 1 alphaIsTransparency: 1
@ -139,7 +139,7 @@ TextureImporter:
physicsShape: [] physicsShape: []
bones: [] bones: []
spriteID: 5e97eb03825dee720800000000000000 spriteID: 5e97eb03825dee720800000000000000
internalID: 1537655665 internalID: 0
vertices: [] vertices: []
indices: indices:
edges: [] edges: []

View File

@ -48,8 +48,8 @@ TextureImporter:
spriteMeshType: 1 spriteMeshType: 1
alignment: 0 alignment: 0
spritePivot: {x: 0.5, y: 0.5} spritePivot: {x: 0.5, y: 0.5}
spritePixelsToUnits: 500 spritePixelsToUnits: 100
spriteBorder: {x: 100, y: 100, z: 100, w: 100} spriteBorder: {x: 0, y: 0, z: 0, w: 0}
spriteGenerateFallbackPhysicsShape: 1 spriteGenerateFallbackPhysicsShape: 1
alphaUsage: 1 alphaUsage: 1
alphaIsTransparency: 1 alphaIsTransparency: 1
@ -139,7 +139,7 @@ TextureImporter:
physicsShape: [] physicsShape: []
bones: [] bones: []
spriteID: 5e97eb03825dee720800000000000000 spriteID: 5e97eb03825dee720800000000000000
internalID: 1537655665 internalID: 0
vertices: [] vertices: []
indices: indices:
edges: [] edges: []

View File

@ -48,8 +48,8 @@ TextureImporter:
spriteMeshType: 1 spriteMeshType: 1
alignment: 0 alignment: 0
spritePivot: {x: 0.5, y: 0.5} spritePivot: {x: 0.5, y: 0.5}
spritePixelsToUnits: 500 spritePixelsToUnits: 100
spriteBorder: {x: 100, y: 100, z: 100, w: 100} spriteBorder: {x: 0, y: 0, z: 0, w: 0}
spriteGenerateFallbackPhysicsShape: 1 spriteGenerateFallbackPhysicsShape: 1
alphaUsage: 1 alphaUsage: 1
alphaIsTransparency: 1 alphaIsTransparency: 1
@ -139,7 +139,7 @@ TextureImporter:
physicsShape: [] physicsShape: []
bones: [] bones: []
spriteID: 5e97eb03825dee720800000000000000 spriteID: 5e97eb03825dee720800000000000000
internalID: 1537655665 internalID: 0
vertices: [] vertices: []
indices: indices:
edges: [] edges: []

View File

@ -48,8 +48,8 @@ TextureImporter:
spriteMeshType: 1 spriteMeshType: 1
alignment: 0 alignment: 0
spritePivot: {x: 0.5, y: 0.5} spritePivot: {x: 0.5, y: 0.5}
spritePixelsToUnits: 500 spritePixelsToUnits: 100
spriteBorder: {x: 100, y: 100, z: 100, w: 100} spriteBorder: {x: 0, y: 0, z: 0, w: 0}
spriteGenerateFallbackPhysicsShape: 1 spriteGenerateFallbackPhysicsShape: 1
alphaUsage: 1 alphaUsage: 1
alphaIsTransparency: 1 alphaIsTransparency: 1
@ -139,7 +139,7 @@ TextureImporter:
physicsShape: [] physicsShape: []
bones: [] bones: []
spriteID: 5e97eb03825dee720800000000000000 spriteID: 5e97eb03825dee720800000000000000
internalID: 1537655665 internalID: 0
vertices: [] vertices: []
indices: indices:
edges: [] edges: []

View File

@ -48,8 +48,8 @@ TextureImporter:
spriteMeshType: 1 spriteMeshType: 1
alignment: 0 alignment: 0
spritePivot: {x: 0.5, y: 0.5} spritePivot: {x: 0.5, y: 0.5}
spritePixelsToUnits: 500 spritePixelsToUnits: 100
spriteBorder: {x: 100, y: 100, z: 100, w: 100} spriteBorder: {x: 0, y: 0, z: 0, w: 0}
spriteGenerateFallbackPhysicsShape: 1 spriteGenerateFallbackPhysicsShape: 1
alphaUsage: 1 alphaUsage: 1
alphaIsTransparency: 1 alphaIsTransparency: 1
@ -139,7 +139,7 @@ TextureImporter:
physicsShape: [] physicsShape: []
bones: [] bones: []
spriteID: 5e97eb03825dee720800000000000000 spriteID: 5e97eb03825dee720800000000000000
internalID: 1537655665 internalID: 0
vertices: [] vertices: []
indices: indices:
edges: [] edges: []

View File

@ -48,8 +48,8 @@ TextureImporter:
spriteMeshType: 1 spriteMeshType: 1
alignment: 0 alignment: 0
spritePivot: {x: 0.5, y: 0.5} spritePivot: {x: 0.5, y: 0.5}
spritePixelsToUnits: 500 spritePixelsToUnits: 100
spriteBorder: {x: 100, y: 100, z: 100, w: 100} spriteBorder: {x: 0, y: 0, z: 0, w: 0}
spriteGenerateFallbackPhysicsShape: 1 spriteGenerateFallbackPhysicsShape: 1
alphaUsage: 1 alphaUsage: 1
alphaIsTransparency: 1 alphaIsTransparency: 1
@ -139,7 +139,7 @@ TextureImporter:
physicsShape: [] physicsShape: []
bones: [] bones: []
spriteID: 5e97eb03825dee720800000000000000 spriteID: 5e97eb03825dee720800000000000000
internalID: 1537655665 internalID: 0
vertices: [] vertices: []
indices: indices:
edges: [] edges: []

View File

@ -48,8 +48,8 @@ TextureImporter:
spriteMeshType: 1 spriteMeshType: 1
alignment: 0 alignment: 0
spritePivot: {x: 0.5, y: 0.5} spritePivot: {x: 0.5, y: 0.5}
spritePixelsToUnits: 500 spritePixelsToUnits: 100
spriteBorder: {x: 100, y: 100, z: 100, w: 100} spriteBorder: {x: 0, y: 0, z: 0, w: 0}
spriteGenerateFallbackPhysicsShape: 1 spriteGenerateFallbackPhysicsShape: 1
alphaUsage: 1 alphaUsage: 1
alphaIsTransparency: 1 alphaIsTransparency: 1

BIN
Assets/2DAssets/ScoreVoteTexture/8.png (Stored with Git LFS) Normal file

Binary file not shown.

View File

@ -0,0 +1,153 @@
fileFormatVersion: 2
guid: c5f7aa046abe3604c9db077a80ee3fc2
TextureImporter:
internalIDToNameTable: []
externalObjects: {}
serializedVersion: 12
mipmaps:
mipMapMode: 0
enableMipMap: 0
sRGBTexture: 1
linearTexture: 0
fadeOut: 0
borderMipMap: 0
mipMapsPreserveCoverage: 0
alphaTestReferenceValue: 0.5
mipMapFadeDistanceStart: 1
mipMapFadeDistanceEnd: 3
bumpmap:
convertToNormalMap: 0
externalNormalMap: 0
heightScale: 0.25
normalMapFilter: 0
flipGreenChannel: 0
isReadable: 0
streamingMipmaps: 0
streamingMipmapsPriority: 0
vTOnly: 0
ignoreMipmapLimit: 0
grayScaleToAlpha: 0
generateCubemap: 6
cubemapConvolution: 0
seamlessCubemap: 0
textureFormat: 1
maxTextureSize: 2048
textureSettings:
serializedVersion: 2
filterMode: 1
aniso: 1
mipBias: 0
wrapU: 1
wrapV: 1
wrapW: 0
nPOTScale: 0
lightmap: 0
compressionQuality: 50
spriteMode: 1
spriteExtrude: 1
spriteMeshType: 1
alignment: 0
spritePivot: {x: 0.5, y: 0.5}
spritePixelsToUnits: 100
spriteBorder: {x: 100, y: 100, z: 100, w: 100}
spriteGenerateFallbackPhysicsShape: 1
alphaUsage: 1
alphaIsTransparency: 1
spriteTessellationDetail: -1
textureType: 8
textureShape: 1
singleChannelComponent: 0
flipbookRows: 1
flipbookColumns: 1
maxTextureSizeSet: 0
compressionQualitySet: 0
textureFormatSet: 0
ignorePngGamma: 0
applyGammaDecoding: 0
swizzle: 50462976
cookieLightType: 0
platformSettings:
- serializedVersion: 3
buildTarget: DefaultTexturePlatform
maxTextureSize: 2048
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
ignorePlatformSupport: 0
androidETC2FallbackOverride: 0
forceMaximumCompressionQuality_BC6H_BC7: 0
- serializedVersion: 3
buildTarget: Standalone
maxTextureSize: 2048
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
ignorePlatformSupport: 0
androidETC2FallbackOverride: 0
forceMaximumCompressionQuality_BC6H_BC7: 0
- serializedVersion: 3
buildTarget: iPhone
maxTextureSize: 2048
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
ignorePlatformSupport: 0
androidETC2FallbackOverride: 0
forceMaximumCompressionQuality_BC6H_BC7: 0
- serializedVersion: 3
buildTarget: Android
maxTextureSize: 2048
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
ignorePlatformSupport: 0
androidETC2FallbackOverride: 0
forceMaximumCompressionQuality_BC6H_BC7: 0
- serializedVersion: 3
buildTarget: Server
maxTextureSize: 2048
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
ignorePlatformSupport: 0
androidETC2FallbackOverride: 0
forceMaximumCompressionQuality_BC6H_BC7: 0
spriteSheet:
serializedVersion: 2
sprites: []
outline: []
physicsShape: []
bones: []
spriteID: 5e97eb03825dee720800000000000000
internalID: 1537655665
vertices: []
indices:
edges: []
weights: []
secondaryTextures: []
nameFileIdTable: {}
mipmapLimitGroupName:
pSDRemoveMatte: 0
userData:
assetBundleName:
assetBundleVariant:

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 960796ead2964d54d9cf0b50f3f052e5
PrefabImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -65,10 +65,10 @@ MonoBehaviour:
m_OnCullStateChanged: m_OnCullStateChanged:
m_PersistentCalls: m_PersistentCalls:
m_Calls: [] m_Calls: []
m_text: 01234567891234567 m_text: playernamevraimentlong
m_isRightToLeft: 0 m_isRightToLeft: 0
m_fontAsset: {fileID: 11400000, guid: 72af27804d5aa49408430b4b2500f877, type: 2} m_fontAsset: {fileID: 11400000, guid: 72af27804d5aa49408430b4b2500f877, type: 2}
m_sharedMaterial: {fileID: 2100000, guid: 9fb4d071241c54841ab116886c83b585, type: 2} m_sharedMaterial: {fileID: 8890805173838430465, guid: 72af27804d5aa49408430b4b2500f877, type: 2}
m_fontSharedMaterials: [] m_fontSharedMaterials: []
m_fontMaterial: {fileID: 0} m_fontMaterial: {fileID: 0}
m_fontMaterials: [] m_fontMaterials: []
@ -92,12 +92,12 @@ MonoBehaviour:
m_faceColor: m_faceColor:
serializedVersion: 2 serializedVersion: 2
rgba: 4294967295 rgba: 4294967295
m_fontSize: 25.55 m_fontSize: 36
m_fontSizeBase: 36 m_fontSizeBase: 36
m_fontWeight: 400 m_fontWeight: 400
m_enableAutoSizing: 1 m_enableAutoSizing: 0
m_fontSizeMin: 18 m_fontSizeMin: 18
m_fontSizeMax: 36 m_fontSizeMax: 72
m_fontStyle: 0 m_fontStyle: 0
m_HorizontalAlignment: 2 m_HorizontalAlignment: 2
m_VerticalAlignment: 512 m_VerticalAlignment: 512
@ -192,14 +192,14 @@ MonoBehaviour:
m_Name: m_Name:
m_EditorClassIdentifier: m_EditorClassIdentifier:
m_Material: {fileID: 0} m_Material: {fileID: 0}
m_Color: {r: 1, g: 1, b: 1, a: 1} m_Color: {r: 0.854902, g: 0.75294125, b: 0.76470596, a: 1}
m_RaycastTarget: 1 m_RaycastTarget: 1
m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0} m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0}
m_Maskable: 1 m_Maskable: 1
m_OnCullStateChanged: m_OnCullStateChanged:
m_PersistentCalls: m_PersistentCalls:
m_Calls: [] m_Calls: []
m_Sprite: {fileID: 21300000, guid: 2976887ec0d7c0449a05a497c5e28353, type: 3} m_Sprite: {fileID: 0}
m_Type: 1 m_Type: 1
m_PreserveAspect: 0 m_PreserveAspect: 0
m_FillCenter: 1 m_FillCenter: 1
@ -218,9 +218,9 @@ GameObject:
serializedVersion: 6 serializedVersion: 6
m_Component: m_Component:
- component: {fileID: 943229596838791819} - component: {fileID: 943229596838791819}
- component: {fileID: 9117562908589005100} - component: {fileID: -3919290783414862184}
m_Layer: 5 m_Layer: 5
m_Name: PlayerSticker m_Name: VoterSticker
m_TagString: Untagged m_TagString: Untagged
m_Icon: {fileID: 0} m_Icon: {fileID: 0}
m_NavMeshLayer: 0 m_NavMeshLayer: 0
@ -247,7 +247,7 @@ RectTransform:
m_AnchoredPosition: {x: -427, y: 38} m_AnchoredPosition: {x: -427, y: 38}
m_SizeDelta: {x: 200, y: 100} m_SizeDelta: {x: 200, y: 100}
m_Pivot: {x: 0.5, y: 0.5} m_Pivot: {x: 0.5, y: 0.5}
--- !u!114 &9117562908589005100 --- !u!114 &-3919290783414862184
MonoBehaviour: MonoBehaviour:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0} m_CorrespondingSourceObject: {fileID: 0}
@ -260,13 +260,3 @@ MonoBehaviour:
m_Name: m_Name:
m_EditorClassIdentifier: m_EditorClassIdentifier:
playerNameLabel: {fileID: 2430977146559507814} playerNameLabel: {fileID: 2430977146559507814}
background: {fileID: 5096287721252539344}
colors:
- {fileID: 21300000, guid: fd34549f885408249a297cc6a21c81c9, type: 3}
- {fileID: 21300000, guid: 0ee0312f568806b478a366909c99109e, type: 3}
- {fileID: 21300000, guid: 9f910186744147d4fa07dac46709683b, type: 3}
- {fileID: 21300000, guid: 1d168eaa4018b5f4f9fe8fed55f26673, type: 3}
- {fileID: 21300000, guid: 1db45b8963eb22947b0eff6942e33aaa, type: 3}
- {fileID: 21300000, guid: 023e2f1ca34256849b141980d26cfc38, type: 3}
- {fileID: 21300000, guid: eaa71830df5ab274b8be23a296887907, type: 3}
- {fileID: 21300000, guid: 2976887ec0d7c0449a05a497c5e28353, type: 3}

File diff suppressed because it is too large Load Diff

View File

@ -2613,7 +2613,7 @@ RectTransform:
m_AnchorMin: {x: 1, y: 0} m_AnchorMin: {x: 1, y: 0}
m_AnchorMax: {x: 1, y: 0} m_AnchorMax: {x: 1, y: 0}
m_AnchoredPosition: {x: -62.99997, y: 73} m_AnchoredPosition: {x: -62.99997, y: 73}
m_SizeDelta: {x: 213.5, y: 50} m_SizeDelta: {x: 160, y: 50}
m_Pivot: {x: 1, y: 0} m_Pivot: {x: 1, y: 0}
--- !u!114 &885941123 --- !u!114 &885941123
MonoBehaviour: MonoBehaviour:
@ -2669,7 +2669,7 @@ MonoBehaviour:
m_fontSizeMin: 18 m_fontSizeMin: 18
m_fontSizeMax: 72 m_fontSizeMax: 72
m_fontStyle: 0 m_fontStyle: 0
m_HorizontalAlignment: 4 m_HorizontalAlignment: 2
m_VerticalAlignment: 512 m_VerticalAlignment: 512
m_textAlignment: 65535 m_textAlignment: 65535
m_characterSpacing: 0 m_characterSpacing: 0

View File

@ -76,12 +76,7 @@ public void SetPlayersAreReady(int _state)
currentState = _state; currentState = _state;
} }
/// <summary> public List<Proposition> GetPropositionsByPlayer(Player player)
/// Return all the propositions linked to a specific player.
/// </summary>
/// <param name="player"></param>
/// <returns></returns>
public List<Proposition> GetPropositionsForPlayer(Player player)
{ {
List<Proposition> playerPropositions = new(); List<Proposition> playerPropositions = new();

View File

@ -1,21 +0,0 @@
using System.Collections;
using System.Collections.Generic;
using TMPro;
using UnityEngine;
using UnityEngine.UI;
public class PlayerSticker : MonoBehaviour
{
[Header("References")]
[SerializeField] private TextMeshProUGUI playerNameLabel;
[SerializeField] private Image background;
[SerializeField] private List<Sprite> colors;
public void Initialize(string _playerName, int _index)
{
playerNameLabel.text = _playerName;
background.sprite = colors[_index];
}
}

View File

@ -1,7 +1,6 @@
using System; using System;
using System.Collections; using System.Collections;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq;
using Firebase.Extensions; using Firebase.Extensions;
using Firebase.Storage; using Firebase.Storage;
using TMPro; using TMPro;
@ -16,23 +15,17 @@ public class PropositionFrame : MonoBehaviour
public TextMeshProUGUI playerName; public TextMeshProUGUI playerName;
public Transform playerGrid; public Transform playerGrid;
private Dictionary<Player, GameObject> currentVoters = new Dictionary<Player, GameObject>(); private List<Player> currentVoters = new List<Player>();
private Proposition proposition; private Proposition proposition;
public void Initialize(Proposition _proposition) public void Initialize(Proposition _proposition)
{ {
Debug.Log($"Initializing {_proposition.owner.name}'s proposition", this); //Debug.Log($"Initializing {_proposition.owner.name}'s proposition", this);
proposition = _proposition; proposition = _proposition;
playerName.text = proposition.owner.name; playerName.text = proposition.owner.name;
if (!string.IsNullOrEmpty(proposition.photoUrl)) if (!string.IsNullOrEmpty(proposition.photoUrl))
DisplayPicture(proposition.photoUrl); DisplayPicture(proposition.photoUrl);
foreach(var voters in currentVoters)
{
Destroy(voters.Value);
}
currentVoters.Clear();
} }
/// <summary> /// <summary>
@ -55,15 +48,13 @@ private void DisplayPicture(string _gsUrl)
public void UpdateVoters(List<Player> _newVoters) public void UpdateVoters(List<Player> _newVoters)
{ {
//Debug.Log($"There are some new voters for {proposition.owner}'s proposition", this); //Debug.Log($"There are some new voters for {proposition.owner}'s proposition", this);
int index = 0;
foreach (Player p in _newVoters) foreach (Player p in _newVoters)
{ {
index++; if (!currentVoters.Contains(p))
if (!currentVoters.Keys.Contains(p))
{ {
PlayerSticker sticker = Instantiate(voterStickerPrefab, playerGrid).GetComponent<PlayerSticker>(); currentVoters.Add(p);
sticker.Initialize(p.name, index); VoterSticker sticker = Instantiate(voterStickerPrefab, playerGrid).GetComponent<VoterSticker>();
currentVoters.Add(p, sticker.gameObject); sticker.playerNameLabel.text = p.name;
Debug.Log($"{p.name} has just voted for {proposition.owner.name}'s proposition."); Debug.Log($"{p.name} has just voted for {proposition.owner.name}'s proposition.");
} }
} }

View File

@ -12,94 +12,69 @@ public class QuestionHandler : MonoBehaviour
public PromptList promptList; public PromptList promptList;
private GameManager gameManager; private GameManager gameManager;
private List<Question> questionsToAnswer; private List<Question> player2questions;
private int activeAnsweredQuestionIndex = 0; private int currentQuestion = 0;
private const int FirstQuestionIndex = 0;
private const int SecondQuestionIndex = 1;
/// <summary>
/// Called when the script is enabled.
/// Initializes the GameManager and questionsToAnswer list, and updates the UI.
/// </summary>
void OnEnable() void OnEnable()
{ {
gameManager = managers.GetComponent<GameManager>(); gameManager = managers.GetComponent<GameManager>();
questionsToAnswer = gameManager.myRoom.GetQuestionsByPlayer(gameManager.currentPlayer); player2questions = gameManager.myRoom.GetQuestionsByPlayer(gameManager.currentPlayer);
Redraw(activeAnsweredQuestionIndex); Redraw(currentQuestion);
} }
/// <summary>
/// Called when the script is disabled.
/// Cleans up resources and resets the activeAnsweredQuestionIndex.
/// </summary>
void OnDisable() void OnDisable()
{ {
questionsToAnswer = null; player2questions = null;
activeAnsweredQuestionIndex = FirstQuestionIndex; currentQuestion = 0;
} }
/// <summary>
/// Redraws the UI with the information from the current question.
/// </summary>
/// <param name="currentQuestion">The index of the current question to display.</param>
void Redraw(int currentQuestion) void Redraw(int currentQuestion)
{ {
Prompt prompt = promptList.prompts.Find(x => x.id == questionsToAnswer[currentQuestion].promptId); Prompt prompt = promptList.prompts.Find(x => x.id == player2questions[currentQuestion].promptId);
//Debug.Log(JsonUtility.ToJson(prompt));
explainText.SetText(prompt.en); explainText.SetText(prompt.en);
CameraManager cameraManager = gameObject.GetComponent<CameraManager>(); CameraManager cameraManager = gameObject.GetComponent<CameraManager>();
cameraManager.WebcamResume(); cameraManager.WebcamResume();
} }
/// <summary> int GetPropRef(Player player)
/// Gets the index of the proposition owned by a player for the current question.
/// </summary>
/// <param name="_playerId">The player's ID for whom the proposition index is retrieved.</param>
/// <returns>The index of the proposition for the player.</returns>
int GetPropositionIndex(string _playerId)
{ {
return questionsToAnswer[activeAnsweredQuestionIndex].propositions.First(x => x.Value.owner.id == _playerId).Key; return gameManager.myRoom.questions[currentQuestion].propositions.First(x => x.Value.owner.id == player.id).Key;
} }
/// <summary>
/// Handles the click event of the submit button.
/// Uploads a photo and manages the UI accordingly.
/// </summary>
public void OnSubmitButton() public void OnSubmitButton()
{ {
submitButton.interactable = false; submitButton.interactable = false;
submitButton.GetComponent<TextMeshProUGUI>().text = "Uploading..."; submitButton.GetComponent<TextMeshProUGUI>().text = "Uploading...";
StorageManager storageManager = managers.GetComponent<StorageManager>(); managers.GetComponent<StorageManager>().UploadPhoto(
if (storageManager != null)
{
storageManager.UploadPhoto(
gameManager.myRoom.code, gameManager.myRoom.code,
gameManager.currentPlayer.id, gameManager.currentPlayer.id,
questionsToAnswer[activeAnsweredQuestionIndex].index, currentQuestion,
GetPropositionIndex(gameManager.currentPlayer.id), GetPropRef(gameManager.currentPlayer),
succeed => succeed =>
{ {
if (!succeed) if(!succeed)
{ {
Debug.LogError("Photo upload failed. Please do something.", this); Debug.LogError("Photo upload failed. please do something", this);
return; return;
} }
if (activeAnsweredQuestionIndex == SecondQuestionIndex) if (currentQuestion == 1)
{ {
gameManager.WaitForPlayers(); gameManager.WaitForPlayers();
return;
} }
else else
{ {
submitButton.interactable = true; submitButton.interactable = true;
submitButton.GetComponent<TextMeshProUGUI>().text = "Submit"; submitButton.GetComponent<TextMeshProUGUI>().text = "Submit";
activeAnsweredQuestionIndex = SecondQuestionIndex; currentQuestion++;
Redraw(activeAnsweredQuestionIndex); Redraw(currentQuestion);
} }
}); });
} }
}
} }

View File

@ -20,7 +20,7 @@ public class RoomManager : MonoBehaviour
/// </summary> /// </summary>
public TextMeshProUGUI roomCodeLabel; public TextMeshProUGUI roomCodeLabel;
public AudioClip playerJoinSFX; public AudioClip playerJoinSFX;
public List<PlayerSticker> playerStickers = new List<PlayerSticker>(); public List<TextMeshProUGUI> waitingForPlayersLabels = new List<TextMeshProUGUI>();
[Header("Explanation Page")] [Header("Explanation Page")]
public GameObject explanationPage; public GameObject explanationPage;
@ -86,9 +86,9 @@ private void SendRoomState(GameState _newState)
private void ResetAllPlayerLabels() private void ResetAllPlayerLabels()
{ {
for (int i = 0; i < playerStickers.Count; i++) for (int i = 0; i < waitingForPlayersLabels.Count; i++)
{ {
playerStickers[i].Initialize($"Waiting for P{i + 1}", i); waitingForPlayersLabels[i].text = $"Waiting for P{i + 1}";
} }
} }
@ -315,7 +315,7 @@ private void UpdateConnectedPlayerList(List<Player> _players)
for (int i = 0; i < orderedPlayers.Count; i++) for (int i = 0; i < orderedPlayers.Count; i++)
{ {
Debug.Log($"player {i} = {orderedPlayers[i].name}"); Debug.Log($"player {i} = {orderedPlayers[i].name}");
playerStickers[i].Initialize(orderedPlayers[i].name, i); waitingForPlayersLabels[i].text = orderedPlayers[i].name;
} }
} }

View File

@ -0,0 +1,9 @@
using System.Collections;
using System.Collections.Generic;
using TMPro;
using UnityEngine;
public class VoterSticker : MonoBehaviour
{
public TextMeshProUGUI playerNameLabel;
}

View File

@ -81,7 +81,7 @@ private void CheckPlayersWhoHaveProposed()
continue; continue;
bool playerHasAnsweredBothProposition = true; bool playerHasAnsweredBothProposition = true;
Proposition[] propositions = myRoom.GetPropositionsForPlayer(player).ToArray(); Proposition[] propositions = myRoom.GetPropositionsByPlayer(player).ToArray();
//Debug.Log($"I found {propositions.Length} propositions for {player.name}", this); //Debug.Log($"I found {propositions.Length} propositions for {player.name}", this);
if (propositions.Length < 2) if (propositions.Length < 2)