DanceMain.cs 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832
  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))
  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. for (int num3 = 0; num3 < DanceMain.SelectDanceData.maid_order.Count; num3++)
  226. {
  227. int index2 = DanceMain.SelectDanceData.maid_order[num3];
  228. if (!RhythmAction_Mgr.Instance.FactOrderList[index2])
  229. {
  230. RhythmAction_Mgr.Instance.FactOrderList[index2] = GameMain.Instance.CharacterMgr.GetMaid(num3);
  231. }
  232. }
  233. }
  234. }
  235. private void Start()
  236. {
  237. if (GameMain.Instance.VRMode)
  238. {
  239. GameObject gameObject = GameObject.Find("effect");
  240. if (gameObject != null)
  241. {
  242. ParticleSystem[] componentsInChildren = gameObject.GetComponentsInChildren<ParticleSystem>(true);
  243. foreach (ParticleSystem particleSystem in componentsInChildren)
  244. {
  245. Renderer component = particleSystem.GetComponent<Renderer>();
  246. if (component != null)
  247. {
  248. component.shadowCastingMode = ShadowCastingMode.Off;
  249. component.receiveShadows = false;
  250. }
  251. }
  252. }
  253. }
  254. if (!DanceMain.KaraokeMode)
  255. {
  256. GameMain.Instance.BgMgr.DeleteBg();
  257. }
  258. GameMain.Instance.MainLight.Reset();
  259. GameMain.Instance.SoundMgr.StopBGM(0f);
  260. GameMain.Instance.MainCamera.gameObject.SetActive(true);
  261. if (!DanceMain.KaraokeMode)
  262. {
  263. GameMain.Instance.MainCamera.Reset(CameraMain.CameraType.Target, false);
  264. }
  265. for (int j = 0; j < this.m_listEventObject.Count; j++)
  266. {
  267. GameObject gameObject2 = this.m_listEventObject[j];
  268. NDebug.Assert(!this.m_htEventObj.ContainsKey(gameObject2.name), "listEventObjectに複数同じObjectを追加しようとしました。" + this.m_listEventObject[j].name);
  269. this.m_htEventObj.Add(gameObject2.name, gameObject2);
  270. }
  271. this.m_takeNow = this.m_AnimatorData.getTake(this.m_strPlayTakeName);
  272. NDebug.Assert(this.m_takeNow != null, "再生するテイク名PlayTakeNameが不正です。" + this.m_strPlayTakeName);
  273. }
  274. public void SetFace(int f_nMaidNo, string f_strFace)
  275. {
  276. RhythmAction_Mgr.Instance.SetTimeLineFace(f_nMaidNo, f_strFace);
  277. Maid maid = GameMain.Instance.CharacterMgr.GetMaid(f_nMaidNo);
  278. if (RhythmAction_Mgr.Instance.GetMaidFaceStop(f_nMaidNo))
  279. {
  280. return;
  281. }
  282. maid.FaceAnime(f_strFace, 1f, 0);
  283. }
  284. public void SetFaceBlend(int f_nMaidNo, string f_strFace)
  285. {
  286. RhythmAction_Mgr.Instance.SetTimeLineFaceBlend(f_nMaidNo, f_strFace);
  287. Maid maid = GameMain.Instance.CharacterMgr.GetMaid(f_nMaidNo);
  288. if (RhythmAction_Mgr.Instance.GetMaidFaceBlendStop(f_nMaidNo))
  289. {
  290. return;
  291. }
  292. maid.FaceBlend(f_strFace);
  293. }
  294. public void SetMaidVisible(int f_nMaidNo, bool visible)
  295. {
  296. Maid maid = GameMain.Instance.CharacterMgr.GetMaid(f_nMaidNo);
  297. maid.transform.localScale = ((!visible) ? Vector3.zero : Vector3.one);
  298. }
  299. public void SwitchObject(string f_strObjName, bool bEnable)
  300. {
  301. (this.m_htEventObj[f_strObjName] as GameObject).SetActive(bEnable);
  302. }
  303. public void EyeToCam(int f_nMaidNo, string f_strType)
  304. {
  305. Maid maid = GameMain.Instance.CharacterMgr.GetMaid(f_nMaidNo);
  306. try
  307. {
  308. maid.EyeToCamera((Maid.EyeMoveType)Enum.Parse(typeof(Maid.EyeMoveType), f_strType), 0f);
  309. }
  310. catch (Exception ex)
  311. {
  312. NDebug.Assert("EyeToCam 目線タイプ " + f_strType + " は不正です。\n" + ex.Message, false);
  313. }
  314. }
  315. public void FadeOut(float f_fTime)
  316. {
  317. GameMain.Instance.MainCamera.FadeOut(f_fTime, false, null, false, default(Color));
  318. }
  319. public void FadeIn(float f_fTime)
  320. {
  321. GameMain.Instance.MainCamera.FadeIn(f_fTime, false, null, false, true, default(Color));
  322. }
  323. private void ChangeObj(AMTake f_take, string f_strOldObjName, GameObject f_goNew)
  324. {
  325. AMTranslationTrack[] array = f_take.findTranslationTrack(f_strOldObjName);
  326. for (int i = 0; i < array.Length; i++)
  327. {
  328. array[i].changeObject(f_goNew.transform);
  329. }
  330. AMRotationTrack[] array2 = f_take.findRotationTrack(f_strOldObjName);
  331. for (int j = 0; j < array2.Length; j++)
  332. {
  333. array2[j].changeObject(f_goNew.transform);
  334. }
  335. AMPropertyTrack[] array3 = f_take.findPropertyTrack(f_strOldObjName);
  336. for (int k = 0; k < array3.Length; k++)
  337. {
  338. array3[k].changeObject(f_goNew);
  339. }
  340. }
  341. public void OnDestroy()
  342. {
  343. this.Uninit();
  344. Debug.Log("DanceMain::OnDestroy");
  345. }
  346. private void Uninit()
  347. {
  348. if (this.m_bFinished)
  349. {
  350. return;
  351. }
  352. if (RhythmAction_Mgr.Instance && DanceMain.KaraokeMode)
  353. {
  354. RhythmAction_Mgr.Instance.KaraokeEnd();
  355. }
  356. Debug.Log("DanceMain::Uninit");
  357. this.m_AnimatorData.StopLoop();
  358. if (GameMain.Instance.MainLight != null)
  359. {
  360. GameMain.Instance.MainLight.Reset();
  361. }
  362. if (GameMain.Instance.MainCamera != null)
  363. {
  364. GameMain.Instance.MainCamera.Reset(CameraMain.CameraType.Target, true);
  365. GameMain.Instance.MainCamera.FadeOut(0f, false, null, true, default(Color));
  366. }
  367. if (GameMain.Instance.SoundMgr != null)
  368. {
  369. GameMain.Instance.SoundMgr.StopBGM(0f);
  370. }
  371. if (GameMain.Instance.CharacterMgr != null)
  372. {
  373. GameMain.Instance.CharacterMgr.ResetCharaPosAll();
  374. }
  375. for (int i = 0; i < this.m_listMaid.Count; i++)
  376. {
  377. if (this.m_listMaid[i] != null)
  378. {
  379. this.m_listMaid[i].transform.localScale = Vector3.one;
  380. this.m_listMaid[i].StopKuchipakuPattern();
  381. this.m_listMaid[i].EyeToCamera(Maid.EyeMoveType.目と顔を向ける, 0f);
  382. }
  383. }
  384. for (int j = 0; j < this.m_listItemObject.Count; j++)
  385. {
  386. if (this.m_listItemObject[j] != null)
  387. {
  388. UnityEngine.Object.DestroyImmediate(this.m_listItemObject[j]);
  389. }
  390. }
  391. this.m_listItemObject.Clear();
  392. for (int k = 0; k < this.m_listTempMaid.Count; k++)
  393. {
  394. GameMain.Instance.CharacterMgr.BanishmentMaid(this.m_listTempMaid[k]);
  395. }
  396. if (!DanceMain.KaraokeMode)
  397. {
  398. if (this.DanceMaid.Any((Maid maid) => maid != null))
  399. {
  400. GameMain.Instance.CharacterMgr.DeactivateCharaAll();
  401. }
  402. if (this.m_maidUser != null && this.m_maidUser != GameMain.Instance.CharacterMgr.GetMaid(0))
  403. {
  404. GameMain.Instance.CharacterMgr.DeactivateMaid(0);
  405. GameMain.Instance.CharacterMgr.SetActiveMaid(this.m_maidUser, 0);
  406. }
  407. }
  408. this.m_eMode = DanceMain.Mode.Finish;
  409. this.m_bFinished = true;
  410. }
  411. private void ToFinish()
  412. {
  413. this.IsDanceEnd = !this.IsForceDanceEnd;
  414. RhythmAction_Mgr.Instance.RhythmGame_End();
  415. this.Uninit();
  416. if (!DanceMain.IsDanceRecet)
  417. {
  418. DanceSelect.SetNextDance();
  419. }
  420. else
  421. {
  422. NDebug.Assert(!string.IsNullOrEmpty(DanceMain.RecetJumpLabel), "やりなおし時に飛ぶラベルが設定されてません");
  423. }
  424. Debug.Log("Dance ToFinish Script");
  425. if (!string.IsNullOrEmpty(this.m_strScriptLabel))
  426. {
  427. if (DanceMain.IsDanceRecet)
  428. {
  429. Debug.Log("OnEndScene JumpTo " + DanceMain.RecetJumpLabel);
  430. GameMain.Instance.ScriptMgr.adv_kag.JumpLabel(DanceMain.RecetJumpLabel);
  431. }
  432. else
  433. {
  434. if (DanceMain.SelectDanceData != null)
  435. {
  436. GameMain.Instance.ScriptMgr.EvalScript("tf['dance_scene_name'] = '" + DanceMain.SelectDanceData.scene_name + "';");
  437. }
  438. Debug.Log("OnEndScene JumpTo " + this.m_strScriptLabel);
  439. GameMain.Instance.ScriptMgr.adv_kag.JumpLabel(this.m_strScriptLabel);
  440. }
  441. GameMain.Instance.ScriptMgr.adv_kag.Exec();
  442. }
  443. Debug.Log("Dance Finish!!");
  444. }
  445. private IEnumerator LoadMotionScript()
  446. {
  447. if (this.m_AdjustScript.IndexOf(".ks") < 0)
  448. {
  449. this.m_AdjustScript += ".ks";
  450. }
  451. NDebug.Assert(!string.IsNullOrEmpty(this.m_ScriptLabel), string.Format("{0}の飛び先が未指定です。", this.m_AdjustScript));
  452. if (this.m_ScriptLabel.IndexOf("*") < 0)
  453. {
  454. this.m_ScriptLabel = "*" + this.m_ScriptLabel;
  455. }
  456. ScriptManager script_mgr = GameMain.Instance.ScriptMgr;
  457. script_mgr.StopMotionScript();
  458. script_mgr.is_motion_blend = true;
  459. script_mgr.LoadMotionScript(0, false, this.m_AdjustScript, this.m_ScriptLabel, string.Empty, string.Empty, false, true);
  460. float timer = 0f;
  461. while (timer <= this.m_LoadScriptTime)
  462. {
  463. timer += Time.deltaTime;
  464. yield return null;
  465. }
  466. script_mgr.StopMotionScript();
  467. this.m_eMode = DanceMain.Mode.LoadAnim;
  468. yield break;
  469. }
  470. private void Update()
  471. {
  472. if (this.m_eMode == DanceMain.Mode.ActiveCam)
  473. {
  474. if (GameMain.Instance.MainCamera.gameObject.activeSelf)
  475. {
  476. GameMain.Instance.MainCamera.FadeOut(0f, false, null, true, default(Color));
  477. GameMain.Instance.MainCamera.SetCameraType(CameraMain.CameraType.Free);
  478. GameMain.Instance.MainCamera.SetControl(false);
  479. if (this.m_camDummyCamera != null)
  480. {
  481. if (!GameMain.Instance.VRMode)
  482. {
  483. AMTranslationTrack amtranslationTrack = this.m_takeNow.findTranslationTrack(this.m_camDummyCamera.gameObject.transform);
  484. amtranslationTrack.obj = GameMain.Instance.MainCamera.gameObject.transform;
  485. foreach (AMAction amaction in amtranslationTrack.cache)
  486. {
  487. AMTranslationAction amtranslationAction = (AMTranslationAction)amaction;
  488. amtranslationAction.obj = GameMain.Instance.MainCamera.gameObject.transform;
  489. }
  490. AMRotationTrack amrotationTrack = this.m_takeNow.findRotationTrack(this.m_camDummyCamera.gameObject.transform);
  491. amrotationTrack.obj = GameMain.Instance.MainCamera.gameObject.transform;
  492. foreach (AMAction amaction2 in amrotationTrack.cache)
  493. {
  494. AMRotationAction amrotationAction = (AMRotationAction)amaction2;
  495. amrotationAction.obj = GameMain.Instance.MainCamera.gameObject.transform;
  496. }
  497. }
  498. else if (GameMain.Instance.CMSystem.GetTmpGenericFlag("ダンスOVRカメラタイプ") != 0)
  499. {
  500. AMTranslationTrack amtranslationTrack2 = this.m_takeNow.findTranslationTrack(this.m_camDummyCamera.gameObject.transform);
  501. amtranslationTrack2.obj = this.m_trOvrDummyCam;
  502. foreach (AMAction amaction3 in amtranslationTrack2.cache)
  503. {
  504. AMTranslationAction amtranslationAction2 = (AMTranslationAction)amaction3;
  505. amtranslationAction2.obj = this.m_trOvrDummyCam;
  506. }
  507. AMRotationTrack amrotationTrack2 = this.m_takeNow.findRotationTrack(this.m_camDummyCamera.gameObject.transform);
  508. amrotationTrack2.obj = this.m_trOvrDummyCam;
  509. foreach (AMAction amaction4 in amrotationTrack2.cache)
  510. {
  511. AMRotationAction amrotationAction2 = (AMRotationAction)amaction4;
  512. amrotationAction2.obj = this.m_trOvrDummyCam;
  513. }
  514. }
  515. this.m_camDummyCamera.gameObject.SetActive(false);
  516. }
  517. if (!GameMain.Instance.VRMode)
  518. {
  519. this.ChangeObj(this.m_takeNow, "CameraMain", GameMain.Instance.MainCamera.gameObject);
  520. }
  521. else if (GameMain.Instance.CMSystem.GetTmpGenericFlag("ダンスOVRカメラタイプ") == 0)
  522. {
  523. if (!DanceMain.KaraokeMode)
  524. {
  525. GameMain.Instance.MainCamera.SetTargetPos(new Vector3(0f, 1.16f, 0f), true);
  526. GameMain.Instance.MainCamera.SetAroundAngle(new Vector2(180f, 0f), true);
  527. GameMain.Instance.MainCamera.SetDistance(5f, true);
  528. }
  529. }
  530. else
  531. {
  532. GameObject y = GameObject.Find("__GameMain__/Camera/CameraMain/CameraMain");
  533. AMBinaryDataBaseObject[] binary_data_list = this.time_line_binary_.binary_data_list;
  534. if (binary_data_list != null)
  535. {
  536. for (int i = 0; i < binary_data_list.Length; i++)
  537. {
  538. if (binary_data_list[i].obj == y)
  539. {
  540. binary_data_list[i].SetGameObject(this.m_trOvrDummyCam.gameObject);
  541. }
  542. }
  543. }
  544. }
  545. this.ChangeObj(this.m_takeNow, "MainDirectionalLight", GameMain.Instance.MainLight.gameObject);
  546. if (DanceMain.SelectDanceData == null || string.IsNullOrEmpty(DanceMain.SelectDanceData.bgm_file_name))
  547. {
  548. GameMain.Instance.SoundMgr.PlayDanceBGM(this.m_strMasterAudioFileName, 0f, true);
  549. }
  550. else
  551. {
  552. GameMain.Instance.SoundMgr.PlayDanceBGM(DanceMain.SelectDanceData.bgm_file_name + ".ogg", 0f, true);
  553. }
  554. AudioSource audioSourceBgm = GameMain.Instance.SoundMgr.GetAudioSourceBgm();
  555. audioSourceBgm.Stop();
  556. AMAudioTrack[] array = this.m_takeNow.findAudioTrack(this.m_strDummyAudioObjectName);
  557. foreach (AMAudioTrack amaudioTrack in array)
  558. {
  559. amaudioTrack.ChangeAudioSource(audioSourceBgm);
  560. }
  561. this.m_audioNew = audioSourceBgm;
  562. if (!this.m_boDebugDummyBody)
  563. {
  564. for (int k = 0; k < this.m_listAnimName.Count; k++)
  565. {
  566. this.m_listMaid.Add(GameMain.Instance.CharacterMgr.GetMaid(k));
  567. }
  568. for (int l = 0; l < this.m_listMaid.Count; l++)
  569. {
  570. this.m_listMaid[l].EyeToCamera(Maid.EyeMoveType.目だけ向ける, 0f);
  571. }
  572. NDebug.Assert(this.m_listKuchiPattern.Count == this.m_listMaid.Count, "メイド数と口パクパターン数が異なります。");
  573. for (int m = 0; m < this.m_listMaid.Count; m++)
  574. {
  575. this.m_listMaid[m].StartKuchipakuPattern(0f, this.m_listKuchiPattern[m], true);
  576. }
  577. }
  578. this.m_eMode = DanceMain.Mode.LoadChara;
  579. }
  580. }
  581. else if (this.m_eMode == DanceMain.Mode.LoadChara)
  582. {
  583. if (!GameMain.Instance.CharacterMgr.IsBusy() || this.m_listMaid.Count == 0)
  584. {
  585. if (!this.m_boDebugDummyBody)
  586. {
  587. int num = 1;
  588. for (;;)
  589. {
  590. string arg = "f";
  591. AMAnimationTrack amanimationTrack = this.m_takeNow.findAnimationTrack(arg + num);
  592. if (amanimationTrack == null)
  593. {
  594. break;
  595. }
  596. int num2 = num - 1;
  597. Maid maid = GameMain.Instance.CharacterMgr.GetMaid(num2);
  598. string name = maid.CrossFade(this.m_listAnimName[num2] + ".anm", false, false, false, 0f, 1f);
  599. Animation component = maid.body0.m_Bones.GetComponent<Animation>();
  600. component.Stop();
  601. amanimationTrack.obj = maid.body0.m_Bones;
  602. NDebug.Assert(amanimationTrack.cache.Count == 1, "キャラアニメーショントラックにはアクションを一つしか使えません。(開始と終了キーひとつのみ)");
  603. foreach (AMAction amaction5 in amanimationTrack.cache)
  604. {
  605. AMAnimationAction amanimationAction = (AMAnimationAction)amaction5;
  606. amanimationAction.amClip = component.GetClip(name);
  607. amanimationAction.obj = maid.body0.m_Bones;
  608. }
  609. if (this.UseFloorHitY)
  610. {
  611. maid.body0.SetBoneHitHeightY(this.m_fFloorY);
  612. }
  613. num++;
  614. }
  615. for (int n = 0; n < this.m_listDummyAnimChara.Count; n++)
  616. {
  617. Maid maid2 = GameMain.Instance.CharacterMgr.GetMaid(n);
  618. for (int num3 = 0; num3 < this.m_listItemObject.Count; num3++)
  619. {
  620. Transform transform = CMT.SearchObjObj(this.m_listDummyAnimChara[n].transform, this.m_listItemObject[num3].transform);
  621. if (transform != null)
  622. {
  623. Transform transform2 = transform;
  624. string name2 = transform2.parent.name;
  625. Transform parent = CMT.SearchObjName(maid2.gameObject.transform, name2, true);
  626. transform2.SetParent(parent, false);
  627. }
  628. }
  629. }
  630. for (int num4 = 0; num4 < this.m_listDebugObj.Count; num4++)
  631. {
  632. UnityEngine.Object.DestroyImmediate(this.m_listDebugObj[num4]);
  633. }
  634. this.m_listDebugObj.Clear();
  635. }
  636. if (string.IsNullOrEmpty(this.m_AdjustScript))
  637. {
  638. this.m_eMode = DanceMain.Mode.LoadAnim;
  639. }
  640. else
  641. {
  642. base.StartCoroutine(this.LoadMotionScript());
  643. this.m_eMode = DanceMain.Mode.LoadScript;
  644. }
  645. }
  646. }
  647. else if (this.m_eMode == DanceMain.Mode.LoadAnim)
  648. {
  649. this.m_AnimatorData.Play(this.m_takeNow.name, true, 0f, false, this.time_line_binary_.GetTrackIDList());
  650. this.m_fTakeStartRealTime = Time.realtimeSinceStartup;
  651. this.m_fNowRealTime = this.m_fTakeStartRealTime;
  652. this.m_eMode = DanceMain.Mode.Exec;
  653. }
  654. else if (this.m_eMode == DanceMain.Mode.Exec)
  655. {
  656. if (!RhythmAction_Mgr.Instance.IsPause)
  657. {
  658. float num5 = RhythmAction_Mgr.Instance.DanceDeltaTime;
  659. if (this.m_audioNew != null && this.m_audioNew.isPlaying)
  660. {
  661. float time = this.m_audioNew.time;
  662. for (int num6 = 0; num6 < this.m_listMaid.Count; num6++)
  663. {
  664. this.m_listMaid[num6].FoceKuchipakuUpdate(time);
  665. }
  666. if (this.m_bAudioFirst)
  667. {
  668. float num7 = time;
  669. num5 = Time.realtimeSinceStartup - this.m_fTakeStartRealTime;
  670. this.m_bAudioFirst = false;
  671. this.m_fOffsetTime = num7 - num5;
  672. RhythmAction_Mgr.Instance.RhythmGame_Start();
  673. }
  674. }
  675. this.m_fNowRealTime += num5;
  676. }
  677. if (this.IsForceDanceEnd || this.m_AnimatorData.takeName == null || this.IsDanceSkip || (DanceMain.KaraokeMode && Input.GetKeyDown(KeyCode.Return)))
  678. {
  679. this.ToFinish();
  680. }
  681. }
  682. else if (this.m_eMode == DanceMain.Mode.Finish)
  683. {
  684. }
  685. if (this.m_AnimatorData.takeName != null)
  686. {
  687. NTime.UpdateNowTime(this.m_fNowRealTime - this.m_fTakeStartRealTime + this.m_fOffsetTime);
  688. this.time_line_binary_.Update(NTime.time);
  689. }
  690. if (GameMain.Instance.VRMode && this.m_trOvrDummyCam != null && this.m_OvrCam != null)
  691. {
  692. this.m_OvrCam.SetPos(this.m_trOvrDummyCam.position);
  693. this.m_OvrCam.SetRotation(this.m_trOvrDummyCam.rotation.eulerAngles);
  694. }
  695. }
  696. private const string m_RhythmMgr_Path = "SceneDance/Rhythm_Action/Prefab/RhythmAction_Mgr";
  697. public static bool IsDanceRecet;
  698. public static DanceData SelectDanceData;
  699. public static bool KaraokeMode;
  700. private DanceMain.Mode m_eMode;
  701. public bool m_boDebugDummyBody;
  702. public Camera m_camDummyCamera;
  703. public List<GameObject> m_listDebugObj;
  704. public AnimatorData m_AnimatorData;
  705. public List<GameObject> m_listDummyAnimChara;
  706. public List<string> m_listAnimName;
  707. public List<GameObject> m_listEventObject;
  708. private Hashtable m_htEventObj = new Hashtable();
  709. public List<string> m_listTestPreset;
  710. public List<GameObject> m_listItemObject = new List<GameObject>();
  711. public List<string> m_listKuchiPakuFile = new List<string>();
  712. private List<string> m_listKuchiPattern = new List<string>();
  713. private List<Maid> m_listMaid = new List<Maid>();
  714. public string m_strDummyAudioObjectName;
  715. private AudioSource m_audioNew;
  716. public string m_strMasterAudioFileName;
  717. public string m_strPlayTakeName = "Take1";
  718. private AMTake m_takeNow;
  719. private string m_strScriptLabel = string.Empty;
  720. private List<Maid> m_listTempMaid = new List<Maid>();
  721. private Maid m_maidUser;
  722. [HideInInspector]
  723. public bool IsForceDanceEnd;
  724. [HideInInspector]
  725. public bool IsDanceSkip;
  726. private OvrCamera m_OvrCam;
  727. private Transform m_trOvrDummyCam;
  728. public bool UseBinaryData;
  729. public string BinaryFolderName;
  730. private DanceObjectDataBinary maid_data_binary_;
  731. private DanceObjectDataBinary maid_item_binary_;
  732. private DanceObjectDataBinary maid_event_binary_;
  733. private AWReadBinaryData time_line_binary_;
  734. [Header("物理境界を変更するか?")]
  735. public bool UseFloorHitY;
  736. public float m_fFloorY;
  737. [SerializeField]
  738. [Header("被写界深度の焦点")]
  739. private float m_DepthFocalSize = 1.2f;
  740. [SerializeField]
  741. [Header("マイク位置調整等に使うモーションスクリプト名")]
  742. private string m_AdjustScript = string.Empty;
  743. [SerializeField]
  744. private string m_ScriptLabel = string.Empty;
  745. [SerializeField]
  746. [Header("AdjustScript読み込みに要する時間")]
  747. private float m_LoadScriptTime = 3f;
  748. private bool m_bFinished;
  749. private float m_fNowRealTime;
  750. private float m_fTakeStartRealTime;
  751. private float m_fOffsetTime;
  752. private bool m_bAudioFirst = true;
  753. private enum Mode
  754. {
  755. ActiveCam,
  756. LoadChara,
  757. LoadAnim,
  758. Exec,
  759. Finish,
  760. LoadScript
  761. }
  762. }