YotogiKagManager.cs 6.9 KB

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