DanceMain.cs 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835
  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. }
  386. }
  387. for (int j = 0; j < this.m_listItemObject.Count; j++)
  388. {
  389. if (this.m_listItemObject[j] != null)
  390. {
  391. UnityEngine.Object.DestroyImmediate(this.m_listItemObject[j]);
  392. }
  393. }
  394. this.m_listItemObject.Clear();
  395. for (int k = 0; k < this.m_listTempMaid.Count; k++)
  396. {
  397. GameMain.Instance.CharacterMgr.BanishmentMaid(this.m_listTempMaid[k]);
  398. }
  399. if (!DanceMain.KaraokeMode)
  400. {
  401. if (this.DanceMaid.Any((Maid maid) => maid != null))
  402. {
  403. GameMain.Instance.CharacterMgr.DeactivateCharaAll();
  404. }
  405. if (this.m_maidUser != null && this.m_maidUser != GameMain.Instance.CharacterMgr.GetMaid(0))
  406. {
  407. GameMain.Instance.CharacterMgr.DeactivateMaid(0);
  408. GameMain.Instance.CharacterMgr.SetActiveMaid(this.m_maidUser, 0);
  409. }
  410. }
  411. this.m_eMode = DanceMain.Mode.Finish;
  412. this.m_bFinished = true;
  413. }
  414. private void ToFinish()
  415. {
  416. this.IsDanceEnd = !this.IsForceDanceEnd;
  417. RhythmAction_Mgr.Instance.RhythmGame_End();
  418. this.Uninit();
  419. if (!DanceMain.IsDanceRecet)
  420. {
  421. DanceSelect.SetNextDance();
  422. }
  423. else
  424. {
  425. NDebug.Assert(!string.IsNullOrEmpty(DanceMain.RecetJumpLabel), "やりなおし時に飛ぶラベルが設定されてません");
  426. }
  427. Debug.Log("Dance ToFinish Script");
  428. if (!string.IsNullOrEmpty(this.m_strScriptLabel))
  429. {
  430. if (DanceMain.IsDanceRecet)
  431. {
  432. Debug.Log("OnEndScene JumpTo " + DanceMain.RecetJumpLabel);
  433. GameMain.Instance.ScriptMgr.adv_kag.JumpLabel(DanceMain.RecetJumpLabel);
  434. }
  435. else
  436. {
  437. if (DanceMain.SelectDanceData != null)
  438. {
  439. GameMain.Instance.ScriptMgr.EvalScript("tf['dance_scene_name'] = '" + DanceMain.SelectDanceData.scene_name + "';");
  440. }
  441. Debug.Log("OnEndScene JumpTo " + this.m_strScriptLabel);
  442. GameMain.Instance.ScriptMgr.adv_kag.JumpLabel(this.m_strScriptLabel);
  443. }
  444. GameMain.Instance.ScriptMgr.adv_kag.Exec();
  445. }
  446. Debug.Log("Dance Finish!!");
  447. }
  448. private IEnumerator LoadMotionScript()
  449. {
  450. if (this.m_AdjustScript.IndexOf(".ks") < 0)
  451. {
  452. this.m_AdjustScript += ".ks";
  453. }
  454. NDebug.Assert(!string.IsNullOrEmpty(this.m_ScriptLabel), string.Format("{0}の飛び先が未指定です。", this.m_AdjustScript));
  455. if (this.m_ScriptLabel.IndexOf("*") < 0)
  456. {
  457. this.m_ScriptLabel = "*" + this.m_ScriptLabel;
  458. }
  459. ScriptManager script_mgr = GameMain.Instance.ScriptMgr;
  460. script_mgr.StopMotionScript();
  461. script_mgr.is_motion_blend = true;
  462. script_mgr.LoadMotionScript(0, false, this.m_AdjustScript, this.m_ScriptLabel, string.Empty, string.Empty, false, true);
  463. float timer = 0f;
  464. while (timer <= this.m_LoadScriptTime)
  465. {
  466. timer += Time.deltaTime;
  467. yield return null;
  468. }
  469. script_mgr.StopMotionScript();
  470. this.m_eMode = DanceMain.Mode.LoadAnim;
  471. yield break;
  472. }
  473. private void Update()
  474. {
  475. if (this.m_eMode == DanceMain.Mode.ActiveCam)
  476. {
  477. if (GameMain.Instance.MainCamera.gameObject.activeSelf)
  478. {
  479. GameMain.Instance.MainCamera.FadeOut(0f, false, null, true, default(Color));
  480. GameMain.Instance.MainCamera.SetCameraType(CameraMain.CameraType.Free);
  481. GameMain.Instance.MainCamera.SetControl(false);
  482. if (this.m_camDummyCamera != null)
  483. {
  484. if (!GameMain.Instance.VRMode)
  485. {
  486. AMTranslationTrack amtranslationTrack = this.m_takeNow.findTranslationTrack(this.m_camDummyCamera.gameObject.transform);
  487. amtranslationTrack.obj = GameMain.Instance.MainCamera.gameObject.transform;
  488. foreach (AMAction amaction in amtranslationTrack.cache)
  489. {
  490. AMTranslationAction amtranslationAction = (AMTranslationAction)amaction;
  491. amtranslationAction.obj = GameMain.Instance.MainCamera.gameObject.transform;
  492. }
  493. AMRotationTrack amrotationTrack = this.m_takeNow.findRotationTrack(this.m_camDummyCamera.gameObject.transform);
  494. amrotationTrack.obj = GameMain.Instance.MainCamera.gameObject.transform;
  495. foreach (AMAction amaction2 in amrotationTrack.cache)
  496. {
  497. AMRotationAction amrotationAction = (AMRotationAction)amaction2;
  498. amrotationAction.obj = GameMain.Instance.MainCamera.gameObject.transform;
  499. }
  500. }
  501. else if (GameMain.Instance.CMSystem.GetTmpGenericFlag("ダンスOVRカメラタイプ") != 0)
  502. {
  503. AMTranslationTrack amtranslationTrack2 = this.m_takeNow.findTranslationTrack(this.m_camDummyCamera.gameObject.transform);
  504. amtranslationTrack2.obj = this.m_trOvrDummyCam;
  505. foreach (AMAction amaction3 in amtranslationTrack2.cache)
  506. {
  507. AMTranslationAction amtranslationAction2 = (AMTranslationAction)amaction3;
  508. amtranslationAction2.obj = this.m_trOvrDummyCam;
  509. }
  510. AMRotationTrack amrotationTrack2 = this.m_takeNow.findRotationTrack(this.m_camDummyCamera.gameObject.transform);
  511. amrotationTrack2.obj = this.m_trOvrDummyCam;
  512. foreach (AMAction amaction4 in amrotationTrack2.cache)
  513. {
  514. AMRotationAction amrotationAction2 = (AMRotationAction)amaction4;
  515. amrotationAction2.obj = this.m_trOvrDummyCam;
  516. }
  517. }
  518. this.m_camDummyCamera.gameObject.SetActive(false);
  519. }
  520. if (!GameMain.Instance.VRMode)
  521. {
  522. this.ChangeObj(this.m_takeNow, "CameraMain", GameMain.Instance.MainCamera.gameObject);
  523. }
  524. else if (GameMain.Instance.CMSystem.GetTmpGenericFlag("ダンスOVRカメラタイプ") == 0)
  525. {
  526. if (!DanceMain.KaraokeMode)
  527. {
  528. GameMain.Instance.MainCamera.SetTargetPos(new Vector3(0f, 1.16f, 0f), true);
  529. GameMain.Instance.MainCamera.SetAroundAngle(new Vector2(180f, 0f), true);
  530. GameMain.Instance.MainCamera.SetDistance(5f, true);
  531. }
  532. }
  533. else
  534. {
  535. GameObject y = GameObject.Find("__GameMain__/Camera/CameraMain/CameraMain");
  536. AMBinaryDataBaseObject[] binary_data_list = this.time_line_binary_.binary_data_list;
  537. if (binary_data_list != null)
  538. {
  539. for (int i = 0; i < binary_data_list.Length; i++)
  540. {
  541. if (binary_data_list[i].obj == y)
  542. {
  543. binary_data_list[i].SetGameObject(this.m_trOvrDummyCam.gameObject);
  544. }
  545. }
  546. }
  547. }
  548. this.ChangeObj(this.m_takeNow, "MainDirectionalLight", GameMain.Instance.MainLight.gameObject);
  549. if (DanceMain.SelectDanceData == null || string.IsNullOrEmpty(DanceMain.SelectDanceData.bgm_file_name))
  550. {
  551. GameMain.Instance.SoundMgr.PlayDanceBGM(this.m_strMasterAudioFileName, 0f, true);
  552. }
  553. else
  554. {
  555. GameMain.Instance.SoundMgr.PlayDanceBGM(DanceMain.SelectDanceData.bgm_file_name + ".ogg", 0f, true);
  556. }
  557. AudioSource audioSourceBgm = GameMain.Instance.SoundMgr.GetAudioSourceBgm();
  558. audioSourceBgm.Stop();
  559. AMAudioTrack[] array = this.m_takeNow.findAudioTrack(this.m_strDummyAudioObjectName);
  560. foreach (AMAudioTrack amaudioTrack in array)
  561. {
  562. amaudioTrack.ChangeAudioSource(audioSourceBgm);
  563. }
  564. this.m_audioNew = audioSourceBgm;
  565. if (!this.m_boDebugDummyBody)
  566. {
  567. for (int k = 0; k < this.m_listAnimName.Count; k++)
  568. {
  569. this.m_listMaid.Add(GameMain.Instance.CharacterMgr.GetMaid(k));
  570. }
  571. for (int l = 0; l < this.m_listMaid.Count; l++)
  572. {
  573. this.m_listMaid[l].EyeToCamera(Maid.EyeMoveType.目だけ向ける, 0f);
  574. }
  575. NDebug.Assert(this.m_listKuchiPattern.Count == this.m_listMaid.Count, "メイド数と口パクパターン数が異なります。");
  576. for (int m = 0; m < this.m_listMaid.Count; m++)
  577. {
  578. this.m_listMaid[m].StartKuchipakuPattern(0f, this.m_listKuchiPattern[m], true);
  579. }
  580. }
  581. this.m_eMode = DanceMain.Mode.LoadChara;
  582. }
  583. }
  584. else if (this.m_eMode == DanceMain.Mode.LoadChara)
  585. {
  586. if (!GameMain.Instance.CharacterMgr.IsBusy() || this.m_listMaid.Count == 0)
  587. {
  588. if (!this.m_boDebugDummyBody)
  589. {
  590. int num = 1;
  591. for (;;)
  592. {
  593. string arg = "f";
  594. AMAnimationTrack amanimationTrack = this.m_takeNow.findAnimationTrack(arg + num);
  595. if (amanimationTrack == null)
  596. {
  597. break;
  598. }
  599. int num2 = num - 1;
  600. Maid maid = GameMain.Instance.CharacterMgr.GetMaid(num2);
  601. string name = maid.CrossFade(this.m_listAnimName[num2] + ".anm", false, false, false, 0f, 1f);
  602. Animation component = maid.body0.m_Bones.GetComponent<Animation>();
  603. component.Stop();
  604. amanimationTrack.obj = maid.body0.m_Bones;
  605. NDebug.Assert(amanimationTrack.cache.Count == 1, "キャラアニメーショントラックにはアクションを一つしか使えません。(開始と終了キーひとつのみ)");
  606. foreach (AMAction amaction5 in amanimationTrack.cache)
  607. {
  608. AMAnimationAction amanimationAction = (AMAnimationAction)amaction5;
  609. amanimationAction.amClip = component.GetClip(name);
  610. amanimationAction.obj = maid.body0.m_Bones;
  611. }
  612. if (this.UseFloorHitY)
  613. {
  614. maid.body0.SetBoneHitHeightY(this.m_fFloorY);
  615. }
  616. num++;
  617. }
  618. for (int n = 0; n < this.m_listDummyAnimChara.Count; n++)
  619. {
  620. Maid maid2 = GameMain.Instance.CharacterMgr.GetMaid(n);
  621. for (int num3 = 0; num3 < this.m_listItemObject.Count; num3++)
  622. {
  623. Transform transform = CMT.SearchObjObj(this.m_listDummyAnimChara[n].transform, this.m_listItemObject[num3].transform);
  624. if (transform != null)
  625. {
  626. Transform transform2 = transform;
  627. string name2 = transform2.parent.name;
  628. Transform parent = CMT.SearchObjName(maid2.gameObject.transform, name2, true);
  629. transform2.SetParent(parent, false);
  630. }
  631. }
  632. }
  633. for (int num4 = 0; num4 < this.m_listDebugObj.Count; num4++)
  634. {
  635. UnityEngine.Object.DestroyImmediate(this.m_listDebugObj[num4]);
  636. }
  637. this.m_listDebugObj.Clear();
  638. }
  639. if (string.IsNullOrEmpty(this.m_AdjustScript))
  640. {
  641. this.m_eMode = DanceMain.Mode.LoadAnim;
  642. }
  643. else
  644. {
  645. base.StartCoroutine(this.LoadMotionScript());
  646. this.m_eMode = DanceMain.Mode.LoadScript;
  647. }
  648. }
  649. }
  650. else if (this.m_eMode == DanceMain.Mode.LoadAnim)
  651. {
  652. this.m_AnimatorData.Play(this.m_takeNow.name, true, 0f, false, this.time_line_binary_.GetTrackIDList());
  653. this.m_fTakeStartRealTime = Time.realtimeSinceStartup;
  654. this.m_fNowRealTime = this.m_fTakeStartRealTime;
  655. this.m_eMode = DanceMain.Mode.Exec;
  656. }
  657. else if (this.m_eMode == DanceMain.Mode.Exec)
  658. {
  659. if (!RhythmAction_Mgr.Instance.IsPause)
  660. {
  661. float num5 = RhythmAction_Mgr.Instance.DanceDeltaTime;
  662. if (this.m_audioNew != null && this.m_audioNew.isPlaying)
  663. {
  664. float time = this.m_audioNew.time;
  665. for (int num6 = 0; num6 < this.m_listMaid.Count; num6++)
  666. {
  667. this.m_listMaid[num6].FoceKuchipakuUpdate(time);
  668. }
  669. if (this.m_bAudioFirst)
  670. {
  671. float num7 = time;
  672. num5 = Time.realtimeSinceStartup - this.m_fTakeStartRealTime;
  673. this.m_bAudioFirst = false;
  674. this.m_fOffsetTime = num7 - num5;
  675. RhythmAction_Mgr.Instance.RhythmGame_Start();
  676. }
  677. }
  678. this.m_fNowRealTime += num5;
  679. }
  680. if (this.IsForceDanceEnd || this.m_AnimatorData.takeName == null || this.IsDanceSkip || (DanceMain.KaraokeMode && Input.GetKeyDown(KeyCode.Return)))
  681. {
  682. this.ToFinish();
  683. }
  684. }
  685. else if (this.m_eMode == DanceMain.Mode.Finish)
  686. {
  687. }
  688. if (this.m_AnimatorData.takeName != null)
  689. {
  690. NTime.UpdateNowTime(this.m_fNowRealTime - this.m_fTakeStartRealTime + this.m_fOffsetTime);
  691. this.time_line_binary_.Update(NTime.time);
  692. }
  693. if (GameMain.Instance.VRMode && this.m_trOvrDummyCam != null && this.m_OvrCam != null)
  694. {
  695. this.m_OvrCam.SetPos(this.m_trOvrDummyCam.position);
  696. this.m_OvrCam.SetRotation(this.m_trOvrDummyCam.rotation.eulerAngles);
  697. }
  698. }
  699. private const string m_RhythmMgr_Path = "SceneDance/Rhythm_Action/Prefab/RhythmAction_Mgr";
  700. public static bool IsDanceRecet;
  701. public static DanceData SelectDanceData;
  702. public static bool KaraokeMode;
  703. private DanceMain.Mode m_eMode;
  704. public bool m_boDebugDummyBody;
  705. public Camera m_camDummyCamera;
  706. public List<GameObject> m_listDebugObj;
  707. public AnimatorData m_AnimatorData;
  708. public List<GameObject> m_listDummyAnimChara;
  709. public List<string> m_listAnimName;
  710. public List<GameObject> m_listEventObject;
  711. private Hashtable m_htEventObj = new Hashtable();
  712. public List<string> m_listTestPreset;
  713. public List<GameObject> m_listItemObject = new List<GameObject>();
  714. public List<string> m_listKuchiPakuFile = new List<string>();
  715. private List<string> m_listKuchiPattern = new List<string>();
  716. private List<Maid> m_listMaid = new List<Maid>();
  717. public string m_strDummyAudioObjectName;
  718. private AudioSource m_audioNew;
  719. public string m_strMasterAudioFileName;
  720. public string m_strPlayTakeName = "Take1";
  721. private AMTake m_takeNow;
  722. private string m_strScriptLabel = string.Empty;
  723. private List<Maid> m_listTempMaid = new List<Maid>();
  724. private Maid m_maidUser;
  725. [HideInInspector]
  726. public bool IsForceDanceEnd;
  727. [HideInInspector]
  728. public bool IsDanceSkip;
  729. private OvrCamera m_OvrCam;
  730. private Transform m_trOvrDummyCam;
  731. public bool UseBinaryData;
  732. public string BinaryFolderName;
  733. private DanceObjectDataBinary maid_data_binary_;
  734. private DanceObjectDataBinary maid_item_binary_;
  735. private DanceObjectDataBinary maid_event_binary_;
  736. private AWReadBinaryData time_line_binary_;
  737. [Header("物理境界を変更するか?")]
  738. public bool UseFloorHitY;
  739. public float m_fFloorY;
  740. [SerializeField]
  741. [Header("被写界深度の焦点")]
  742. private float m_DepthFocalSize = 1.2f;
  743. [SerializeField]
  744. [Header("マイク位置調整等に使うモーションスクリプト名")]
  745. private string m_AdjustScript = string.Empty;
  746. [SerializeField]
  747. private string m_ScriptLabel = string.Empty;
  748. [SerializeField]
  749. [Header("AdjustScript読み込みに要する時間")]
  750. private float m_LoadScriptTime = 3f;
  751. private bool m_bFinished;
  752. private float m_fNowRealTime;
  753. private float m_fTakeStartRealTime;
  754. private float m_fOffsetTime;
  755. private bool m_bAudioFirst = true;
  756. private enum Mode
  757. {
  758. ActiveCam,
  759. LoadChara,
  760. LoadAnim,
  761. Exec,
  762. Finish,
  763. LoadScript
  764. }
  765. }