BjVoiceMgr.cs 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using UnityEngine;
  5. public class BjVoiceMgr : MonoBehaviour
  6. {
  7. public static BjVoiceMgr Instance { get; private set; }
  8. private Maid m_TargetMaid
  9. {
  10. get
  11. {
  12. return GameMain.Instance.CharacterMgr.GetMaid(0);
  13. }
  14. }
  15. public bool isPlay
  16. {
  17. get
  18. {
  19. return this.m_TargetMaid.AudioMan.isPlay();
  20. }
  21. }
  22. private void Awake()
  23. {
  24. BjVoiceMgr.Instance = this;
  25. KasaiUtility.CsvReadY("bj_voice_data.nei", new Action<CsvParser, int>(this.ReadVoiceData), 1, null);
  26. }
  27. private void Start()
  28. {
  29. if (CasinoDataMgr.Instance.DealerMaid)
  30. {
  31. string label_name = string.Empty;
  32. if (GameMain.Instance.ScriptMgr.adv_kag.tag_backup.ContainsKey("voice_label"))
  33. {
  34. label_name = GameMain.Instance.ScriptMgr.adv_kag.tag_backup["voice_label"];
  35. }
  36. GameMain.Instance.ScriptMgr.adv_kag.JumpLabel(label_name);
  37. }
  38. else
  39. {
  40. string file_name = ScriptManager.ReplacePersonal(this.m_TargetMaid, this.m_VoiceScript);
  41. GameMain.Instance.ScriptMgr.LoadAdvScenarioScript(file_name, string.Empty);
  42. }
  43. GameMain.Instance.ScriptMgr.adv_kag.Exec();
  44. }
  45. private void ReadVoiceData(CsvParser csv, int cy)
  46. {
  47. this.m_VoiceData.Add(csv.GetCellAsString(0, cy), csv.GetCellAsString(1, cy));
  48. }
  49. private IEnumerator VoiceWait(Action end_call)
  50. {
  51. yield return null;
  52. while (this.m_TargetMaid.AudioMan.isPlay())
  53. {
  54. yield return null;
  55. }
  56. if (end_call != null)
  57. {
  58. end_call();
  59. }
  60. yield break;
  61. }
  62. private void Recet()
  63. {
  64. this.m_TargetMaid.FaceBlend("無し");
  65. this.m_TargetMaid.FaceAnime("通常", 1f, 0);
  66. GameMain.Instance.ScriptMgr.adv_kag.ClearExecWait();
  67. }
  68. public void PlayScoreVoice(Action end_call = null, float fade_time = 0f)
  69. {
  70. if (Dealer.Instance.IsNatural21())
  71. {
  72. this.PlayVoice("ディーラーBJ", end_call, fade_time);
  73. }
  74. else if (Dealer.Instance.IsBust())
  75. {
  76. this.PlayVoice("ディーラーバースト", end_call, fade_time);
  77. }
  78. else
  79. {
  80. this.PlayVoice(Dealer.Instance.CurrentScore.ToString(), end_call, fade_time);
  81. }
  82. }
  83. public void PlayVoice(string voice_category, Action end_call = null, float fade_time = 0f)
  84. {
  85. if (!this.m_VoiceData.ContainsKey(voice_category))
  86. {
  87. return;
  88. }
  89. GameMain.Instance.ScriptMgr.adv_kag.ClearExecWait();
  90. GameMain.Instance.ScriptMgr.adv_kag.JumpLabel(this.m_VoiceData[voice_category]);
  91. GameMain.Instance.ScriptMgr.adv_kag.Exec();
  92. if (end_call != null)
  93. {
  94. base.StartCoroutine(this.VoiceWait(end_call));
  95. }
  96. }
  97. public void VoiceToVoice(string first_voice, string second_voice, Action end_call, float first_fade = 0f, float second_fade = 0f)
  98. {
  99. this.PlayVoice(first_voice, delegate
  100. {
  101. this.PlayVoice(second_voice, end_call, second_fade);
  102. }, first_fade);
  103. }
  104. public void Stop()
  105. {
  106. this.Recet();
  107. base.StopAllCoroutines();
  108. if (this.m_TargetMaid && this.m_TargetMaid.AudioMan)
  109. {
  110. this.m_TargetMaid.AudioMan.Stop();
  111. }
  112. }
  113. public void VoiceEnd()
  114. {
  115. this.Recet();
  116. GameMain.Instance.ScriptMgr.adv_kag.JumpLabel(this.m_EndLabel);
  117. GameMain.Instance.ScriptMgr.adv_kag.Exec();
  118. }
  119. private Dictionary<string, string> m_VoiceData = new Dictionary<string, string>();
  120. [SerializeField]
  121. [Header("ボイス再生用のスクリプトファイル")]
  122. private string m_VoiceScript = "?_casino_0001.ks";
  123. [SerializeField]
  124. [Header(" ボイス用スクリプトから抜けるときのラベル")]
  125. private string m_EndLabel = "*カジノうひょー";
  126. }