2024-01-28 21:42:02 +00:00
|
|
|
using Firebase.Database;
|
|
|
|
using Newtonsoft.Json;
|
2024-01-28 16:34:11 +00:00
|
|
|
using System.Collections.Generic;
|
|
|
|
using System.Linq;
|
2024-01-28 21:42:02 +00:00
|
|
|
using TMPro;
|
2024-01-28 16:34:11 +00:00
|
|
|
using UnityEngine;
|
|
|
|
using UnityEngine.UI;
|
|
|
|
|
2024-01-28 21:42:02 +00:00
|
|
|
public class PropositionHandler : MonoBehaviour
|
2024-01-28 16:34:11 +00:00
|
|
|
{
|
|
|
|
public GameManager gameManager;
|
|
|
|
public StorageManager storageManager;
|
2024-01-28 21:42:02 +00:00
|
|
|
public TextMeshProUGUI promptLabel;
|
|
|
|
public PromptList prompts;
|
2024-01-28 16:34:11 +00:00
|
|
|
public Image[] btns;
|
|
|
|
|
2024-01-28 21:42:02 +00:00
|
|
|
public void ShowQuestion(Question currentQuestion)
|
2024-01-28 16:34:11 +00:00
|
|
|
{
|
2024-01-28 21:42:02 +00:00
|
|
|
List<Proposition> props = currentQuestion.propositions.Values.ToList();
|
|
|
|
promptLabel.text = prompts.GetPromptById(currentQuestion.promptId).en;
|
2024-01-28 16:34:11 +00:00
|
|
|
|
2024-01-28 16:35:11 +00:00
|
|
|
for (int i = 0; i < 2; i++)
|
|
|
|
{
|
2024-01-28 21:07:34 +00:00
|
|
|
StorageManager.ConvertGoogleStorageURLToHttpsUrl(props[i].photoUrl, _httpURL =>
|
2024-01-28 16:35:11 +00:00
|
|
|
{
|
2024-01-28 21:07:34 +00:00
|
|
|
StartCoroutine(StorageManager.DownloadImage_Coroutine(_httpURL, (Texture texture) =>
|
|
|
|
{
|
|
|
|
Sprite sprite = Sprite.Create(texture as Texture2D, new Rect(0, 0, texture.width, texture.height), Vector2.zero);
|
|
|
|
btns[i].sprite = sprite;
|
|
|
|
}));
|
|
|
|
});
|
2024-01-28 16:34:11 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|