YotogiKagManager.cs 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186
  1. using System;
  2. using UnityEngine;
  3. public class YotogiKagManager : BaseKagManager
  4. {
  5. public YotogiKagManager(TJSScript tjs, ScriptManager script_mgr) : base(tjs, script_mgr)
  6. {
  7. }
  8. public override void Initialize()
  9. {
  10. base.Initialize();
  11. this.kag_.AddTagCallBack("talk", new KagScript.KagTagCallBack(this.TagTalk));
  12. this.kag_.AddTagCallBack("hitret", new KagScript.KagTagCallBack(this.TagHitRet));
  13. this.kag_.AddTagCallBack("talkrepeat", new KagScript.KagTagCallBack(this.TagTalkRepeat));
  14. this.kag_.AddTagCallBack("talkrepeatadd", new KagScript.KagTagCallBack(this.TagTalkRepeatAdd));
  15. this.kag_.AddTagCallBack("talkrepeatclear", new KagScript.KagTagCallBack(this.TagTalkRepeatClear));
  16. this.kag_.AddTagCallBack("voicewait", new KagScript.KagTagCallBack(this.TagVoiceWait));
  17. this.kag_.AddTagCallBack("repeatvoicelock", new KagScript.KagTagCallBack(this.TagRepeatVoiceLock));
  18. }
  19. public void SetYotogiManager(YotogiManager yotogi_mgr)
  20. {
  21. this.yotogi_mgr_ = yotogi_mgr;
  22. this.yotogi_old_mgr_ = null;
  23. }
  24. public void SetYotogiOldManager(YotogiOldManager yotogi_old_mgr)
  25. {
  26. this.yotogi_old_mgr_ = yotogi_old_mgr;
  27. this.yotogi_mgr_ = null;
  28. }
  29. public override bool TagWait(KagTagSupport tag_data)
  30. {
  31. if (!tag_data.IsValid("motion"))
  32. {
  33. return base.TagWait(tag_data);
  34. }
  35. this.exec_wait_data_.Clear();
  36. int num = 0;
  37. MotionKagManager motionKagManager = null;
  38. if (GameMain.Instance.ScriptMgr.kag_mot_dic.ContainsKey(0))
  39. {
  40. motionKagManager = GameMain.Instance.ScriptMgr.kag_mot_dic[0];
  41. }
  42. Maid maidAndMan = base.GetMaidAndMan(tag_data);
  43. if (motionKagManager != null && maidAndMan != null && maidAndMan.body0 != null && maidAndMan.body0.m_Bones != null)
  44. {
  45. string[] array = (!maidAndMan.boMAN) ? motionKagManager.last_maid_motion_set_log : motionKagManager.last_man_motion_set_log;
  46. Animation component = maidAndMan.body0.m_Bones.GetComponent<Animation>();
  47. if (component != null && !string.IsNullOrEmpty(array[maidAndMan.ActiveSlotNo]))
  48. {
  49. string text = array[maidAndMan.ActiveSlotNo];
  50. AnimationState animationState = component[text];
  51. if (animationState != null)
  52. {
  53. num = (int)(animationState.length * 1000f);
  54. Debug.Log(string.Concat(new string[]
  55. {
  56. "@wait motion 再生中モーション[",
  57. text,
  58. "] 再生時間 : ",
  59. num.ToString(),
  60. "ms"
  61. }));
  62. }
  63. else
  64. {
  65. Debug.Log("@wait motionが指定されましたが最後に再生したモーション[" + text + "]が現在は再生されていません");
  66. }
  67. }
  68. }
  69. if (num <= 0)
  70. {
  71. return false;
  72. }
  73. bool skip_possible = !tag_data.IsValid("skip") || tag_data.GetTagProperty("skip").AsBool();
  74. base.SetWait(num, skip_possible);
  75. return true;
  76. }
  77. public bool TagTalk(KagTagSupport tag_data)
  78. {
  79. if (tag_data.IsValid("voice"))
  80. {
  81. Maid voiceTargetMaid = BaseKagManager.GetVoiceTargetMaid(tag_data);
  82. this.PlayVoice(voiceTargetMaid, tag_data.GetTagProperty("voice").AsString() + ".ogg");
  83. }
  84. return false;
  85. }
  86. public bool TagTalkRepeat(KagTagSupport tag_data)
  87. {
  88. int maid_no = 0;
  89. if (tag_data.IsValid("maid"))
  90. {
  91. maid_no = tag_data.GetTagProperty("maid").AsInteger();
  92. }
  93. if (tag_data.IsValid("voice"))
  94. {
  95. if (this.yotogi_mgr_ != null)
  96. {
  97. this.yotogi_mgr_.SetRepeatVoiceFile(tag_data.GetTagProperty("voice").AsString() + ".ogg", maid_no);
  98. }
  99. else
  100. {
  101. this.yotogi_old_mgr_.SetRepeatVoiceFile(tag_data.GetTagProperty("voice").AsString() + ".ogg", maid_no);
  102. }
  103. }
  104. return false;
  105. }
  106. public bool TagTalkRepeatAdd(KagTagSupport tag_data)
  107. {
  108. int maid_no = 0;
  109. if (tag_data.IsValid("maid"))
  110. {
  111. maid_no = tag_data.GetTagProperty("maid").AsInteger();
  112. }
  113. if (tag_data.IsValid("voice"))
  114. {
  115. this.yotogi_mgr_.AddRepeatVoiceFile(tag_data.GetTagProperty("voice").AsString() + ".ogg", maid_no);
  116. }
  117. return false;
  118. }
  119. public bool TagTalkRepeatClear(KagTagSupport tag_data)
  120. {
  121. if (this.yotogi_mgr_ != null)
  122. {
  123. this.yotogi_mgr_.play_mgr.ClearRepeatVoiceData();
  124. }
  125. return false;
  126. }
  127. public bool TagVoiceWait(KagTagSupport tag_data)
  128. {
  129. int maid_no = 0;
  130. if (tag_data.IsValid("maid"))
  131. {
  132. maid_no = tag_data.GetTagProperty("maid").AsInteger();
  133. }
  134. Maid maid = this.GetMaid(maid_no);
  135. float length = maid.AudioMan.GetLength();
  136. base.SetWait((int)(length * 1000f), true);
  137. return true;
  138. }
  139. public bool TagRepeatVoiceLock(KagTagSupport tag_data)
  140. {
  141. bool lockRepeatVoiceUpdate = bool.Parse(tag_data.GetTagProperty("value").AsString());
  142. if (this.yotogi_mgr_ != null)
  143. {
  144. this.yotogi_mgr_.play_mgr.lockRepeatVoiceUpdate = lockRepeatVoiceUpdate;
  145. }
  146. return false;
  147. }
  148. public bool TagHitRet(KagTagSupport tag_data)
  149. {
  150. this.kag_.TextClear();
  151. return false;
  152. }
  153. private void PlayVoice(Maid maid, string file)
  154. {
  155. if (maid != null && maid.Visible)
  156. {
  157. maid.AudioMan.LoadPlay(file, 0f, false, false);
  158. }
  159. else
  160. {
  161. GameMain.Instance.SoundMgr.PlayDummyVoice(file, 0f, false, false, 50);
  162. }
  163. }
  164. public override string GetKagClassName()
  165. {
  166. return "夜伽kag";
  167. }
  168. private YotogiManager yotogi_mgr_;
  169. private YotogiOldManager yotogi_old_mgr_;
  170. }