YotogiKagManager.cs 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234
  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, true);
  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. if (tag_data.IsValid("maid"))
  138. {
  139. this.yotogi_mgr_.play_mgr.RemoveRepeatVoiceData(tag_data.GetTagProperty("maid").AsInteger());
  140. }
  141. else
  142. {
  143. this.yotogi_mgr_.play_mgr.ClearRepeatVoiceData();
  144. }
  145. }
  146. return false;
  147. }
  148. public bool TagVoiceWait(KagTagSupport tag_data)
  149. {
  150. int maid_no = 0;
  151. if (tag_data.IsValid("maid"))
  152. {
  153. maid_no = tag_data.GetTagProperty("maid").AsInteger();
  154. }
  155. Maid maid = this.GetMaid(maid_no);
  156. float length = maid.AudioMan.GetLength();
  157. base.SetWait((int)(length * 1000f), true);
  158. return true;
  159. }
  160. public bool TagRepeatVoiceLock(KagTagSupport tag_data)
  161. {
  162. bool lockRepeatVoiceUpdate = bool.Parse(tag_data.GetTagProperty("value").AsString());
  163. if (this.yotogi_mgr_ != null)
  164. {
  165. this.yotogi_mgr_.play_mgr.lockRepeatVoiceUpdate = lockRepeatVoiceUpdate;
  166. }
  167. return false;
  168. }
  169. public bool TagHitRet(KagTagSupport tag_data)
  170. {
  171. if (this.pickUpText && this.yotogi_mgr_ != null)
  172. {
  173. string text = this.kag_.GetText();
  174. if (!string.IsNullOrEmpty(text))
  175. {
  176. if (this.repeatStackText)
  177. {
  178. this.yotogi_mgr_.play_mgr.AddRepeatVoiceText(text);
  179. }
  180. else
  181. {
  182. this.yotogi_mgr_.play_mgr.SetMessageText(text);
  183. }
  184. }
  185. }
  186. this.kag_.TextClear();
  187. this.pickUpText = (this.repeatStackText = false);
  188. return false;
  189. }
  190. private void PlayVoice(Maid maid, string file)
  191. {
  192. if (maid != null && maid.Visible)
  193. {
  194. maid.AudioMan.LoadPlay(file, 0f, false, false);
  195. }
  196. else
  197. {
  198. int voice_pitch = 50;
  199. AudioSourceMgr.Type soundType = AudioSourceMgr.Type.Voice;
  200. if (maid != null)
  201. {
  202. voice_pitch = maid.VoicePitch;
  203. soundType = maid.AudioMan.SoundType;
  204. }
  205. GameMain.Instance.SoundMgr.PlayDummyVoice(file, 0f, false, false, voice_pitch, soundType);
  206. }
  207. }
  208. public override string GetKagClassName()
  209. {
  210. return "夜伽kag";
  211. }
  212. private YotogiManager yotogi_mgr_;
  213. private YotogiOldManager yotogi_old_mgr_;
  214. private bool pickUpText;
  215. private bool repeatStackText;
  216. }