YotogiKagManager.cs 5.8 KB

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