Compare commits

...

4 Commits

Author SHA1 Message Date
Fangh
8c825b0d0c fix: the correct questions should be sent to the correct players 2024-01-31 22:34:50 +01:00
Fangh
7e4416824e fix: uploading text was on two lines 2024-01-31 22:05:23 +01:00
Fangh
74f732f1f3 fix: voter stickers are reset between each vote 2024-01-31 22:05:08 +01:00
Fangh
580dbbdca8 feat: new voter sticerks 2024-01-31 22:04:51 +01:00
24 changed files with 1059 additions and 3332 deletions

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

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

Binary file not shown.

View File

@ -1,153 +0,0 @@
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:

View File

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

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

File diff suppressed because it is too large Load Diff

View File

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

View File

@ -76,7 +76,12 @@ public void SetPlayersAreReady(int _state)
currentState = _state;
}
public List<Proposition> GetPropositionsByPlayer(Player player)
/// <summary>
/// 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();

View File

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

View File

@ -12,69 +12,94 @@ public class QuestionHandler : MonoBehaviour
public PromptList promptList;
private GameManager gameManager;
private List<Question> player2questions;
private int currentQuestion = 0;
private List<Question> questionsToAnswer;
private int activeAnsweredQuestionIndex = 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()
{
gameManager = managers.GetComponent<GameManager>();
player2questions = gameManager.myRoom.GetQuestionsByPlayer(gameManager.currentPlayer);
Redraw(currentQuestion);
questionsToAnswer = gameManager.myRoom.GetQuestionsByPlayer(gameManager.currentPlayer);
Redraw(activeAnsweredQuestionIndex);
}
/// <summary>
/// Called when the script is disabled.
/// Cleans up resources and resets the activeAnsweredQuestionIndex.
/// </summary>
void OnDisable()
{
player2questions = null;
currentQuestion = 0;
questionsToAnswer = null;
activeAnsweredQuestionIndex = FirstQuestionIndex;
}
/// <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)
{
Prompt prompt = promptList.prompts.Find(x => x.id == player2questions[currentQuestion].promptId);
//Debug.Log(JsonUtility.ToJson(prompt));
Prompt prompt = promptList.prompts.Find(x => x.id == questionsToAnswer[currentQuestion].promptId);
explainText.SetText(prompt.en);
CameraManager cameraManager = gameObject.GetComponent<CameraManager>();
cameraManager.WebcamResume();
}
int GetPropRef(Player player)
/// <summary>
/// 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 gameManager.myRoom.questions[currentQuestion].propositions.First(x => x.Value.owner.id == player.id).Key;
return questionsToAnswer[activeAnsweredQuestionIndex].propositions.First(x => x.Value.owner.id == _playerId).Key;
}
/// <summary>
/// Handles the click event of the submit button.
/// Uploads a photo and manages the UI accordingly.
/// </summary>
public void OnSubmitButton()
{
submitButton.interactable = false;
submitButton.GetComponent<TextMeshProUGUI>().text = "Uploading...";
managers.GetComponent<StorageManager>().UploadPhoto(
gameManager.myRoom.code,
gameManager.currentPlayer.id,
currentQuestion,
GetPropRef(gameManager.currentPlayer),
succeed =>
{
if(!succeed)
StorageManager storageManager = managers.GetComponent<StorageManager>();
if (storageManager != null)
{
storageManager.UploadPhoto(
gameManager.myRoom.code,
gameManager.currentPlayer.id,
questionsToAnswer[activeAnsweredQuestionIndex].index,
GetPropositionIndex(gameManager.currentPlayer.id),
succeed =>
{
Debug.LogError("Photo upload failed. please do something", this);
return;
}
if (currentQuestion == 1)
{
gameManager.WaitForPlayers();
return;
}
else
{
submitButton.interactable = true;
submitButton.GetComponent<TextMeshProUGUI>().text = "Submit";
currentQuestion++;
Redraw(currentQuestion);
}
});
if (!succeed)
{
Debug.LogError("Photo upload failed. Please do something.", this);
return;
}
if (activeAnsweredQuestionIndex == SecondQuestionIndex)
{
gameManager.WaitForPlayers();
}
else
{
submitButton.interactable = true;
submitButton.GetComponent<TextMeshProUGUI>().text = "Submit";
activeAnsweredQuestionIndex = SecondQuestionIndex;
Redraw(activeAnsweredQuestionIndex);
}
});
}
}
}

View File

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

View File

@ -1,9 +0,0 @@
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;
bool playerHasAnsweredBothProposition = true;
Proposition[] propositions = myRoom.GetPropositionsByPlayer(player).ToArray();
Proposition[] propositions = myRoom.GetPropositionsForPlayer(player).ToArray();
//Debug.Log($"I found {propositions.Length} propositions for {player.name}", this);
if (propositions.Length < 2)