Files

54 lines
1.4 KiB
C#
Raw Permalink Normal View History

2022-06-13 21:11:05 +02:00
using System.Text.RegularExpressions;
2022-05-04 20:36:46 +02:00
using TMPro;
using UnityEngine;
public class IntroUI : MonoBehaviour
{
2022-11-14 14:20:37 +02:00
[SerializeField] private PlayerDialogue _playerOneDialogue = default;
[SerializeField] private TextMeshProUGUI _playerOneName = default;
[SerializeField] private TextMeshProUGUI _playerTwoName = default;
private Animator _animator;
private Audio _audio;
private int _midDialogueFrame;
2022-11-14 14:20:37 +02:00
void Awake()
{
_animator = GetComponent<Animator>();
_audio = GetComponent<Audio>();
2022-11-14 14:20:37 +02:00
}
2022-05-04 20:36:46 +02:00
2022-11-14 14:20:37 +02:00
void FixedUpdate()
{
if (DemonicsWorld.WaitFramesOnce(ref _midDialogueFrame))
{
2022-12-04 21:35:31 +02:00
GameplayManager.Instance.IsDialogueRunning = true;
2022-11-14 14:20:37 +02:00
_playerOneDialogue.PlayDialogue();
}
}
2022-06-13 21:11:05 +02:00
2022-11-14 14:20:37 +02:00
public void StartIntro()
{
GameplayManager.Instance.IsDialogueRunning = true;
_animator.Rebind();
2022-11-14 14:20:37 +02:00
_animator.SetBool("IsIntroRunning", true);
_midDialogueFrame = 200;
}
2022-06-13 21:11:05 +02:00
2022-11-14 14:20:37 +02:00
public void SkipIntro()
{
_animator.SetBool("IsIntroRunning", false);
}
public void SetPlayerNames(string playerOne, string playerTwo)
{
_playerOneName.text = Regex.Replace(playerOne, "([a-z])([A-Z])", "$1 $2"); ;
_playerTwoName.text = Regex.Replace(playerTwo, "([a-z])([A-Z])", "$1 $2"); ;
}
public void PlayTextAppearSoundAnimationEvent()
{
_audio.Sound("TextAppear").Play();
}
}