OnaholeReactionManager.cs 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282
  1. using System;
  2. using UnityEngine;
  3. public class OnaholeReactionManager : MonoBehaviour
  4. {
  5. public Maid maid { get; private set; }
  6. public bool highlightHeart
  7. {
  8. get
  9. {
  10. return this.highlightHeart_;
  11. }
  12. set
  13. {
  14. this.highlightHeart_ = value;
  15. if (this.highlightHeart_ && this.highlightHide_)
  16. {
  17. this.highlightHide_ = false;
  18. }
  19. this.UpdateHighligParts();
  20. }
  21. }
  22. public bool highlightHide
  23. {
  24. get
  25. {
  26. return this.highlightHide_;
  27. }
  28. set
  29. {
  30. this.highlightHide_ = value;
  31. if (this.highlightHide_ && this.highlightHeart_)
  32. {
  33. this.highlightHeart_ = false;
  34. }
  35. this.UpdateHighligParts();
  36. }
  37. }
  38. public bool runnyNoseEffect
  39. {
  40. get
  41. {
  42. return this.runnyNoseEffect_;
  43. }
  44. set
  45. {
  46. if (this.isReady)
  47. {
  48. this.CallReactionFile("*鼻水", value);
  49. }
  50. this.runnyNoseEffect_ = value;
  51. }
  52. }
  53. public bool saladEffect
  54. {
  55. get
  56. {
  57. return this.saladEffect_;
  58. }
  59. set
  60. {
  61. if (this.isReady)
  62. {
  63. this.CallReactionFile("*涎", value);
  64. }
  65. this.saladEffect_ = value;
  66. }
  67. }
  68. public bool sweatEffect
  69. {
  70. get
  71. {
  72. return this.sweatEffect_;
  73. }
  74. set
  75. {
  76. if (this.isReady)
  77. {
  78. this.CallReactionFile("*汗", value);
  79. }
  80. this.sweatEffect_ = value;
  81. }
  82. }
  83. public bool breatheEffect
  84. {
  85. get
  86. {
  87. return this.breatheEffect_;
  88. }
  89. set
  90. {
  91. if (this.breatheObject != null)
  92. {
  93. this.breatheObject.SetActive(value);
  94. }
  95. this.breatheEffect_ = value;
  96. }
  97. }
  98. private void Awake()
  99. {
  100. this.maid = base.GetComponent<Maid>();
  101. this.ReadyCheck();
  102. }
  103. private void OnDestroy()
  104. {
  105. if (!this.isReady)
  106. {
  107. return;
  108. }
  109. if (this.breatheObject != null)
  110. {
  111. this.maid.DelPrefab("夜伽_吐息");
  112. }
  113. if (this.maid == null || this.maid.body0 == null || !this.maid.body0.isLoadedBody)
  114. {
  115. return;
  116. }
  117. bool visible = this.maid.Visible;
  118. if (this.runnyNoseEffect)
  119. {
  120. this.runnyNoseEffect = false;
  121. }
  122. if (this.saladEffect)
  123. {
  124. this.saladEffect = false;
  125. }
  126. if (this.sweatEffect)
  127. {
  128. this.sweatEffect = false;
  129. }
  130. if (this.breatheEffect)
  131. {
  132. this.breatheEffect = false;
  133. }
  134. if (this.highlightHeart)
  135. {
  136. this.highlightHeart = false;
  137. }
  138. if (this.highlightHide)
  139. {
  140. this.highlightHide = false;
  141. }
  142. if (this.maid.Visible != visible)
  143. {
  144. this.maid.Visible = visible;
  145. }
  146. }
  147. private void Start()
  148. {
  149. if (this.maid == null)
  150. {
  151. this.maid = base.GetComponent<Maid>();
  152. }
  153. this.ReadyCheck();
  154. }
  155. public void SetMaid(Maid maid)
  156. {
  157. if (this.maid == null || maid != null)
  158. {
  159. this.maid = maid;
  160. this.ReadyCheck();
  161. }
  162. else if (this.maid != null)
  163. {
  164. Debug.LogWarning("OnaholeReactionManager::SetMaid Error:すでにメイドはセットされています");
  165. }
  166. }
  167. public void ResetReaction()
  168. {
  169. this.highlightHeart = false;
  170. this.highlightHide = false;
  171. this.runnyNoseEffect = false;
  172. this.saladEffect = false;
  173. this.sweatEffect = false;
  174. this.breatheEffect = false;
  175. }
  176. private void Update()
  177. {
  178. if (!this.isReady)
  179. {
  180. this.ReadyCheck();
  181. }
  182. }
  183. private void ReadyCheck()
  184. {
  185. if (this.isReady || this.maid == null || this.maid.body0 == null || !this.maid.body0.isLoadedBody || this.maid.IsAllProcPropBusy)
  186. {
  187. return;
  188. }
  189. this.isReady = true;
  190. if (this.breatheObject == null)
  191. {
  192. this.maid.AddPrefab("Particle/pToiki", "夜伽_吐息", "Bip01 Head", new Vector3(0.042f, 0.076f, 0f), new Vector3(-90f, 90f, 0f));
  193. this.breatheObject = this.maid.GetPrefab("夜伽_吐息");
  194. this.breatheEffect = this.breatheEffect_;
  195. }
  196. this.sweatEffect = this.sweatEffect_;
  197. this.UpdateHighligParts();
  198. }
  199. private void CallReactionFile(string label, bool enabled)
  200. {
  201. if (!this.isReady)
  202. {
  203. return;
  204. }
  205. if (this.maid.ActiveSlotNo < 0)
  206. {
  207. Debug.LogWarning("リアクションファイルを呼び出そうとしましたが、メイドがActiveではありません");
  208. return;
  209. }
  210. GameMain.Instance.ScriptMgr.EvalScript("tf['痕メイド'] = " + this.maid.ActiveSlotNo.ToString());
  211. GameMain.Instance.ScriptMgr.EvalScript("tf['痕遅延'] = 0");
  212. if (!enabled)
  213. {
  214. label += "_削除";
  215. }
  216. GameMain.Instance.ScriptMgr.LoadTempScript("CBLReactionFile.ks", label);
  217. GameMain.Instance.ScriptMgr.tmp_kag.Exec();
  218. }
  219. private void UpdateHighligParts()
  220. {
  221. if (!this.isReady)
  222. {
  223. return;
  224. }
  225. string text = string.Empty;
  226. if (this.highlightHeart)
  227. {
  228. text = "_i_skinhi_nky003.menu";
  229. }
  230. if (this.highlightHide_)
  231. {
  232. text = "_i_skinhi002.menu";
  233. }
  234. if (string.IsNullOrEmpty(text))
  235. {
  236. this.maid.ResetProp(MPN.eye_hi, true);
  237. this.maid.ResetProp(MPN.eye_hi_r, true);
  238. }
  239. else
  240. {
  241. this.maid.SetProp(MPN.eye_hi, text, 0, true, false);
  242. this.maid.SetProp(MPN.eye_hi_r, text, 0, true, false);
  243. }
  244. this.maid.AllProcProp();
  245. }
  246. private const string kHighlightNoneMenuFile = "_i_skinhi002.menu";
  247. private const string kHighlightHeartMenuFile = "_i_skinhi_nky003.menu";
  248. private bool isReady;
  249. private bool runnyNoseEffect_;
  250. private bool saladEffect_;
  251. private bool sweatEffect_;
  252. private bool breatheEffect_;
  253. private bool highlightHide_;
  254. private bool highlightHeart_;
  255. private GameObject breatheObject;
  256. }