fix: Vote one by one

This commit is contained in:
Fangh 2024-01-28 22:42:02 +01:00
parent f533a4ba75
commit e27ad3fb40
8 changed files with 701 additions and 334 deletions

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

Binary file not shown.

View File

@ -0,0 +1,153 @@
fileFormatVersion: 2
guid: 49c6da5c3a35a6b47a96d6e9c2353c1e
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: 0, y: 0, z: 0, w: 0}
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: 1
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: 0
vertices: []
indices:
edges: []
weights: []
secondaryTextures: []
nameFileIdTable: {}
mipmapLimitGroupName:
pSDRemoveMatte: 0
userData:
assetBundleName:
assetBundleVariant:

File diff suppressed because it is too large Load Diff

View File

@ -6,7 +6,7 @@
public class FunnyText : MonoBehaviour public class FunnyText : MonoBehaviour
{ {
public List<string> texts; public List<string> texts;
private void Start() private void OnEnable()
{ {
GetComponent<TextMeshProUGUI>().text = texts[Random.Range(0, texts.Count)]; GetComponent<TextMeshProUGUI>().text = texts[Random.Range(0, texts.Count)];
} }

View File

@ -389,7 +389,6 @@ private void OnRoomUpdate(object sender, ValueChangedEventArgs e)
} }
case (int)GameState.PropositionsSent: case (int)GameState.PropositionsSent:
{ {
if (TakePicture.activeInHierarchy) if (TakePicture.activeInHierarchy)
{ {
TakePicture.SetActive(false); TakePicture.SetActive(false);
@ -403,15 +402,19 @@ private void OnRoomUpdate(object sender, ValueChangedEventArgs e)
{ {
TakePicture.SetActive(false); TakePicture.SetActive(false);
VotePicture.SetActive(true); VotePicture.SetActive(true);
myOnlineRoom.Child("currentQuestion").ValueChanged += OnCurrentQuestionChanged;
} }
if (WaitingOtherPlayers.activeInHierarchy) break;
}
case (int)GameState.Score:
{
if (TakePicture.activeInHierarchy)
{ {
VotePicture.SetActive(false);
WaitingOtherPlayers.SetActive(false); WaitingOtherPlayers.SetActive(false);
VotePicture.SetActive(true); EndGame.SetActive(true);
myOnlineRoom.Child("currentQuestion").ValueChanged -= OnCurrentQuestionChanged;
} }
break; break;
} }
@ -504,11 +507,28 @@ public void onClickNewPlayers()
} }
private void OnCurrentQuestionChanged(object sender, ValueChangedEventArgs onlineValue)
{
Question q = JsonConvert.DeserializeObject<Question>(onlineValue.Snapshot.GetRawJsonValue());
if (WaitingOtherPlayers.activeInHierarchy)
{
WaitingOtherPlayers.SetActive(false);
VotePicture.SetActive(true);
}
VotePicture.GetComponent<PropositionHandler>().ShowQuestion(q);
}
public void OnClickProposition(int propositionNumber) public void OnClickProposition(int propositionNumber)
{ {
List<string> voters = myRoom.questions[myRoom.currentQuestionId].propositions[propositionNumber].voters.ToList<string>(); List<string> voters = myRoom.questions[myRoom.currentQuestionId].propositions[propositionNumber].voters.ToList<string>();
voters.Add(currentPlayer.id); voters.Add(currentPlayer.id);
myOnlineRoom.Child("questions").Child(myRoom.currentQuestionId.ToString()).Child("propositions").Child(propositionNumber.ToString()).Child("voters").SetValueAsync(voters); myOnlineRoom.Child("questions").Child(myRoom.currentQuestionId.ToString()).Child("propositions").Child(propositionNumber.ToString()).Child("voters").SetValueAsync(voters);
myRoom.currentState = (int)GameState.VoteSent;
WaitingOtherPlayers.SetActive(true);
VotePicture.SetActive(false);
} }

View File

@ -1,29 +1,23 @@
using Firebase.Database;
using Newtonsoft.Json;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using TMPro;
using UnityEngine; using UnityEngine;
using UnityEngine.UI; using UnityEngine.UI;
public class PropositionDownload : MonoBehaviour public class PropositionHandler : MonoBehaviour
{ {
public GameManager gameManager; public GameManager gameManager;
public StorageManager storageManager; public StorageManager storageManager;
public TextMeshProUGUI promptLabel;
public PromptList prompts;
public Image[] btns; public Image[] btns;
// Start is called before the first frame update public void ShowQuestion(Question currentQuestion)
void Start()
{ {
List<Proposition> props = currentQuestion.propositions.Values.ToList();
} promptLabel.text = prompts.GetPromptById(currentQuestion.promptId).en;
// Update is called once per frame
void Update()
{
}
void OnEnable()
{
List<Proposition> props = gameManager.myRoom.questions[gameManager.myRoom.currentQuestionId].propositions.Values.ToList();
for (int i = 0; i < 2; i++) for (int i = 0; i < 2; i++)
{ {
@ -38,8 +32,4 @@ void OnEnable()
} }
} }
void OnDisable()
{
}
} }