DailyAPI.cs 8.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336
  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 = maidColliderCollect.AddCollider(MaidColliderCollect.ColliderType.Grab);
  205. for (int i = 0; i < list.Count; i++)
  206. {
  207. ColliderEventVR colliderEventVR = list[i].gameObject.AddComponent<ColliderEventVR>();
  208. colliderEventVR.onMouseDown = delegate()
  209. {
  210. if (BasePanelMgr.IsOpen())
  211. {
  212. return;
  213. }
  214. this.EndNextScene(DailyAPI.EndType.NormalSceneChange, "label_privatemaidmodeevent");
  215. };
  216. }
  217. }
  218. else
  219. {
  220. Maid privateMaid = PrivateModeMgr.Instance.PrivateMaid;
  221. if (privateMaid != null && privateMaid.GetComponent<MaidColliderCollect>() != null)
  222. {
  223. privateMaid.GetComponent<MaidColliderCollect>().RemoveCollider(MaidColliderCollect.ColliderType.Grab);
  224. UnityEngine.Object.Destroy(privateMaid.GetComponent<MaidColliderCollect>());
  225. }
  226. }
  227. }
  228. }
  229. private void OnFinishFadeOut()
  230. {
  231. if (this.m_isPrivate)
  232. {
  233. GameMain.Instance.CharacterMgr.DeactivateMaid(0);
  234. }
  235. if (!string.IsNullOrEmpty(this.jumpLabelName))
  236. {
  237. this.sceneManager.GoToLabel(this.jumpLabelName);
  238. }
  239. }
  240. public void SceneFinish()
  241. {
  242. if (GameMain.Instance.MainCamera != null)
  243. {
  244. GameMain.Instance.MainCamera.SetTargetOffset(Vector3.zero, false);
  245. }
  246. if (GameMain.Instance.CharacterMgr != null)
  247. {
  248. GameMain.Instance.CharacterMgr.DeactivateCharaAll();
  249. }
  250. }
  251. public void SetupTutorial()
  252. {
  253. bool isLegacy = DailyMgr.IsLegacy;
  254. bool bDay = this.m_bDay;
  255. bool isAvailableTransfer = GameMain.Instance.CharacterMgr.status.isAvailableTransfer;
  256. bool flag = PluginData.IsEnabled("GP001FB");
  257. string text = string.Empty;
  258. if (isLegacy)
  259. {
  260. if (bDay)
  261. {
  262. text = "SceneDailyDayTimeLegacy";
  263. }
  264. }
  265. else if (bDay)
  266. {
  267. if (isAvailableTransfer)
  268. {
  269. text = "SceneDailyDayTimeAvailableTransfer";
  270. if (flag)
  271. {
  272. text = "SceneDailyDayTimeAvailableTransfer_GP001FB";
  273. }
  274. }
  275. else
  276. {
  277. text = "SceneDailyDayTime";
  278. if (flag)
  279. {
  280. text = "SceneDailyDayTime_GP001FB";
  281. }
  282. }
  283. }
  284. else if (isAvailableTransfer)
  285. {
  286. text = "SceneDailyNight";
  287. }
  288. else
  289. {
  290. text = "SceneDailyNight";
  291. }
  292. if (string.IsNullOrEmpty(text))
  293. {
  294. return;
  295. }
  296. if (!uGUITutorialPanel.IsOpened())
  297. {
  298. uGUITutorialPanel.OpenTutorial(text, null, false);
  299. }
  300. GameMain.Instance.SysShortcut.strSceneHelpName = text;
  301. }
  302. private DailyAPI.dgOnSceneStartCallBack m_dgStart;
  303. private string jumpLabelName;
  304. private SceneMgr sceneManager;
  305. private bool m_bDay = true;
  306. private bool m_isPrivate;
  307. private DailyAPI.EndType m_eEndType;
  308. public delegate void dgOnSceneStartCallBack();
  309. public enum EndType
  310. {
  311. ToFreeMode,
  312. TakeOver,
  313. NormalSceneChange
  314. }
  315. }
  316. }