DailyAPI.cs 8.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using MaidStatus;
  5. using MaidStatus.CsvData;
  6. using PrivateMaidMode;
  7. using UnityEngine;
  8. namespace com.workman.cm3d2.scene.dailyEtc
  9. {
  10. public class DailyAPI
  11. {
  12. public DailyAPI(SceneMgr sceneMgr)
  13. {
  14. this.sceneManager = sceneMgr;
  15. }
  16. public static string dayBgm
  17. {
  18. get
  19. {
  20. if (DailyMgr.IsLegacy)
  21. {
  22. return "BGM015.ogg";
  23. }
  24. return "BGM020.ogg";
  25. }
  26. }
  27. public static string nightBgm
  28. {
  29. get
  30. {
  31. if (DailyMgr.IsLegacy)
  32. {
  33. return "BGM015.ogg";
  34. }
  35. return "BGM009.ogg";
  36. }
  37. }
  38. public static string dayBg
  39. {
  40. get
  41. {
  42. if (DailyMgr.IsLegacy)
  43. {
  44. return "Shitsumu";
  45. }
  46. return "ShinShitsumu_ChairRot";
  47. }
  48. }
  49. public static string nightBg
  50. {
  51. get
  52. {
  53. if (DailyMgr.IsLegacy)
  54. {
  55. return "Shitsumu_Night";
  56. }
  57. return "ShinShitsumu_ChairRot_Night";
  58. }
  59. }
  60. public void SceneStart(bool f_bIsDay, MonoBehaviour f_parent, DailyAPI.dgOnSceneStartCallBack f_dgLoadedFinish)
  61. {
  62. this.m_bDay = f_bIsDay;
  63. this.m_dgStart = f_dgLoadedFinish;
  64. GameMain.Instance.MainCamera.FadeOut(0f, false, null, true, default(Color));
  65. GameMain.Instance.TutorialPanel.SetImage(TutorialPanel.ImageSet.MainMenu, false);
  66. if (GameMain.Instance.CharacterMgr.status.isAvailableCompetitiveShow)
  67. {
  68. GameMain.Instance.TutorialPanel.SetImage(TutorialPanel.ImageSet.CompetitiveShow, false);
  69. }
  70. GameMain.Instance.ScriptMgr.adv_kag.MessageWindowMgr.CloseMessageWindowPanel();
  71. GameMain.Instance.MainLight.Reset();
  72. Debug.Log("Daily LightReset");
  73. GameMain.Instance.MainCamera.Reset(CameraMain.CameraType.Target, true);
  74. if (GameMain.Instance.VRMode)
  75. {
  76. GameMain.Instance.MainCamera.SetTargetPos(new Vector3(0f, 1.327261f, -0.1473188f), true);
  77. GameMain.Instance.MainCamera.SetDistance(3.6f, true);
  78. GameMain.Instance.MainCamera.SetAroundAngle(new Vector2(719.8212f, 2.235997f), true);
  79. }
  80. else
  81. {
  82. GameMain.Instance.MainCamera.SetTargetPos(new Vector3(0.5609447f, 1.380762f, -1.382336f), true);
  83. GameMain.Instance.MainCamera.SetDistance(1.6f, true);
  84. GameMain.Instance.MainCamera.SetAroundAngle(new Vector2(245.5691f, 6.273283f), true);
  85. }
  86. GameMain.Instance.MainCamera.SetTargetOffset(Vector3.zero, false);
  87. if (f_bIsDay)
  88. {
  89. if (DailyMgr.IsLegacy)
  90. {
  91. GameMain.Instance.SoundMgr.PlayBGMLegacy("BGM015.ogg", 0.5f, true);
  92. }
  93. else
  94. {
  95. GameMain.Instance.SoundMgr.PlayBGM("BGM020.ogg", 0.5f, true);
  96. }
  97. GameMain.Instance.BgMgr.ChangeBg(DailyAPI.dayBg);
  98. }
  99. else
  100. {
  101. if (DailyMgr.IsLegacy)
  102. {
  103. GameMain.Instance.SoundMgr.PlayBGMLegacy("BGM015.ogg", 0.5f, true);
  104. }
  105. else
  106. {
  107. GameMain.Instance.SoundMgr.PlayBGM("BGM009.ogg", 0.5f, true);
  108. }
  109. GameMain.Instance.BgMgr.ChangeBg(DailyAPI.nightBg);
  110. }
  111. this.SetupTutorial();
  112. CharacterMgr characterMgr = GameMain.Instance.CharacterMgr;
  113. for (int i = 0; i < characterMgr.GetStockMaidCount(); i++)
  114. {
  115. Maid stockMaid = characterMgr.GetStockMaid(i);
  116. if (stockMaid != null)
  117. {
  118. stockMaid.FaceAnime("通常", 0f, 0);
  119. stockMaid.FaceBlend("無し");
  120. }
  121. }
  122. GameMain.Instance.CharacterMgr.DeactivateCharaAll();
  123. GameMain.Instance.CharacterMgr.DeactivateMaid(0);
  124. if (PluginData.IsEnabled("GP002") && !DailyMgr.IsLegacy)
  125. {
  126. this.m_isPrivate = PrivateModeMgr.Instance.LoadPrivateMaid(this.m_bDay);
  127. }
  128. f_parent.StartCoroutine(this.CoCharaLoad());
  129. for (int j = 0; j < GameMain.Instance.CharacterMgr.GetStockMaidCount(); j++)
  130. {
  131. bool flag = false;
  132. Maid stockMaid2 = GameMain.Instance.CharacterMgr.GetStockMaid(j);
  133. if (stockMaid2 != null && stockMaid2.status.heroineType != HeroineType.Sub)
  134. {
  135. List<JobClass.Data> learnPossibleClassDatas = stockMaid2.status.jobClass.GetLearnPossibleClassDatas(true, AbstractClassData.ClassType.Share | AbstractClassData.ClassType.New);
  136. foreach (JobClass.Data data in learnPossibleClassDatas)
  137. {
  138. stockMaid2.status.jobClass.Add(data, true, true);
  139. flag = true;
  140. }
  141. }
  142. if (flag)
  143. {
  144. stockMaid2.status.UpdateClassBonusStatus();
  145. }
  146. }
  147. }
  148. private IEnumerator CoCharaLoad()
  149. {
  150. while (GameMain.Instance.CharacterMgr.IsBusy())
  151. {
  152. yield return null;
  153. }
  154. yield return null;
  155. yield return null;
  156. if (this.m_isPrivate)
  157. {
  158. this.SetMaidCollider(true);
  159. PrivateModeMgr.Instance.LoadLocation();
  160. }
  161. else
  162. {
  163. GameMain.Instance.CharacterMgr.ResetCharaPosAll();
  164. }
  165. GameMain.Instance.MainCamera.FadeIn(0.5f, false, null, true, true, default(Color));
  166. if (this.m_dgStart != null)
  167. {
  168. this.m_dgStart();
  169. }
  170. yield break;
  171. }
  172. public void EndNextScene(DailyAPI.EndType f_eEndType, string f_jumpLabelName)
  173. {
  174. this.jumpLabelName = f_jumpLabelName;
  175. this.m_eEndType = f_eEndType;
  176. CharacterMgr characterMgr = GameMain.Instance.CharacterMgr;
  177. if (this.m_isPrivate)
  178. {
  179. this.SetMaidCollider(false);
  180. }
  181. if (this.m_eEndType == DailyAPI.EndType.NormalSceneChange)
  182. {
  183. GameMain.Instance.SoundMgr.StopBGM(1f);
  184. }
  185. else if (this.m_eEndType == DailyAPI.EndType.ToFreeMode)
  186. {
  187. for (int i = 0; i < characterMgr.GetMaidCount(); i++)
  188. {
  189. if (characterMgr.GetMaid(i) != null)
  190. {
  191. characterMgr.Deactivate(i, false);
  192. }
  193. }
  194. }
  195. GameMain.Instance.MainCamera.FadeOut(0.5f, false, new CameraMain.dgOnCompleteFade(this.OnFinishFadeOut), true, default(Color));
  196. }
  197. public void SetMaidCollider(bool isActive)
  198. {
  199. if (this.m_isPrivate)
  200. {
  201. if (isActive)
  202. {
  203. MaidColliderCollect maidColliderCollect = MaidColliderCollect.AddColliderCollect(PrivateModeMgr.Instance.PrivateMaid);
  204. List<CapsuleCollider> list = new List<CapsuleCollider>();
  205. if (PrivateModeMgr.Instance.PrivateMaid.body0.IsCrcBody)
  206. {
  207. list = maidColliderCollect.AddCollider(MaidColliderCollect.ColliderType.Crc);
  208. }
  209. else
  210. {
  211. list = maidColliderCollect.AddCollider(MaidColliderCollect.ColliderType.Grab);
  212. }
  213. for (int i = 0; i < list.Count; i++)
  214. {
  215. ColliderEventVR colliderEventVR = list[i].gameObject.AddComponent<ColliderEventVR>();
  216. colliderEventVR.onMouseDown = delegate()
  217. {
  218. if (BasePanelMgr.IsOpen())
  219. {
  220. return;
  221. }
  222. this.EndNextScene(DailyAPI.EndType.NormalSceneChange, "label_privatemaidmodeevent");
  223. };
  224. }
  225. }
  226. else
  227. {
  228. Maid privateMaid = PrivateModeMgr.Instance.PrivateMaid;
  229. if (privateMaid != null && privateMaid.GetComponent<MaidColliderCollect>() != null)
  230. {
  231. if (privateMaid.body0.IsCrcBody)
  232. {
  233. privateMaid.GetComponent<MaidColliderCollect>().RemoveCollider(MaidColliderCollect.ColliderType.Crc);
  234. }
  235. else
  236. {
  237. privateMaid.GetComponent<MaidColliderCollect>().RemoveCollider(MaidColliderCollect.ColliderType.Grab);
  238. }
  239. UnityEngine.Object.Destroy(privateMaid.GetComponent<MaidColliderCollect>());
  240. }
  241. }
  242. }
  243. }
  244. private void OnFinishFadeOut()
  245. {
  246. if (this.m_isPrivate)
  247. {
  248. GameMain.Instance.CharacterMgr.DeactivateMaid(0);
  249. }
  250. if (!string.IsNullOrEmpty(this.jumpLabelName))
  251. {
  252. this.sceneManager.GoToLabel(this.jumpLabelName);
  253. }
  254. }
  255. public void SceneFinish()
  256. {
  257. if (GameMain.Instance.MainCamera != null)
  258. {
  259. GameMain.Instance.MainCamera.SetTargetOffset(Vector3.zero, false);
  260. }
  261. if (GameMain.Instance.CharacterMgr != null)
  262. {
  263. GameMain.Instance.CharacterMgr.DeactivateCharaAll();
  264. }
  265. }
  266. public void SetupTutorial()
  267. {
  268. bool isLegacy = DailyMgr.IsLegacy;
  269. bool bDay = this.m_bDay;
  270. bool isAvailableTransfer = GameMain.Instance.CharacterMgr.status.isAvailableTransfer;
  271. bool flag = PluginData.IsEnabled("GP001FB");
  272. string text = string.Empty;
  273. if (isLegacy)
  274. {
  275. if (bDay)
  276. {
  277. text = "SceneDailyDayTimeLegacy";
  278. }
  279. }
  280. else if (bDay)
  281. {
  282. if (isAvailableTransfer)
  283. {
  284. text = "SceneDailyDayTimeAvailableTransfer";
  285. if (flag)
  286. {
  287. text = "SceneDailyDayTimeAvailableTransfer_GP001FB";
  288. }
  289. }
  290. else
  291. {
  292. text = "SceneDailyDayTime";
  293. if (flag)
  294. {
  295. text = "SceneDailyDayTime_GP001FB";
  296. }
  297. }
  298. }
  299. else if (isAvailableTransfer)
  300. {
  301. text = "SceneDailyNight";
  302. }
  303. else
  304. {
  305. text = "SceneDailyNight";
  306. }
  307. if (string.IsNullOrEmpty(text))
  308. {
  309. return;
  310. }
  311. if (!uGUITutorialPanel.IsOpened())
  312. {
  313. uGUITutorialPanel.OpenTutorial(text, null, false);
  314. }
  315. GameMain.Instance.SysShortcut.strSceneHelpName = text;
  316. }
  317. private DailyAPI.dgOnSceneStartCallBack m_dgStart;
  318. private string jumpLabelName;
  319. private SceneMgr sceneManager;
  320. private bool m_bDay = true;
  321. private bool m_isPrivate;
  322. private DailyAPI.EndType m_eEndType;
  323. public delegate void dgOnSceneStartCallBack();
  324. public enum EndType
  325. {
  326. ToFreeMode,
  327. TakeOver,
  328. NormalSceneChange
  329. }
  330. }
  331. }