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 year = int.Parse(yearAgeRegister.options[yearAgeRegister.value].text);
|
||||
|
||||
DateTime birthDate = new DateTime(year, month, day);
|
||||
calculatedAge = CalculateAge(birthDate);
|
||||
//
|
||||
// if (calculatedAge < 6 || calculatedAge > 12)
|
||||
// {
|
||||
// Debug.LogWarning("Age must be between 6 and 12 years!");
|
||||
// Debug.Log(calculatedAge);
|
||||
// InvalidAge.SetActive(true);
|
||||
// return;
|
||||
// }
|
||||
// Validasi tanggal + hitung umur
|
||||
if (!TryGetValidAge(year, month, day, out calculatedAge))
|
||||
{
|
||||
Debug.LogWarning("Tanggal tidak valid!");
|
||||
InvalidAge.SetActive(true);
|
||||
ResetRegisterFields();
|
||||
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());
|
||||
|
||||
|
|
@ -125,6 +131,21 @@ public class AuntMenu : Menu<AuntMenu>
|
|||
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)
|
||||
{
|
||||
DateTime today = DateTime.Today;
|
||||
|
|
@ -132,4 +153,15 @@ public class AuntMenu : Menu<AuntMenu>
|
|||
if (birthDate.Date > today.AddYears(-age)) age--;
|
||||
return age;
|
||||
}
|
||||
|
||||
private void ResetRegisterFields()
|
||||
{
|
||||
usernameFieldRegister.text = "";
|
||||
nameFieldRegister.text = "";
|
||||
paswordFieldRegister.text = "";
|
||||
EmailFieldRegister.text = "";
|
||||
dateAgeRegister.value = 0;
|
||||
monthAgeRegister.value = 0;
|
||||
yearAgeRegister.value = 0;
|
||||
}
|
||||
}
|
||||
|
|
@ -132,7 +132,7 @@ public class PostTestMenu : Menu<PostTestMenu>
|
|||
|
||||
if (index == correctAnswerIndex)
|
||||
{
|
||||
correctAnswers ++;
|
||||
correctAnswers++;
|
||||
Debug.Log("Jawab Benar");
|
||||
selectedImage.sprite = trueAnswerSprite;
|
||||
questionText.text = "Jawaban Benar!";
|
||||
|
|
@ -174,4 +174,16 @@ public class PostTestMenu : Menu<PostTestMenu>
|
|||
MainMenu.Open();
|
||||
SelectLevel.Open();
|
||||
}
|
||||
|
||||
private void OnDisable()
|
||||
{
|
||||
audioController.Instance.StopDubbing();
|
||||
}
|
||||
|
||||
public override void OnBackPressed()
|
||||
{
|
||||
base.OnBackPressed();
|
||||
audioController.Instance.StopDubbing();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -59,7 +59,7 @@ public class PreTestMenu : Menu<PreTestMenu>
|
|||
{
|
||||
if (isComplete) return;
|
||||
|
||||
if(indexEnable == 0) return;
|
||||
if (indexEnable == 0) return;
|
||||
if (isComplete) return;
|
||||
|
||||
timer -= Time.deltaTime;
|
||||
|
|
@ -175,4 +175,15 @@ public class PreTestMenu : Menu<PreTestMenu>
|
|||
MainMenu.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;
|
||||
}
|
||||
|
||||
if (audioController.Instance != null)
|
||||
{
|
||||
audioController.Instance.StopDubbing();
|
||||
audioController.Instance.bgmSource.volume = 1f;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void Update()
|
||||
{
|
||||
|
|
@ -95,7 +99,7 @@ public class QuizPopUp : Menu<QuizPopUp>
|
|||
}
|
||||
StateLoadQuestion();
|
||||
UpdateTimer();
|
||||
if(isComplete)
|
||||
if (isComplete)
|
||||
{
|
||||
Debug.Log("Game Over");
|
||||
isComplete = false;
|
||||
|
|
@ -293,5 +297,13 @@ public class QuizPopUp : Menu<QuizPopUp>
|
|||
{
|
||||
audioController.Instance.StopDubbing();
|
||||
audioController.Instance.PlayDubbing(currentQuestion.dubbingName);
|
||||
|
||||
}
|
||||
|
||||
public override void OnBackPressed()
|
||||
{
|
||||
base.OnBackPressed();
|
||||
audioController.Instance.StopDubbing();
|
||||
}
|
||||
|
||||
}
|
||||
Loading…
Reference in New Issue