75 lines
2.6 KiB
C#
75 lines
2.6 KiB
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using System.Threading.Tasks;
|
|
using TMPro;
|
|
using UnityEngine;
|
|
using UnityEngine.UI;
|
|
|
|
public class ProfileMenu : Menu<ProfileMenu>
|
|
{
|
|
private SaveData saveData;
|
|
|
|
[SerializeField] private TextMeshProUGUI namePlayer, agePlayer;
|
|
[SerializeField] private TextMeshProUGUI passwordPlayer , usernamePlayer;
|
|
[SerializeField] private Image dataKesehatanGigiImage;
|
|
[SerializeField] private Image dataPenyakitGigiImage;
|
|
[SerializeField] private Image dataPreTestImage;
|
|
[SerializeField] private Image dataPostTestImage;
|
|
[SerializeField] private TextMeshProUGUI dataKesehatanGigiText;
|
|
[SerializeField] private TextMeshProUGUI dataPenyakitGigiText;
|
|
[SerializeField] private TextMeshProUGUI dataPreTestText;
|
|
[SerializeField] private TextMeshProUGUI dataPostTestText;
|
|
|
|
private void OnEnable()
|
|
{
|
|
LoadAndRefresh();
|
|
}
|
|
|
|
private async void LoadAndRefresh()
|
|
{
|
|
saveData = await Cloudsave.LoadData<SaveData>("DataPlayer");
|
|
|
|
if (saveData == null)
|
|
{
|
|
Debug.LogWarning("DataPlayer tidak ditemukan di cloud!");
|
|
return;
|
|
}
|
|
|
|
namePlayer.text = "Nama = " + saveData.playerName;
|
|
agePlayer.text = "Usia = " + saveData.agePlayer + " Tahun";
|
|
passwordPlayer.text = "Pasword = " + CryptoUtility.Decrypt(saveData.password);
|
|
usernamePlayer.text = "Username = " + CryptoUtility.Decrypt(saveData.username);
|
|
dataKesehatanGigiImage.fillAmount = (float)saveData.kesehatanGigiStatistik / 100f;
|
|
dataPenyakitGigiImage.fillAmount = (float)saveData.PenyakitGigiStatistik / 100f;
|
|
dataKesehatanGigiText.text = saveData.kesehatanGigiStatistik.ToString("F1");
|
|
dataPenyakitGigiText.text = saveData.PenyakitGigiStatistik.ToString("F1");
|
|
dataPreTestImage.fillAmount = saveData.preTestStatistik /100;
|
|
dataPostTestImage.fillAmount = saveData.postTestStatistik / 100f;
|
|
dataPostTestText.text = saveData.postTestStatistik.ToString("F1") + "%";
|
|
dataPreTestText.text = saveData.preTestStatistik.ToString("F1") + "%";
|
|
}
|
|
|
|
public override void OnBackPressed()
|
|
{
|
|
audioController.Instance.PlaySFX("TombolClose", 0.5f);
|
|
base.OnBackPressed();
|
|
}
|
|
|
|
public void ProfileShowButton()
|
|
{
|
|
audioController.Instance.PlaySFX("TombolUmum", 0.5f);
|
|
}
|
|
|
|
public void LogoutButton()
|
|
{
|
|
audioController.Instance.PlaySFX("TombolClose", 0.5f);
|
|
AuthenticationManager.Signout();
|
|
AuntMenu.Open();
|
|
}
|
|
|
|
public void StatisticProfileButton()
|
|
{
|
|
audioController.Instance.PlaySFX("TombolUmum", 0.5f);
|
|
}
|
|
}
|