DanceMain.cs 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using System.IO;
  5. using System.Linq;
  6. using System.Text.RegularExpressions;
  7. using UnityEngine;
  8. using UnityEngine.Rendering;
  9. public class DanceMain : MonoBehaviour
  10. {
  11. public static string RecetJumpLabel { private get; set; }
  12. public List<Maid> DanceMaid
  13. {
  14. get
  15. {
  16. return this.m_listMaid;
  17. }
  18. }
  19. public Maid UserMaid
  20. {
  21. get
  22. {
  23. return this.m_maidUser;
  24. }
  25. }
  26. public bool IsDanceEnd { get; private set; }
  27. public Transform OvrCamTrans
  28. {
  29. get
  30. {
  31. return this.m_trOvrDummyCam;
  32. }
  33. }
  34. public float DepthFocalSize
  35. {
  36. get
  37. {
  38. return this.m_DepthFocalSize;
  39. }
  40. set
  41. {
  42. this.m_DepthFocalSize = value;
  43. if (RhythmAction_Mgr.Instance)
  44. {
  45. RhythmAction_Mgr.Instance.SetFocalSize(value);
  46. }
  47. }
  48. }
  49. public string GetFolderPathToBinaryData()
  50. {
  51. string binaryFolderName = this.BinaryFolderName;
  52. string text = Path.GetFileNameWithoutExtension(this.BinaryFolderName).ToLower();
  53. return "Assets/Resources/SceneDance/" + Path.GetFileNameWithoutExtension(this.BinaryFolderName).ToLower() + "/";
  54. }
  55. private void Awake()
  56. {
  57. this.m_boDebugDummyBody = false;
  58. NTime.Reset();
  59. Dictionary<string, string> tag_backup = GameMain.Instance.ScriptMgr.adv_kag.tag_backup;
  60. string strScriptLabel;
  61. if (tag_backup != null && tag_backup.TryGetValue("label", out strScriptLabel))
  62. {
  63. this.m_strScriptLabel = strScriptLabel;
  64. }
  65. NDebug.Assert(this.m_listDummyAnimChara.Count == this.m_listAnimName.Count, "m_listDummyAnimChara と m_listAnimName の数は同一でないといけません。");
  66. NDebug.Assert(this.m_AnimatorData != null, "AnimatorDataが外れています。");
  67. NDebug.Assert(this.m_listTestPreset.Count == this.m_listAnimName.Count, "プリセット数が不正です。");
  68. NDebug.Assert(!string.IsNullOrEmpty(this.m_strMasterAudioFileName), "マスター用MasterAudioFileNameが必要です。");
  69. bool flag = DanceMain.IsDanceRecet;
  70. flag |= (RhythmAction_Mgr.NowState == RhythmAction_Mgr.DanceState.Dance_Second);
  71. flag |= (RhythmAction_Mgr.NowDance == RhythmAction_Mgr.DanceType.Encore);
  72. flag |= RhythmAction_Mgr.IsVSDance;
  73. if (flag && !DanceMain.KaraokeMode)
  74. {
  75. DanceSelect.SelectMaidActive(DanceMain.SelectDanceData);
  76. DanceMain.IsDanceRecet = false;
  77. }
  78. if (this.time_line_binary_ == null)
  79. {
  80. this.maid_data_binary_ = new DanceObjectDataBinary();
  81. this.maid_item_binary_ = new DanceObjectDataBinary();
  82. this.maid_event_binary_ = new DanceObjectDataBinary();
  83. this.time_line_binary_ = new AWReadBinaryData();
  84. if (this.UseBinaryData)
  85. {
  86. string file_name = this.GetFolderPathToBinaryData() + "item_data.bytes";
  87. this.maid_item_binary_.ReadData(file_name);
  88. NDebug.Assert(this.m_listItemObject.Count == this.maid_item_binary_.datas.Length, "アイテム数がバイナリデータと不一致");
  89. this.maid_item_binary_.Restoration(false);
  90. for (int i = 0; i < this.m_listItemObject.Count; i++)
  91. {
  92. if (!(this.m_listItemObject[i] != null))
  93. {
  94. this.m_listItemObject[i] = this.maid_item_binary_.datas[i].obj;
  95. }
  96. }
  97. file_name = this.GetFolderPathToBinaryData() + "event_data.bytes";
  98. this.maid_event_binary_.ReadData(file_name);
  99. NDebug.Assert(this.m_listEventObject.Count == this.maid_event_binary_.datas.Length, "イベント数がバイナリデータと不一致");
  100. this.maid_event_binary_.Restoration(false);
  101. for (int j = 0; j < this.m_listEventObject.Count; j++)
  102. {
  103. if (!(this.m_listEventObject[j] != null))
  104. {
  105. this.m_listEventObject[j] = this.maid_event_binary_.datas[j].obj;
  106. }
  107. }
  108. file_name = this.GetFolderPathToBinaryData() + "maid_data.bytes";
  109. this.maid_data_binary_.ReadData(file_name);
  110. NDebug.Assert(this.m_listDummyAnimChara.Count == this.maid_data_binary_.datas.Length, "メイド数がバイナリデータと不一致");
  111. this.maid_data_binary_.Restoration(true);
  112. for (int k = 0; k < this.m_listDummyAnimChara.Count; k++)
  113. {
  114. if (!(this.m_listDummyAnimChara[k] != null))
  115. {
  116. this.m_listDummyAnimChara[k] = this.maid_data_binary_.datas[k].obj;
  117. this.m_listDebugObj.Add(this.m_listDummyAnimChara[k]);
  118. }
  119. }
  120. file_name = this.GetFolderPathToBinaryData() + "timeline_data.bytes";
  121. this.time_line_binary_.ReadFile(file_name);
  122. this.maid_item_binary_.AttachObject(this.m_AnimatorData.getTake(this.m_strPlayTakeName));
  123. this.maid_event_binary_.AttachObject(this.m_AnimatorData.getTake(this.m_strPlayTakeName));
  124. }
  125. }
  126. foreach (string str in this.m_listKuchiPakuFile)
  127. {
  128. TextAsset textAsset = Resources.Load("SceneDance/" + str) as TextAsset;
  129. NDebug.Assert(textAsset != null, "口パクパターンテキストファイルが開けません。" + str);
  130. string text = textAsset.text;
  131. NDebug.Assert(text.Length != 0, "口パクパターンファイル内が空です。" + str);
  132. text = Regex.Replace(text, "(\\r|\\n| )", string.Empty);
  133. this.m_listKuchiPattern.Add(text);
  134. }
  135. this.m_AnimatorData.playOnStart = null;
  136. this.m_AnimatorData.bAutoTimeUpdate = false;
  137. if (GameMain.Instance.VRMode && GameMain.Instance.CMSystem.GetTmpGenericFlag("ダンスOVRカメラタイプ") == 1)
  138. {
  139. this.m_trOvrDummyCam = new GameObject("OvrDummyDanceCam").transform;
  140. this.m_trOvrDummyCam.gameObject.AddComponent<Camera>().enabled = false;
  141. this.m_OvrCam = GameMain.Instance.OvrMgr.OvrCamera;
  142. }
  143. GameObject gameObject = GameObject.Find("RhythmAction_Mgr");
  144. if (!gameObject)
  145. {
  146. gameObject = UnityEngine.Object.Instantiate<GameObject>(Resources.Load<GameObject>("SceneDance/Rhythm_Action/Prefab/RhythmAction_Mgr"));
  147. }
  148. if (!RhythmAction_Mgr.Instance)
  149. {
  150. gameObject.GetComponent<RhythmAction_Mgr>().InstanceInit();
  151. }
  152. for (int l = 0; l < this.m_listTestPreset.Count; l++)
  153. {
  154. Maid maid = GameMain.Instance.CharacterMgr.GetMaid(l);
  155. if (maid)
  156. {
  157. if (!this.m_maidUser)
  158. {
  159. this.m_maidUser = DanceSelect.SelectTopMaid;
  160. }
  161. maid.Visible = true;
  162. }
  163. }
  164. if (!this.m_maidUser)
  165. {
  166. this.m_maidUser = GameMain.Instance.CharacterMgr.GetMaid(0);
  167. }
  168. if (DanceMain.KaraokeMode)
  169. {
  170. return;
  171. }
  172. GameMain.Instance.CharacterMgr.ResetCharaPosAll();
  173. if (DanceMain.SelectDanceData != null)
  174. {
  175. for (int m = 0; m < DanceMain.SelectDanceData.select_chara_num; m++)
  176. {
  177. RhythmAction_Mgr.Instance.FactOrderList.Add(GameMain.Instance.CharacterMgr.GetMaid(m));
  178. }
  179. }
  180. if (RhythmAction_Mgr.NowDance != RhythmAction_Mgr.DanceType.BenchMark && DanceMain.SelectDanceData != null && DanceMain.SelectDanceData.maid_order.Count > 0)
  181. {
  182. List<Maid> list = new List<Maid>();
  183. for (int n = 0; n < DanceMain.SelectDanceData.maid_order.Count; n++)
  184. {
  185. list.Add(GameMain.Instance.CharacterMgr.GetMaid(n));
  186. }
  187. GameMain.Instance.CharacterMgr.DeactivateCharaAll();
  188. GameMain.Instance.CharacterMgr.DeactivateMaid(0);
  189. for (int num = 0; num < DanceMain.SelectDanceData.maid_order.Count; num++)
  190. {
  191. int index = DanceMain.SelectDanceData.maid_order[num];
  192. if (list[index])
  193. {
  194. GameMain.Instance.CharacterMgr.SetActiveMaid(list[index], num);
  195. list[index].Visible = true;
  196. }
  197. }
  198. }
  199. if (RhythmAction_Mgr.Instance.FactOrderList.Any((Maid e) => !e) || DanceMain.SelectDanceData == null)
  200. {
  201. for (int num2 = 0; num2 < this.m_listTestPreset.Count; num2++)
  202. {
  203. Maid maid2 = GameMain.Instance.CharacterMgr.GetMaid(num2);
  204. if (!maid2)
  205. {
  206. maid2 = GameMain.Instance.CharacterMgr.AddStockMaid();
  207. GameMain.Instance.CharacterMgr.SetActiveMaid(maid2, num2);
  208. CharacterMgr.Preset preset;
  209. if (DanceMain.SelectDanceData != null && !string.IsNullOrEmpty(DanceMain.SelectDanceData.preset_name[num2]))
  210. {
  211. preset = GameMain.Instance.CharacterMgr.PresetLoadFromResources(DanceMain.SelectDanceData.preset_name[num2]);
  212. }
  213. else
  214. {
  215. preset = GameMain.Instance.CharacterMgr.PresetLoadFromResources(this.m_listTestPreset[num2]);
  216. }
  217. if (preset != null)
  218. {
  219. GameMain.Instance.CharacterMgr.PresetSet(maid2, preset);
  220. }
  221. this.m_listTempMaid.Add(maid2);
  222. maid2.Visible = true;
  223. }
  224. }
  225. if (DanceMain.SelectDanceData != null)
  226. {
  227. for (int num3 = 0; num3 < DanceMain.SelectDanceData.maid_order.Count; num3++)
  228. {
  229. int index2 = DanceMain.SelectDanceData.maid_order[num3];
  230. if (!RhythmAction_Mgr.Instance.FactOrderList[index2])
  231. {
  232. RhythmAction_Mgr.Instance.FactOrderList[index2] = GameMain.Instance.CharacterMgr.GetMaid(num3);
  233. }
  234. }
  235. }
  236. }
  237. }
  238. private void Start()
  239. {
  240. if (GameMain.Instance.VRMode)
  241. {
  242. GameObject gameObject = GameObject.Find("effect");
  243. if (gameObject != null)
  244. {
  245. ParticleSystem[] componentsInChildren = gameObject.GetComponentsInChildren<ParticleSystem>(true);
  246. foreach (ParticleSystem particleSystem in componentsInChildren)
  247. {
  248. Renderer component = particleSystem.GetComponent<Renderer>();
  249. if (component != null)
  250. {
  251. component.shadowCastingMode = ShadowCastingMode.Off;
  252. component.receiveShadows = false;
  253. }
  254. }
  255. }
  256. }
  257. if (!DanceMain.KaraokeMode)
  258. {
  259. GameMain.Instance.BgMgr.DeleteBg();
  260. }
  261. GameMain.Instance.MainLight.Reset();
  262. GameMain.Instance.SoundMgr.StopBGM(0f);
  263. GameMain.Instance.MainCamera.gameObject.SetActive(true);
  264. if (!DanceMain.KaraokeMode)
  265. {
  266. GameMain.Instance.MainCamera.Reset(CameraMain.CameraType.Target, false);
  267. }
  268. for (int j = 0; j < this.m_listEventObject.Count; j++)
  269. {
  270. GameObject gameObject2 = this.m_listEventObject[j];
  271. NDebug.Assert(!this.m_htEventObj.ContainsKey(gameObject2.name), "listEventObjectに複数同じObjectを追加しようとしました。" + this.m_listEventObject[j].name);
  272. this.m_htEventObj.Add(gameObject2.name, gameObject2);
  273. }
  274. this.m_takeNow = this.m_AnimatorData.getTake(this.m_strPlayTakeName);
  275. NDebug.Assert(this.m_takeNow != null, "再生するテイク名PlayTakeNameが不正です。" + this.m_strPlayTakeName);
  276. }
  277. public void SetFace(int f_nMaidNo, string f_strFace)
  278. {
  279. RhythmAction_Mgr.Instance.SetTimeLineFace(f_nMaidNo, f_strFace);
  280. Maid maid = GameMain.Instance.CharacterMgr.GetMaid(f_nMaidNo);
  281. if (RhythmAction_Mgr.Instance.GetMaidFaceStop(f_nMaidNo))
  282. {
  283. return;
  284. }
  285. maid.FaceAnime(f_strFace, 1f, 0);
  286. }
  287. public void SetFaceBlend(int f_nMaidNo, string f_strFace)
  288. {
  289. RhythmAction_Mgr.Instance.SetTimeLineFaceBlend(f_nMaidNo, f_strFace);
  290. Maid maid = GameMain.Instance.CharacterMgr.GetMaid(f_nMaidNo);
  291. if (RhythmAction_Mgr.Instance.GetMaidFaceBlendStop(f_nMaidNo))
  292. {
  293. return;
  294. }
  295. maid.FaceBlend(f_strFace);
  296. }
  297. public void SetMaidVisible(int f_nMaidNo, bool visible)
  298. {
  299. Maid maid = GameMain.Instance.CharacterMgr.GetMaid(f_nMaidNo);
  300. maid.transform.localScale = ((!visible) ? Vector3.zero : Vector3.one);
  301. }
  302. public void SwitchObject(string f_strObjName, bool bEnable)
  303. {
  304. (this.m_htEventObj[f_strObjName] as GameObject).SetActive(bEnable);
  305. }
  306. public void EyeToCam(int f_nMaidNo, string f_strType)
  307. {
  308. Maid maid = GameMain.Instance.CharacterMgr.GetMaid(f_nMaidNo);
  309. try
  310. {
  311. maid.EyeToCamera((Maid.EyeMoveType)Enum.Parse(typeof(Maid.EyeMoveType), f_strType), 0f);
  312. }
  313. catch (Exception ex)
  314. {
  315. NDebug.Assert("EyeToCam 目線タイプ " + f_strType + " は不正です。\n" + ex.Message, false);
  316. }
  317. }
  318. public void FadeOut(float f_fTime)
  319. {
  320. GameMain.Instance.MainCamera.FadeOut(f_fTime, false, null, false, default(Color));
  321. }
  322. public void FadeIn(float f_fTime)
  323. {
  324. GameMain.Instance.MainCamera.FadeIn(f_fTime, false, null, false, true, default(Color));
  325. }
  326. private void ChangeObj(AMTake f_take, string f_strOldObjName, GameObject f_goNew)
  327. {
  328. AMTranslationTrack[] array = f_take.findTranslationTrack(f_strOldObjName);
  329. for (int i = 0; i < array.Length; i++)
  330. {
  331. array[i].changeObject(f_goNew.transform);
  332. }
  333. AMRotationTrack[] array2 = f_take.findRotationTrack(f_strOldObjName);
  334. for (int j = 0; j < array2.Length; j++)
  335. {
  336. array2[j].changeObject(f_goNew.transform);
  337. }
  338. AMPropertyTrack[] array3 = f_take.findPropertyTrack(f_strOldObjName);
  339. for (int k = 0; k < array3.Length; k++)
  340. {
  341. array3[k].changeObject(f_goNew);
  342. }
  343. }
  344. public void OnDestroy()
  345. {
  346. this.Uninit();
  347. Debug.Log("DanceMain::OnDestroy");
  348. }
  349. private void Uninit()
  350. {
  351. if (this.m_bFinished)
  352. {
  353. return;
  354. }
  355. if (RhythmAction_Mgr.Instance && DanceMain.KaraokeMode)
  356. {
  357. RhythmAction_Mgr.Instance.KaraokeEnd();
  358. }
  359. Debug.Log("DanceMain::Uninit");
  360. this.m_AnimatorData.StopLoop();
  361. if (GameMain.Instance.MainLight != null)
  362. {
  363. GameMain.Instance.MainLight.Reset();
  364. }
  365. if (GameMain.Instance.MainCamera != null)
  366. {
  367. GameMain.Instance.MainCamera.Reset(CameraMain.CameraType.Target, true);
  368. GameMain.Instance.MainCamera.FadeOut(0f, false, null, true, default(Color));
  369. }
  370. if (GameMain.Instance.SoundMgr != null)
  371. {
  372. GameMain.Instance.SoundMgr.StopBGM(0f);
  373. }
  374. if (GameMain.Instance.CharacterMgr != null)
  375. {
  376. GameMain.Instance.CharacterMgr.ResetCharaPosAll();
  377. }
  378. for (int i = 0; i < this.m_listMaid.Count; i++)
  379. {
  380. if (this.m_listMaid[i] != null)
  381. {
  382. this.m_listMaid[i].transform.localScale = Vector3.one;
  383. this.m_listMaid[i].StopKuchipakuPattern();
  384. this.m_listMaid[i].EyeToCamera(Maid.EyeMoveType.目と顔を向ける, 0f);
  385. this.m_listMaid[i].AllIKDetach(0f);
  386. }
  387. }
  388. for (int j = 0; j < this.m_listItemObject.Count; j++)
  389. {
  390. if (this.m_listItemObject[j] != null)
  391. {
  392. UnityEngine.Object.DestroyImmediate(this.m_listItemObject[j]);
  393. }
  394. }
  395. this.m_listItemObject.Clear();
  396. for (int k = 0; k < this.m_listTempMaid.Count; k++)
  397. {
  398. GameMain.Instance.CharacterMgr.BanishmentMaid(this.m_listTempMaid[k]);
  399. }
  400. if (!DanceMain.KaraokeMode)
  401. {
  402. if (this.DanceMaid.Any((Maid maid) => maid != null))
  403. {
  404. GameMain.Instance.CharacterMgr.DeactivateCharaAll();
  405. }
  406. if (this.m_maidUser != null && this.m_maidUser != GameMain.Instance.CharacterMgr.GetMaid(0))
  407. {
  408. GameMain.Instance.CharacterMgr.DeactivateMaid(0);
  409. GameMain.Instance.CharacterMgr.SetActiveMaid(this.m_maidUser, 0);
  410. }
  411. }
  412. this.m_eMode = DanceMain.Mode.Finish;
  413. this.m_bFinished = true;
  414. }
  415. private void ToFinish()
  416. {
  417. this.IsDanceEnd = !this.IsForceDanceEnd;
  418. RhythmAction_Mgr.Instance.RhythmGame_End();
  419. this.Uninit();
  420. if (!DanceMain.IsDanceRecet)
  421. {
  422. DanceSelect.SetNextDance();
  423. }
  424. else
  425. {
  426. NDebug.Assert(!string.IsNullOrEmpty(DanceMain.RecetJumpLabel), "やりなおし時に飛ぶラベルが設定されてません");
  427. }
  428. Debug.Log("Dance ToFinish Script");
  429. if (!string.IsNullOrEmpty(this.m_strScriptLabel))
  430. {
  431. if (DanceMain.IsDanceRecet)
  432. {
  433. Debug.Log("OnEndScene JumpTo " + DanceMain.RecetJumpLabel);
  434. GameMain.Instance.ScriptMgr.adv_kag.JumpLabel(DanceMain.RecetJumpLabel);
  435. }
  436. else
  437. {
  438. if (DanceMain.SelectDanceData != null)
  439. {
  440. GameMain.Instance.ScriptMgr.EvalScript("tf['dance_scene_name'] = '" + DanceMain.SelectDanceData.scene_name + "';");
  441. }
  442. Debug.Log("OnEndScene JumpTo " + this.m_strScriptLabel);
  443. GameMain.Instance.ScriptMgr.adv_kag.JumpLabel(this.m_strScriptLabel);
  444. }
  445. GameMain.Instance.ScriptMgr.adv_kag.Exec();
  446. }
  447. Debug.Log("Dance Finish!!");
  448. }
  449. private IEnumerator LoadMotionScript()
  450. {
  451. if (this.m_AdjustScript.IndexOf(".ks") < 0)
  452. {
  453. this.m_AdjustScript += ".ks";
  454. }
  455. NDebug.Assert(!string.IsNullOrEmpty(this.m_ScriptLabel), string.Format("{0}の飛び先が未指定です。", this.m_AdjustScript));
  456. if (this.m_ScriptLabel.IndexOf("*") < 0)
  457. {
  458. this.m_ScriptLabel = "*" + this.m_ScriptLabel;
  459. }
  460. ScriptManager script_mgr = GameMain.Instance.ScriptMgr;
  461. script_mgr.StopMotionScript();
  462. script_mgr.is_motion_blend = true;
  463. script_mgr.LoadMotionScript(0, false, this.m_AdjustScript, this.m_ScriptLabel, string.Empty, string.Empty, false, true);
  464. float timer = 0f;
  465. while (timer <= this.m_LoadScriptTime)
  466. {
  467. timer += Time.deltaTime;
  468. yield return null;
  469. }
  470. script_mgr.StopMotionScript();
  471. this.m_eMode = DanceMain.Mode.LoadAnim;
  472. yield break;
  473. }
  474. private void Update()
  475. {
  476. if (this.m_eMode == DanceMain.Mode.ActiveCam)
  477. {
  478. if (GameMain.Instance.MainCamera.gameObject.activeSelf)
  479. {
  480. GameMain.Instance.MainCamera.FadeOut(0f, false, null, true, default(Color));
  481. GameMain.Instance.MainCamera.SetCameraType(CameraMain.CameraType.Free);
  482. GameMain.Instance.MainCamera.SetControl(false);
  483. if (this.m_camDummyCamera != null)
  484. {
  485. if (!GameMain.Instance.VRMode)
  486. {
  487. AMTranslationTrack amtranslationTrack = this.m_takeNow.findTranslationTrack(this.m_camDummyCamera.gameObject.transform);
  488. amtranslationTrack.obj = GameMain.Instance.MainCamera.gameObject.transform;
  489. foreach (AMAction amaction in amtranslationTrack.cache)
  490. {
  491. AMTranslationAction amtranslationAction = (AMTranslationAction)amaction;
  492. amtranslationAction.obj = GameMain.Instance.MainCamera.gameObject.transform;
  493. }
  494. AMRotationTrack amrotationTrack = this.m_takeNow.findRotationTrack(this.m_camDummyCamera.gameObject.transform);
  495. amrotationTrack.obj = GameMain.Instance.MainCamera.gameObject.transform;
  496. foreach (AMAction amaction2 in amrotationTrack.cache)
  497. {
  498. AMRotationAction amrotationAction = (AMRotationAction)amaction2;
  499. amrotationAction.obj = GameMain.Instance.MainCamera.gameObject.transform;
  500. }
  501. }
  502. else if (GameMain.Instance.CMSystem.GetTmpGenericFlag("ダンスOVRカメラタイプ") != 0)
  503. {
  504. AMTranslationTrack amtranslationTrack2 = this.m_takeNow.findTranslationTrack(this.m_camDummyCamera.gameObject.transform);
  505. amtranslationTrack2.obj = this.m_trOvrDummyCam;
  506. foreach (AMAction amaction3 in amtranslationTrack2.cache)
  507. {
  508. AMTranslationAction amtranslationAction2 = (AMTranslationAction)amaction3;
  509. amtranslationAction2.obj = this.m_trOvrDummyCam;
  510. }
  511. AMRotationTrack amrotationTrack2 = this.m_takeNow.findRotationTrack(this.m_camDummyCamera.gameObject.transform);
  512. amrotationTrack2.obj = this.m_trOvrDummyCam;
  513. foreach (AMAction amaction4 in amrotationTrack2.cache)
  514. {
  515. AMRotationAction amrotationAction2 = (AMRotationAction)amaction4;
  516. amrotationAction2.obj = this.m_trOvrDummyCam;
  517. }
  518. }
  519. this.m_camDummyCamera.gameObject.SetActive(false);
  520. }
  521. if (!GameMain.Instance.VRMode)
  522. {
  523. this.ChangeObj(this.m_takeNow, "CameraMain", GameMain.Instance.MainCamera.gameObject);
  524. }
  525. else if (GameMain.Instance.CMSystem.GetTmpGenericFlag("ダンスOVRカメラタイプ") == 0)
  526. {
  527. if (!DanceMain.KaraokeMode)
  528. {
  529. GameMain.Instance.MainCamera.SetTargetPos(new Vector3(0f, 1.16f, 0f), true);
  530. GameMain.Instance.MainCamera.SetAroundAngle(new Vector2(180f, 0f), true);
  531. GameMain.Instance.MainCamera.SetDistance(5f, true);
  532. }
  533. }
  534. else
  535. {
  536. GameObject y = GameObject.Find("__GameMain__/Camera/CameraMain/CameraMain");
  537. AMBinaryDataBaseObject[] binary_data_list = this.time_line_binary_.binary_data_list;
  538. if (binary_data_list != null)
  539. {
  540. for (int i = 0; i < binary_data_list.Length; i++)
  541. {
  542. if (binary_data_list[i].obj == y)
  543. {
  544. binary_data_list[i].SetGameObject(this.m_trOvrDummyCam.gameObject);
  545. }
  546. }
  547. }
  548. }
  549. this.ChangeObj(this.m_takeNow, "MainDirectionalLight", GameMain.Instance.MainLight.gameObject);
  550. if (DanceMain.SelectDanceData == null || string.IsNullOrEmpty(DanceMain.SelectDanceData.bgm_file_name))
  551. {
  552. GameMain.Instance.SoundMgr.PlayDanceBGM(this.m_strMasterAudioFileName, 0f, true);
  553. }
  554. else
  555. {
  556. GameMain.Instance.SoundMgr.PlayDanceBGM(DanceMain.SelectDanceData.bgm_file_name + ".ogg", 0f, true);
  557. }
  558. AudioSource audioSourceBgm = GameMain.Instance.SoundMgr.GetAudioSourceBgm();
  559. audioSourceBgm.Stop();
  560. AMAudioTrack[] array = this.m_takeNow.findAudioTrack(this.m_strDummyAudioObjectName);
  561. foreach (AMAudioTrack amaudioTrack in array)
  562. {
  563. amaudioTrack.ChangeAudioSource(audioSourceBgm);
  564. }
  565. this.m_audioNew = audioSourceBgm;
  566. if (!this.m_boDebugDummyBody)
  567. {
  568. for (int k = 0; k < this.m_listAnimName.Count; k++)
  569. {
  570. this.m_listMaid.Add(GameMain.Instance.CharacterMgr.GetMaid(k));
  571. }
  572. for (int l = 0; l < this.m_listMaid.Count; l++)
  573. {
  574. this.m_listMaid[l].EyeToCamera(Maid.EyeMoveType.目だけ向ける, 0f);
  575. }
  576. NDebug.Assert(this.m_listKuchiPattern.Count == this.m_listMaid.Count, "メイド数と口パクパターン数が異なります。");
  577. for (int m = 0; m < this.m_listMaid.Count; m++)
  578. {
  579. this.m_listMaid[m].StartKuchipakuPattern(0f, this.m_listKuchiPattern[m], true);
  580. }
  581. }
  582. this.m_eMode = DanceMain.Mode.LoadChara;
  583. }
  584. }
  585. else if (this.m_eMode == DanceMain.Mode.LoadChara)
  586. {
  587. if (!GameMain.Instance.CharacterMgr.IsBusy() || this.m_listMaid.Count == 0)
  588. {
  589. if (!this.m_boDebugDummyBody)
  590. {
  591. int num = 1;
  592. for (;;)
  593. {
  594. string arg = "f";
  595. AMAnimationTrack amanimationTrack = this.m_takeNow.findAnimationTrack(arg + num);
  596. if (amanimationTrack == null)
  597. {
  598. break;
  599. }
  600. int num2 = num - 1;
  601. Maid maid = GameMain.Instance.CharacterMgr.GetMaid(num2);
  602. string name = maid.CrossFade(this.m_listAnimName[num2] + ".anm", false, false, false, 0f, 1f);
  603. Animation component = maid.body0.m_Bones.GetComponent<Animation>();
  604. component.Stop();
  605. amanimationTrack.obj = maid.body0.m_Bones;
  606. NDebug.Assert(amanimationTrack.cache.Count == 1, "キャラアニメーショントラックにはアクションを一つしか使えません。(開始と終了キーひとつのみ)");
  607. foreach (AMAction amaction5 in amanimationTrack.cache)
  608. {
  609. AMAnimationAction amanimationAction = (AMAnimationAction)amaction5;
  610. amanimationAction.amClip = component.GetClip(name);
  611. amanimationAction.obj = maid.body0.m_Bones;
  612. }
  613. if (this.UseFloorHitY)
  614. {
  615. maid.body0.SetBoneHitHeightY(this.m_fFloorY);
  616. }
  617. num++;
  618. }
  619. for (int n = 0; n < this.m_listDummyAnimChara.Count; n++)
  620. {
  621. Maid maid2 = GameMain.Instance.CharacterMgr.GetMaid(n);
  622. for (int num3 = 0; num3 < this.m_listItemObject.Count; num3++)
  623. {
  624. Transform transform = CMT.SearchObjObj(this.m_listDummyAnimChara[n].transform, this.m_listItemObject[num3].transform);
  625. if (transform != null)
  626. {
  627. Transform transform2 = transform;
  628. string name2 = transform2.parent.name;
  629. Transform parent = CMT.SearchObjName(maid2.gameObject.transform, name2, true);
  630. transform2.SetParent(parent, false);
  631. }
  632. }
  633. }
  634. for (int num4 = 0; num4 < this.m_listDebugObj.Count; num4++)
  635. {
  636. UnityEngine.Object.DestroyImmediate(this.m_listDebugObj[num4]);
  637. }
  638. this.m_listDebugObj.Clear();
  639. }
  640. if (string.IsNullOrEmpty(this.m_AdjustScript))
  641. {
  642. this.m_eMode = DanceMain.Mode.LoadAnim;
  643. }
  644. else
  645. {
  646. base.StartCoroutine(this.LoadMotionScript());
  647. this.m_eMode = DanceMain.Mode.LoadScript;
  648. }
  649. }
  650. }
  651. else if (this.m_eMode == DanceMain.Mode.LoadAnim)
  652. {
  653. this.m_AnimatorData.Play(this.m_takeNow.name, true, 0f, false, this.time_line_binary_.GetTrackIDList());
  654. this.m_fTakeStartRealTime = Time.realtimeSinceStartup;
  655. this.m_fNowRealTime = this.m_fTakeStartRealTime;
  656. this.m_eMode = DanceMain.Mode.Exec;
  657. }
  658. else if (this.m_eMode == DanceMain.Mode.Exec)
  659. {
  660. if (!RhythmAction_Mgr.Instance.IsPause)
  661. {
  662. float num5 = RhythmAction_Mgr.Instance.DanceDeltaTime;
  663. if (this.m_audioNew != null && this.m_audioNew.isPlaying)
  664. {
  665. float time = this.m_audioNew.time;
  666. for (int num6 = 0; num6 < this.m_listMaid.Count; num6++)
  667. {
  668. this.m_listMaid[num6].FoceKuchipakuUpdate(time);
  669. }
  670. if (this.m_bAudioFirst)
  671. {
  672. float num7 = time;
  673. num5 = Time.realtimeSinceStartup - this.m_fTakeStartRealTime;
  674. this.m_bAudioFirst = false;
  675. this.m_fOffsetTime = num7 - num5;
  676. RhythmAction_Mgr.Instance.RhythmGame_Start();
  677. }
  678. }
  679. this.m_fNowRealTime += num5;
  680. }
  681. if (this.IsForceDanceEnd || this.m_AnimatorData.takeName == null || this.IsDanceSkip || (DanceMain.KaraokeMode && Input.GetKeyDown(KeyCode.Return)))
  682. {
  683. this.ToFinish();
  684. }
  685. }
  686. else if (this.m_eMode == DanceMain.Mode.Finish)
  687. {
  688. }
  689. if (this.m_AnimatorData.takeName != null)
  690. {
  691. NTime.UpdateNowTime(this.m_fNowRealTime - this.m_fTakeStartRealTime + this.m_fOffsetTime);
  692. this.time_line_binary_.Update(NTime.time);
  693. }
  694. if (GameMain.Instance.VRMode && this.m_trOvrDummyCam != null && this.m_OvrCam != null)
  695. {
  696. this.m_OvrCam.SetPos(this.m_trOvrDummyCam.position);
  697. this.m_OvrCam.SetRotation(this.m_trOvrDummyCam.rotation.eulerAngles);
  698. }
  699. }
  700. private const string m_RhythmMgr_Path = "SceneDance/Rhythm_Action/Prefab/RhythmAction_Mgr";
  701. public static bool IsDanceRecet;
  702. public static DanceData SelectDanceData;
  703. public static bool KaraokeMode;
  704. private DanceMain.Mode m_eMode;
  705. public bool m_boDebugDummyBody;
  706. public Camera m_camDummyCamera;
  707. public List<GameObject> m_listDebugObj;
  708. public AnimatorData m_AnimatorData;
  709. public List<GameObject> m_listDummyAnimChara;
  710. public List<string> m_listAnimName;
  711. public List<GameObject> m_listEventObject;
  712. private Hashtable m_htEventObj = new Hashtable();
  713. public List<string> m_listTestPreset;
  714. public List<GameObject> m_listItemObject = new List<GameObject>();
  715. public List<string> m_listKuchiPakuFile = new List<string>();
  716. private List<string> m_listKuchiPattern = new List<string>();
  717. private List<Maid> m_listMaid = new List<Maid>();
  718. public string m_strDummyAudioObjectName;
  719. private AudioSource m_audioNew;
  720. public string m_strMasterAudioFileName;
  721. public string m_strPlayTakeName = "Take1";
  722. private AMTake m_takeNow;
  723. private string m_strScriptLabel = string.Empty;
  724. private List<Maid> m_listTempMaid = new List<Maid>();
  725. private Maid m_maidUser;
  726. [HideInInspector]
  727. public bool IsForceDanceEnd;
  728. [HideInInspector]
  729. public bool IsDanceSkip;
  730. private OvrCamera m_OvrCam;
  731. private Transform m_trOvrDummyCam;
  732. public bool UseBinaryData;
  733. public string BinaryFolderName;
  734. private DanceObjectDataBinary maid_data_binary_;
  735. private DanceObjectDataBinary maid_item_binary_;
  736. private DanceObjectDataBinary maid_event_binary_;
  737. private AWReadBinaryData time_line_binary_;
  738. [Header("物理境界を変更するか?")]
  739. public bool UseFloorHitY;
  740. public float m_fFloorY;
  741. [SerializeField]
  742. [Header("被写界深度の焦点")]
  743. private float m_DepthFocalSize = 1.2f;
  744. [SerializeField]
  745. [Header("マイク位置調整等に使うモーションスクリプト名")]
  746. private string m_AdjustScript = string.Empty;
  747. [SerializeField]
  748. private string m_ScriptLabel = string.Empty;
  749. [SerializeField]
  750. [Header("AdjustScript読み込みに要する時間")]
  751. private float m_LoadScriptTime = 3f;
  752. private bool m_bFinished;
  753. private float m_fNowRealTime;
  754. private float m_fTakeStartRealTime;
  755. private float m_fOffsetTime;
  756. private bool m_bAudioFirst = true;
  757. private enum Mode
  758. {
  759. ActiveCam,
  760. LoadChara,
  761. LoadAnim,
  762. Exec,
  763. Finish,
  764. LoadScript
  765. }
  766. }