Merge branch 'main' of https://github.com/itsvraza/ToothyV
This commit is contained in:
commit
381209a405
|
|
@ -103,16 +103,22 @@ public class AuntMenu : Menu<AuntMenu>
|
||||||
int month = monthAgeRegister.value + 1;
|
int month = monthAgeRegister.value + 1;
|
||||||
int year = int.Parse(yearAgeRegister.options[yearAgeRegister.value].text);
|
int year = int.Parse(yearAgeRegister.options[yearAgeRegister.value].text);
|
||||||
|
|
||||||
DateTime birthDate = new DateTime(year, month, day);
|
// Validasi tanggal + hitung umur
|
||||||
calculatedAge = CalculateAge(birthDate);
|
if (!TryGetValidAge(year, month, day, out calculatedAge))
|
||||||
//
|
{
|
||||||
// if (calculatedAge < 6 || calculatedAge > 12)
|
Debug.LogWarning("Tanggal tidak valid!");
|
||||||
// {
|
InvalidAge.SetActive(true);
|
||||||
// Debug.LogWarning("Age must be between 6 and 12 years!");
|
ResetRegisterFields();
|
||||||
// Debug.Log(calculatedAge);
|
return;
|
||||||
// InvalidAge.SetActive(true);
|
}
|
||||||
// return;
|
|
||||||
// }
|
if (calculatedAge < 6 || calculatedAge > 9)
|
||||||
|
{
|
||||||
|
Debug.LogWarning("Usia harus antara 6 sampai 9 tahun!");
|
||||||
|
InvalidAge.SetActive(true);
|
||||||
|
ResetRegisterFields();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
await AuthenticationManager.SignUpUsernamePassword(usernameRegister, paswordRegister, EmailRegister, calculatedAge.ToString());
|
await AuthenticationManager.SignUpUsernamePassword(usernameRegister, paswordRegister, EmailRegister, calculatedAge.ToString());
|
||||||
|
|
||||||
|
|
@ -125,6 +131,21 @@ public class AuntMenu : Menu<AuntMenu>
|
||||||
await Cloudsave.SaveData(dataToSave, "DataPlayer");
|
await Cloudsave.SaveData(dataToSave, "DataPlayer");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private bool TryGetValidAge(int year, int month, int day, out int age)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
DateTime birthDate = new DateTime(year, month, day);
|
||||||
|
age = CalculateAge(birthDate);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
catch (ArgumentOutOfRangeException)
|
||||||
|
{
|
||||||
|
age = 0;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private int CalculateAge(DateTime birthDate)
|
private int CalculateAge(DateTime birthDate)
|
||||||
{
|
{
|
||||||
DateTime today = DateTime.Today;
|
DateTime today = DateTime.Today;
|
||||||
|
|
@ -132,4 +153,15 @@ public class AuntMenu : Menu<AuntMenu>
|
||||||
if (birthDate.Date > today.AddYears(-age)) age--;
|
if (birthDate.Date > today.AddYears(-age)) age--;
|
||||||
return age;
|
return age;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void ResetRegisterFields()
|
||||||
|
{
|
||||||
|
usernameFieldRegister.text = "";
|
||||||
|
nameFieldRegister.text = "";
|
||||||
|
paswordFieldRegister.text = "";
|
||||||
|
EmailFieldRegister.text = "";
|
||||||
|
dateAgeRegister.value = 0;
|
||||||
|
monthAgeRegister.value = 0;
|
||||||
|
yearAgeRegister.value = 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -174,4 +174,16 @@ public class PostTestMenu : Menu<PostTestMenu>
|
||||||
MainMenu.Open();
|
MainMenu.Open();
|
||||||
SelectLevel.Open();
|
SelectLevel.Open();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void OnDisable()
|
||||||
|
{
|
||||||
|
audioController.Instance.StopDubbing();
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void OnBackPressed()
|
||||||
|
{
|
||||||
|
base.OnBackPressed();
|
||||||
|
audioController.Instance.StopDubbing();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -175,4 +175,15 @@ public class PreTestMenu : Menu<PreTestMenu>
|
||||||
MainMenu.Open();
|
MainMenu.Open();
|
||||||
SelectLevel.Open();
|
SelectLevel.Open();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void OnDisable()
|
||||||
|
{
|
||||||
|
audioController.Instance.StopDubbing();
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void OnBackPressed()
|
||||||
|
{
|
||||||
|
base.OnBackPressed();
|
||||||
|
audioController.Instance.StopDubbing();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -83,9 +83,13 @@ public class QuizPopUp : Menu<QuizPopUp>
|
||||||
timerImage.fillAmount = 1f;
|
timerImage.fillAmount = 1f;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (audioController.Instance != null)
|
||||||
|
{
|
||||||
|
audioController.Instance.StopDubbing();
|
||||||
audioController.Instance.bgmSource.volume = 1f;
|
audioController.Instance.bgmSource.volume = 1f;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void Update()
|
void Update()
|
||||||
{
|
{
|
||||||
|
|
@ -293,5 +297,13 @@ public class QuizPopUp : Menu<QuizPopUp>
|
||||||
{
|
{
|
||||||
audioController.Instance.StopDubbing();
|
audioController.Instance.StopDubbing();
|
||||||
audioController.Instance.PlayDubbing(currentQuestion.dubbingName);
|
audioController.Instance.PlayDubbing(currentQuestion.dubbingName);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public override void OnBackPressed()
|
||||||
|
{
|
||||||
|
base.OnBackPressed();
|
||||||
|
audioController.Instance.StopDubbing();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
Loading…
Reference in New Issue