112 lines
2.6 KiB
C#
112 lines
2.6 KiB
C#
using System;
|
|
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using TMPro;
|
|
using UnityEngine;
|
|
using UnityEngine.UI;
|
|
|
|
public class MateriKesehatanGigi : Menu<MateriKesehatanGigi>
|
|
{
|
|
[SerializeField] protected TextMeshProUGUI nameText;
|
|
[SerializeField] protected TextMeshProUGUI descriptionText;
|
|
[SerializeField] protected Image previewImage;
|
|
|
|
protected MateriSelector MateriSelector;
|
|
protected MateriSpec currentMateri;
|
|
|
|
private int indexBgm = 0;
|
|
|
|
|
|
protected override void Awake()
|
|
{
|
|
base.Awake();
|
|
MateriSelector = GetComponent<MateriSelector>();
|
|
UpdateInfo();
|
|
}
|
|
|
|
private void OnEnable()
|
|
{
|
|
UpdateInfo();
|
|
indexBgm++;
|
|
if (indexBgm > 1)
|
|
{
|
|
PlayInitDubbing();
|
|
}
|
|
}
|
|
|
|
private void OnDisable()
|
|
{
|
|
audioController.Instance.StopDubbing();
|
|
}
|
|
|
|
public void UpdateInfo()
|
|
{
|
|
|
|
currentMateri = MateriSelector.GetCurrentMission();
|
|
|
|
if(currentMateri != null )
|
|
{
|
|
nameText.text = currentMateri.Name;
|
|
descriptionText.text = currentMateri.Description;
|
|
previewImage.sprite = currentMateri.Image;
|
|
}
|
|
}
|
|
|
|
public void PlayInitDubbing()
|
|
{
|
|
currentMateri = MateriSelector.GetCurrentMission();
|
|
|
|
if(currentMateri != null )
|
|
{
|
|
audioController.Instance.StopDubbing();
|
|
audioController.Instance.PlayDubbing(currentMateri.DubbingName);
|
|
}
|
|
}
|
|
|
|
public void PlayNextDubbing()
|
|
{
|
|
MateriSpec materiDub = MateriSelector.GetNextMissionDubbing();
|
|
if (materiDub != null)
|
|
{
|
|
audioController.Instance.StopDubbing();
|
|
audioController.Instance.PlayDubbing(materiDub.DubbingName);
|
|
}
|
|
}
|
|
|
|
public void PlayPreviousDubbing()
|
|
{
|
|
MateriSpec materiDub = MateriSelector.GetPreviousMissionDubbing();
|
|
if (materiDub != null)
|
|
{
|
|
audioController.Instance.StopDubbing();
|
|
audioController.Instance.PlayDubbing(materiDub.DubbingName);
|
|
}
|
|
}
|
|
public void OnNextPressed()
|
|
{
|
|
audioController.Instance.PlaySFX("TombolUmum", 0.5f);
|
|
MateriSelector.IncrementIndex();
|
|
UpdateInfo();
|
|
PlayNextDubbing();
|
|
}
|
|
|
|
public void OnPreviousPressed()
|
|
{
|
|
audioController.Instance.PlaySFX("TombolUmum", 0.5f);
|
|
MateriSelector.DecrementIndex();
|
|
UpdateInfo();
|
|
PlayPreviousDubbing();
|
|
}
|
|
|
|
|
|
public override void OnBackPressed()
|
|
{
|
|
base.OnBackPressed();
|
|
audioController.Instance.StopDubbing();
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|