fix(#11]
This commit is contained in:
parent
c10683a6f6
commit
c290bbd1cb
@ -321,3 +321,4 @@ MonoBehaviour:
|
|||||||
voterStickerPrefab: {fileID: 4312846972391547553, guid: 69942fa558cf34dfc91982c6bccef840, type: 3}
|
voterStickerPrefab: {fileID: 4312846972391547553, guid: 69942fa558cf34dfc91982c6bccef840, type: 3}
|
||||||
playerName: {fileID: 782069874130417341}
|
playerName: {fileID: 782069874130417341}
|
||||||
playerGrid: {fileID: 4509981124141486577}
|
playerGrid: {fileID: 4509981124141486577}
|
||||||
|
defaultTexture: {fileID: 2800000, guid: 57d7dffbdddc24c959c3c072208cbafe, type: 3}
|
||||||
|
@ -1388,6 +1388,7 @@ MonoBehaviour:
|
|||||||
storageManager: {fileID: 429358652}
|
storageManager: {fileID: 429358652}
|
||||||
promptLabel: {fileID: 1545657113}
|
promptLabel: {fileID: 1545657113}
|
||||||
prompts: {fileID: 11400000, guid: 21907abc84e40403ca34c4fb9ab30b06, type: 2}
|
prompts: {fileID: 11400000, guid: 21907abc84e40403ca34c4fb9ab30b06, type: 2}
|
||||||
|
defaultImage: {fileID: 21300000, guid: 49c6da5c3a35a6b47a96d6e9c2353c1e, type: 3}
|
||||||
btns:
|
btns:
|
||||||
- {fileID: 456700976}
|
- {fileID: 456700976}
|
||||||
- {fileID: 589915591}
|
- {fileID: 589915591}
|
||||||
|
@ -546,7 +546,7 @@ private void OnCurrentQuestionChanged(object sender, ValueChangedEventArgs onlin
|
|||||||
VotePicture.SetActive(true);
|
VotePicture.SetActive(true);
|
||||||
WaitingOtherPlayers.SetActive(false);
|
WaitingOtherPlayers.SetActive(false);
|
||||||
endOfViewDate = DateTime.Now.AddSeconds(20);
|
endOfViewDate = DateTime.Now.AddSeconds(20);
|
||||||
VotePicture.GetComponent<PropositionHandler>().ShowQuestion(q);
|
VotePicture.GetComponent<PropositionHandler>().ShowPlayersProposition(q);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -15,11 +15,17 @@ public class PropositionFrame : MonoBehaviour
|
|||||||
public GameObject voterStickerPrefab;
|
public GameObject voterStickerPrefab;
|
||||||
public TextMeshProUGUI playerName;
|
public TextMeshProUGUI playerName;
|
||||||
public Transform playerGrid;
|
public Transform playerGrid;
|
||||||
|
public Texture2D defaultTexture;
|
||||||
|
|
||||||
private Dictionary<Player, GameObject> currentVoters = new Dictionary<Player, GameObject>();
|
private Dictionary<Player, GameObject> currentVoters = new Dictionary<Player, GameObject>();
|
||||||
private Proposition proposition;
|
private Proposition proposition;
|
||||||
|
|
||||||
public void Initialize(Proposition _proposition)
|
private void OnEnable()
|
||||||
|
{
|
||||||
|
picture.texture = defaultTexture;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void SetProposition(Proposition _proposition)
|
||||||
{
|
{
|
||||||
Debug.Log($"Initializing {_proposition.owner.name}'s proposition", this);
|
Debug.Log($"Initializing {_proposition.owner.name}'s proposition", this);
|
||||||
proposition = _proposition;
|
proposition = _proposition;
|
||||||
@ -27,12 +33,27 @@ public void Initialize(Proposition _proposition)
|
|||||||
|
|
||||||
if (!string.IsNullOrEmpty(proposition.photoUrl))
|
if (!string.IsNullOrEmpty(proposition.photoUrl))
|
||||||
DisplayPicture(proposition.photoUrl);
|
DisplayPicture(proposition.photoUrl);
|
||||||
|
else
|
||||||
|
picture.texture = defaultTexture;
|
||||||
|
|
||||||
|
ResetVoters();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void SetNoProposition()
|
||||||
|
{
|
||||||
|
picture.texture = defaultTexture;
|
||||||
|
playerName.text = "Nobody";
|
||||||
|
ResetVoters();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ResetVoters()
|
||||||
|
{
|
||||||
foreach (var voters in currentVoters)
|
foreach (var voters in currentVoters)
|
||||||
{
|
{
|
||||||
Destroy(voters.Value);
|
Destroy(voters.Value);
|
||||||
}
|
}
|
||||||
currentVoters.Clear();
|
currentVoters.Clear();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using System.Security.Policy;
|
||||||
using TMPro;
|
using TMPro;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
using UnityEngine.UI;
|
using UnityEngine.UI;
|
||||||
@ -12,9 +13,10 @@ public class PropositionHandler : MonoBehaviour
|
|||||||
public StorageManager storageManager;
|
public StorageManager storageManager;
|
||||||
public TextMeshProUGUI promptLabel;
|
public TextMeshProUGUI promptLabel;
|
||||||
public PromptList prompts;
|
public PromptList prompts;
|
||||||
|
public Sprite defaultImage;
|
||||||
public Image[] btns;
|
public Image[] btns;
|
||||||
|
|
||||||
public void ShowQuestion(Question currentQuestion)
|
public void ShowPlayersProposition(Question currentQuestion)
|
||||||
{
|
{
|
||||||
List<Proposition> props = currentQuestion.propositions.Values.ToList();
|
List<Proposition> props = currentQuestion.propositions.Values.ToList();
|
||||||
string enPrompt = prompts.GetPromptById(currentQuestion.promptId).en;
|
string enPrompt = prompts.GetPromptById(currentQuestion.promptId).en;
|
||||||
@ -26,6 +28,7 @@ public void ShowQuestion(Question currentQuestion)
|
|||||||
if(props[i].photoUrl == null)
|
if(props[i].photoUrl == null)
|
||||||
{
|
{
|
||||||
Debug.Log("One player did not send a proposition !", this);
|
Debug.Log("One player did not send a proposition !", this);
|
||||||
|
btns[index].sprite = defaultImage; // Utilise l'index local au lieu de i
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -152,12 +152,12 @@ private void InitializeProposition(PropositionFrame proposition, Proposition pro
|
|||||||
{
|
{
|
||||||
if (propositionData != null)
|
if (propositionData != null)
|
||||||
{
|
{
|
||||||
proposition.Initialize(propositionData);
|
proposition.SetProposition(propositionData);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Debug.Log("User has given no proposition", this);
|
Debug.Log("User has given no proposition", this);
|
||||||
// Handle the case when there is no proposition
|
proposition.SetNoProposition();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user