using System; using System.Collections; using System.Collections.Generic; using System.IO; using System.Linq; using System.Text.RegularExpressions; using UnityEngine; using UnityEngine.Rendering; using UnityEngine.SceneManagement; public class DanceMain : MonoBehaviour { public static string RecetJumpLabel { private get; set; } public List DanceMaid { get { return this.m_listMaid; } } public Maid UserMaid { get { return this.m_maidUser; } } public bool IsDanceEnd { get; private set; } public Transform OvrCamTrans { get { return this.m_trOvrDummyCam; } } public float DepthFocalSize { get { return this.m_DepthFocalSize; } set { this.m_DepthFocalSize = value; if (RhythmAction_Mgr.Instance) { RhythmAction_Mgr.Instance.SetFocalSize(value); } } } public string GetFolderPathToBinaryData() { string binaryFolderName = this.BinaryFolderName; string text = Path.GetFileNameWithoutExtension(this.BinaryFolderName).ToLower(); return "Assets/Resources/SceneDance/" + Path.GetFileNameWithoutExtension(this.BinaryFolderName).ToLower() + "/"; } private void Awake() { this.m_boDebugDummyBody = false; NTime.Reset(); string name = SceneManager.GetActiveScene().name; if (name.ToLower().Contains("_release") && !this.UseBinaryData) { Debug.LogError("ダンスシーン:" + name + " でUseBinaryDataがONになっていません。強制でONにします。"); this.UseBinaryData = true; } Dictionary tag_backup = GameMain.Instance.ScriptMgr.adv_kag.tag_backup; string strScriptLabel; if (tag_backup != null && tag_backup.TryGetValue("label", out strScriptLabel)) { this.m_strScriptLabel = strScriptLabel; } NDebug.Assert(this.m_listDummyAnimChara.Count == this.m_listAnimName.Count, "m_listDummyAnimChara と m_listAnimName の数は同一でないといけません。"); NDebug.Assert(this.m_AnimatorData != null, "AnimatorDataが外れています。"); NDebug.Assert(this.m_listTestPreset.Count == this.m_listAnimName.Count, "プリセット数が不正です。"); NDebug.Assert(!string.IsNullOrEmpty(this.m_strMasterAudioFileName), "マスター用MasterAudioFileNameが必要です。"); bool flag = DanceMain.IsDanceRecet; flag |= (RhythmAction_Mgr.NowState == RhythmAction_Mgr.DanceState.Dance_Second); flag |= (RhythmAction_Mgr.NowDance == RhythmAction_Mgr.DanceType.Encore); flag |= RhythmAction_Mgr.IsVSDance; if (flag && !DanceMain.KaraokeMode) { DanceSelect.SelectMaidActive(DanceMain.SelectDanceData); DanceMain.IsDanceRecet = false; } if (this.time_line_binary_ == null) { this.maid_data_binary_ = new DanceObjectDataBinary(); this.maid_item_binary_ = new DanceObjectDataBinary(); this.maid_event_binary_ = new DanceObjectDataBinary(); this.time_line_binary_ = new AWReadBinaryData(); if (this.UseBinaryData) { string file_name = this.GetFolderPathToBinaryData() + "item_data.bytes"; this.maid_item_binary_.ReadData(file_name); NDebug.Assert(this.m_listItemObject.Count == this.maid_item_binary_.datas.Length, "アイテム数がバイナリデータと不一致"); this.maid_item_binary_.Restoration(false); for (int i = 0; i < this.m_listItemObject.Count; i++) { if (!(this.m_listItemObject[i] != null)) { this.m_listItemObject[i] = this.maid_item_binary_.datas[i].obj; } } file_name = this.GetFolderPathToBinaryData() + "event_data.bytes"; this.maid_event_binary_.ReadData(file_name); NDebug.Assert(this.m_listEventObject.Count == this.maid_event_binary_.datas.Length, "イベント数がバイナリデータと不一致"); this.maid_event_binary_.Restoration(false); for (int j = 0; j < this.m_listEventObject.Count; j++) { if (!(this.m_listEventObject[j] != null)) { this.m_listEventObject[j] = this.maid_event_binary_.datas[j].obj; } } file_name = this.GetFolderPathToBinaryData() + "maid_data.bytes"; this.maid_data_binary_.ReadData(file_name); NDebug.Assert(this.m_listDummyAnimChara.Count == this.maid_data_binary_.datas.Length, "メイド数がバイナリデータと不一致"); this.maid_data_binary_.Restoration(true); for (int k = 0; k < this.m_listDummyAnimChara.Count; k++) { if (!(this.m_listDummyAnimChara[k] != null)) { this.m_listDummyAnimChara[k] = this.maid_data_binary_.datas[k].obj; this.m_listDebugObj.Add(this.m_listDummyAnimChara[k]); } } file_name = this.GetFolderPathToBinaryData() + "timeline_data.bytes"; this.time_line_binary_.ReadFile(file_name); this.maid_item_binary_.AttachObject(this.m_AnimatorData.getTake(this.m_strPlayTakeName)); this.maid_event_binary_.AttachObject(this.m_AnimatorData.getTake(this.m_strPlayTakeName)); } } this.m_listKuchiPattern = new string[this.m_listKuchiPakuFile.Count]; Func func = delegate(string fn) { TextAsset textAsset = Resources.Load("SceneDance/" + fn) as TextAsset; NDebug.Assert(textAsset != null, "口パクパターンテキストファイルが開けません。" + fn); string text3 = textAsset.text; NDebug.Assert(text3.Length != 0, "口パクパターンファイル内が空です。" + fn); return Regex.Replace(text3, "(\\r|\\n| )", string.Empty); }; for (int l = 0; l < this.m_listKuchiPakuFile.Count; l++) { string text = this.m_listKuchiPakuFile[l]; if (!string.IsNullOrEmpty(text)) { this.m_listKuchiPattern[l] = func(text); } } if (this.m_KuchipakuCacheFileName != null) { for (int m2 = 0; m2 < this.m_KuchipakuCacheFileName.Length; m2++) { string text2 = this.m_KuchipakuCacheFileName[m2]; if (!string.IsNullOrEmpty(text2)) { this.m_KuchiPatternCache[text2] = func(text2); } } } this.m_AnimatorData.playOnStart = null; this.m_AnimatorData.bAutoTimeUpdate = false; if (GameMain.Instance.VRMode && GameMain.Instance.CMSystem.GetTmpGenericFlag("ダンスOVRカメラタイプ") == 1) { this.m_trOvrDummyCam = new GameObject("OvrDummyDanceCam").transform; this.m_trOvrDummyCam.gameObject.AddComponent().enabled = false; this.m_OvrCam = GameMain.Instance.OvrMgr.OvrCamera; } GameObject gameObject = GameObject.Find("RhythmAction_Mgr"); if (!gameObject) { gameObject = UnityEngine.Object.Instantiate(Resources.Load("SceneDance/Rhythm_Action/Prefab/RhythmAction_Mgr")); } if (!RhythmAction_Mgr.Instance) { gameObject.GetComponent().InstanceInit(); } for (int n = 0; n < this.m_listTestPreset.Count; n++) { Maid maid = GameMain.Instance.CharacterMgr.GetMaid(n); if (maid) { if (!this.m_maidUser) { this.m_maidUser = DanceSelect.SelectTopMaid; } maid.Visible = true; } } if (!this.m_maidUser) { this.m_maidUser = GameMain.Instance.CharacterMgr.GetMaid(0); } if (DanceMain.KaraokeMode) { return; } GameMain.Instance.CharacterMgr.ResetCharaPosAll(); if (DanceMain.SelectDanceData != null) { for (int num = 0; num < DanceMain.SelectDanceData.select_chara_num; num++) { RhythmAction_Mgr.Instance.FactOrderList.Add(GameMain.Instance.CharacterMgr.GetMaid(num)); } } if (RhythmAction_Mgr.NowDance != RhythmAction_Mgr.DanceType.BenchMark && DanceMain.SelectDanceData != null && DanceMain.SelectDanceData.maid_order.Count > 0) { List list = new List(); for (int num2 = 0; num2 < DanceMain.SelectDanceData.maid_order.Count; num2++) { list.Add(GameMain.Instance.CharacterMgr.GetMaid(num2)); } GameMain.Instance.CharacterMgr.DeactivateCharaAll(); GameMain.Instance.CharacterMgr.DeactivateMaid(0); for (int num3 = 0; num3 < DanceMain.SelectDanceData.maid_order.Count; num3++) { int index = DanceMain.SelectDanceData.maid_order[num3]; if (list[index]) { GameMain.Instance.CharacterMgr.SetActiveMaid(list[index], num3); list[index].Visible = true; } } } if (this.m_listTestPreset.Count <= RhythmAction_Mgr.Instance.FactOrderList.Count) { if (!RhythmAction_Mgr.Instance.FactOrderList.Any((Maid e) => !e) && DanceMain.SelectDanceData != null) { goto IL_97D; } } for (int num4 = 0; num4 < this.m_listTestPreset.Count; num4++) { Maid maid2 = GameMain.Instance.CharacterMgr.GetMaid(num4); if (!maid2) { maid2 = GameMain.Instance.CharacterMgr.AddStockMaid(); GameMain.Instance.CharacterMgr.SetActiveMaid(maid2, num4); CharacterMgr.Preset preset; if (DanceMain.SelectDanceData != null && num4 < DanceMain.SelectDanceData.preset_name.Count && !string.IsNullOrEmpty(DanceMain.SelectDanceData.preset_name[num4])) { preset = GameMain.Instance.CharacterMgr.PresetLoadFromResources(DanceMain.SelectDanceData.preset_name[num4]); } else { preset = GameMain.Instance.CharacterMgr.PresetLoadFromResources(this.m_listTestPreset[num4]); } if (preset != null) { GameMain.Instance.CharacterMgr.PresetSet(maid2, preset); } this.m_listTempMaid.Add(maid2); maid2.Visible = true; } } if (DanceMain.SelectDanceData != null) { for (int num5 = 0; num5 < DanceMain.SelectDanceData.maid_order.Count; num5++) { int index2 = DanceMain.SelectDanceData.maid_order[num5]; if (!RhythmAction_Mgr.Instance.FactOrderList[index2]) { RhythmAction_Mgr.Instance.FactOrderList[index2] = GameMain.Instance.CharacterMgr.GetMaid(num5); } } } IL_97D: if (this.m_PresetCopyToDummyChara != null) { NDebug.Assert(this.m_PresetCopyToDummyChara.Length <= this.m_listDummyAnimChara.Count(), "PresetCopyToDummyChara は listDummyAnimChara の数以下である必要があります。"); for (int num6 = 0; num6 < this.m_PresetCopyToDummyChara.Length; num6++) { int num7 = this.m_PresetCopyToDummyChara[num6]; if (num7 != num6) { Maid maid3 = GameMain.Instance.CharacterMgr.GetMaid(num7); if (maid3) { byte[] buffer = GameMain.Instance.CharacterMgr.PresetSaveNotWriteFile(maid3, CharacterMgr.PresetType.All); BinaryReader binaryReader = new BinaryReader(new MemoryStream(buffer)); CharacterMgr.Preset f_prest = GameMain.Instance.CharacterMgr.PresetLoad(binaryReader, string.Empty); binaryReader.Close(); Maid maidDest = GameMain.Instance.CharacterMgr.GetMaid(num6); if (maidDest != null && this.m_listTempMaid.Find((Maid m) => m == maidDest) != null) { GameMain.Instance.CharacterMgr.PresetSet(maidDest, f_prest); maidDest.AllProcPropSeqStart(); } else { Debug.LogError("Presetコピー先メイドが居ないか、一時雇用メイドではありません。"); } } } } } this.m_KuchipakuAudioStartTimeAtMaid = new float[this.m_listDummyAnimChara.Count()]; for (int num8 = 0; num8 < this.m_KuchipakuAudioStartTimeAtMaid.Length; num8++) { this.m_KuchipakuAudioStartTimeAtMaid[num8] = 0f; } } private void Start() { if (GameMain.Instance.VRMode) { GameObject gameObject = GameObject.Find("effect"); if (gameObject != null) { ParticleSystem[] componentsInChildren = gameObject.GetComponentsInChildren(true); foreach (ParticleSystem particleSystem in componentsInChildren) { Renderer component = particleSystem.GetComponent(); if (component != null) { component.shadowCastingMode = ShadowCastingMode.Off; component.receiveShadows = false; } } } } if (!DanceMain.KaraokeMode) { GameMain.Instance.BgMgr.DeleteBg(); } GameMain.Instance.MainLight.Reset(); GameMain.Instance.SoundMgr.StopBGM(0f); GameMain.Instance.MainCamera.gameObject.SetActive(true); if (!DanceMain.KaraokeMode) { GameMain.Instance.MainCamera.Reset(CameraMain.CameraType.Target, false); } for (int j = 0; j < this.m_listEventObject.Count; j++) { GameObject gameObject2 = this.m_listEventObject[j]; NDebug.Assert(!this.m_htEventObj.ContainsKey(gameObject2.name), "listEventObjectに複数同じObjectを追加しようとしました。" + this.m_listEventObject[j].name); this.m_htEventObj.Add(gameObject2.name, gameObject2); } this.m_takeNow = this.m_AnimatorData.getTake(this.m_strPlayTakeName); NDebug.Assert(this.m_takeNow != null, "再生するテイク名PlayTakeNameが不正です。" + this.m_strPlayTakeName); } public void SetFace(int f_nMaidNo, string f_strFace) { RhythmAction_Mgr.Instance.SetTimeLineFace(f_nMaidNo, f_strFace); Maid maid = GameMain.Instance.CharacterMgr.GetMaid(f_nMaidNo); if (RhythmAction_Mgr.Instance.GetMaidFaceStop(f_nMaidNo)) { return; } maid.FaceAnime(f_strFace, 1f, 0); } public void SetFaceBlend(int f_nMaidNo, string f_strFace) { RhythmAction_Mgr.Instance.SetTimeLineFaceBlend(f_nMaidNo, f_strFace); Maid maid = GameMain.Instance.CharacterMgr.GetMaid(f_nMaidNo); if (RhythmAction_Mgr.Instance.GetMaidFaceBlendStop(f_nMaidNo)) { return; } maid.FaceBlend(f_strFace); } public void SetMaidVisible(int f_nMaidNo, bool visible) { Maid maid = GameMain.Instance.CharacterMgr.GetMaid(f_nMaidNo); maid.transform.localScale = ((!visible) ? Vector3.zero : Vector3.one); } public void SwitchObject(string f_strObjName, bool bEnable) { (this.m_htEventObj[f_strObjName] as GameObject).SetActive(bEnable); } public void EyeToCam(int f_nMaidNo, string f_strType) { Maid maid = GameMain.Instance.CharacterMgr.GetMaid(f_nMaidNo); try { maid.EyeToCamera((Maid.EyeMoveType)Enum.Parse(typeof(Maid.EyeMoveType), f_strType), 0f); } catch (Exception ex) { NDebug.Assert("EyeToCam 目線タイプ " + f_strType + " は不正です。\n" + ex.Message, false); } } public void FadeOut(float f_fTime) { GameMain.Instance.MainCamera.FadeOut(f_fTime, false, null, false, default(Color)); } public void FadeIn(float f_fTime) { GameMain.Instance.MainCamera.FadeIn(f_fTime, false, null, false, true, default(Color)); } public void ChangeAnimation(int maidNo, string animName, float fadeTime) { Maid maid = GameMain.Instance.CharacterMgr.GetMaid(maidNo); try { maid.CrossFade(animName + ".anm", false, false, false, fadeTime, 1f); } catch (Exception ex) { NDebug.Assert(string.Concat(new object[] { "ChangeAnimation メイド ", maidNo, " : ", animName, " は不正です。\n", ex.Message }), false); } } public void ChangeKuchipaku(int maidNo, string kuchipakuName) { Maid maid = GameMain.Instance.CharacterMgr.GetMaid(maidNo); maid.StartKuchipakuPattern((!(this.m_audioNew != null)) ? 0f : (this.m_audioNew.time * -1f), this.m_KuchiPatternCache[kuchipakuName], true); } public void SetActiveObj(GameObject targetObj, bool visible) { targetObj.SetActive(visible); } public void SetEyeTarget(int maidNo, GameObject targetObj) { Maid maid = GameMain.Instance.CharacterMgr.GetMaid(maidNo); maid.EyeToTargetObject(targetObj.transform, 0f); } private void ChangeObj(AMTake f_take, string f_strOldObjName, GameObject f_goNew) { AMTranslationTrack[] array = f_take.findTranslationTrack(f_strOldObjName); for (int i = 0; i < array.Length; i++) { array[i].changeObject(f_goNew.transform); } AMRotationTrack[] array2 = f_take.findRotationTrack(f_strOldObjName); for (int j = 0; j < array2.Length; j++) { array2[j].changeObject(f_goNew.transform); } AMPropertyTrack[] array3 = f_take.findPropertyTrack(f_strOldObjName); for (int k = 0; k < array3.Length; k++) { array3[k].changeObject(f_goNew); } } public void OnDestroy() { this.Uninit(); NUty.GCFree(); Debug.Log("DanceMain::OnDestroy"); } private void Uninit() { if (this.m_bFinished) { return; } if (RhythmAction_Mgr.Instance && DanceMain.KaraokeMode) { RhythmAction_Mgr.Instance.KaraokeEnd(); } Debug.Log("DanceMain::Uninit"); this.m_AnimatorData.StopLoop(); if (GameMain.Instance.MainLight != null) { GameMain.Instance.MainLight.Reset(); } if (GameMain.Instance.MainCamera != null) { GameMain.Instance.MainCamera.Reset(CameraMain.CameraType.Target, true); GameMain.Instance.MainCamera.FadeOut(0f, false, null, true, default(Color)); } if (GameMain.Instance.SoundMgr != null) { GameMain.Instance.SoundMgr.StopBGM(0f); } if (GameMain.Instance.CharacterMgr != null) { GameMain.Instance.CharacterMgr.ResetCharaPosAll(); } for (int i = 0; i < this.m_listMaid.Count; i++) { if (this.m_listMaid[i] != null) { this.m_listMaid[i].transform.localScale = Vector3.one; this.m_listMaid[i].StopKuchipakuPattern(); this.m_listMaid[i].EyeToCamera(Maid.EyeMoveType.目と顔を向ける, 0f); this.m_listMaid[i].AllIKDetach(0f); this.m_listMaid[i].SetAutoTwist(Maid.AutoTwist.WristL, true); this.m_listMaid[i].SetAutoTwist(Maid.AutoTwist.WristR, true); Transform[] componentsInChildren = this.m_listMaid[i].gameObject.GetComponentsInChildren(true); foreach (Transform transform in componentsInChildren) { transform.gameObject.layer = LayerMask.NameToLayer("Charactor"); } } } for (int k = 0; k < this.m_listItemObject.Count; k++) { if (this.m_listItemObject[k] != null) { UnityEngine.Object.DestroyImmediate(this.m_listItemObject[k]); } } this.m_listItemObject.Clear(); for (int l = 0; l < this.m_listTempMaid.Count; l++) { GameMain.Instance.CharacterMgr.BanishmentMaid(this.m_listTempMaid[l]); } if (!DanceMain.KaraokeMode) { if (this.DanceMaid.Any((Maid maid) => maid != null)) { GameMain.Instance.CharacterMgr.DeactivateCharaAll(); } if (this.m_maidUser != null && this.m_maidUser != GameMain.Instance.CharacterMgr.GetMaid(0)) { GameMain.Instance.CharacterMgr.DeactivateMaid(0); GameMain.Instance.CharacterMgr.SetActiveMaid(this.m_maidUser, 0); } } this.m_eMode = DanceMain.Mode.Finish; this.m_bFinished = true; } private void ToFinish() { this.IsDanceEnd = !this.IsForceDanceEnd; RhythmAction_Mgr.Instance.RhythmGame_End(); this.Uninit(); if (!DanceMain.IsDanceRecet) { DanceSelect.SetNextDance(); } else { NDebug.Assert(!string.IsNullOrEmpty(DanceMain.RecetJumpLabel), "やりなおし時に飛ぶラベルが設定されてません"); } Debug.Log("Dance ToFinish Script"); if (!string.IsNullOrEmpty(this.m_strScriptLabel)) { if (DanceMain.IsDanceRecet) { Debug.Log("OnEndScene JumpTo " + DanceMain.RecetJumpLabel); GameMain.Instance.ScriptMgr.adv_kag.JumpLabel(DanceMain.RecetJumpLabel); } else { if (DanceMain.SelectDanceData != null) { GameMain.Instance.ScriptMgr.EvalScript("tf['dance_scene_name'] = '" + DanceMain.SelectDanceData.scene_name + "';"); } Debug.Log("OnEndScene JumpTo " + this.m_strScriptLabel); GameMain.Instance.ScriptMgr.adv_kag.JumpLabel(this.m_strScriptLabel); } GameMain.Instance.ScriptMgr.adv_kag.Exec(); } Debug.Log("Dance Finish!!"); } private IEnumerator LoadMotionScript() { if (this.m_AdjustScript.IndexOf(".ks") < 0) { this.m_AdjustScript += ".ks"; } NDebug.Assert(!string.IsNullOrEmpty(this.m_ScriptLabel), string.Format("{0}の飛び先が未指定です。", this.m_AdjustScript)); if (this.m_ScriptLabel.IndexOf("*") < 0) { this.m_ScriptLabel = "*" + this.m_ScriptLabel; } ScriptManager script_mgr = GameMain.Instance.ScriptMgr; script_mgr.StopMotionScript(); script_mgr.is_motion_blend = true; script_mgr.LoadMotionScript(0, false, this.m_AdjustScript, this.m_ScriptLabel, string.Empty, string.Empty, false, true, false); float timer = 0f; while (timer <= this.m_LoadScriptTime) { timer += Time.deltaTime; yield return null; } script_mgr.StopMotionScript(); this.m_eMode = DanceMain.Mode.LoadAnim; yield break; } private void Update() { if (this.m_eMode == DanceMain.Mode.ActiveCam) { if (GameMain.Instance.MainCamera.gameObject.activeSelf) { GameMain.Instance.MainCamera.FadeOut(0f, false, null, true, default(Color)); GameMain.Instance.MainCamera.SetCameraType(CameraMain.CameraType.Free); GameMain.Instance.MainCamera.SetControl(false); if (this.m_camDummyCamera != null) { if (!GameMain.Instance.VRMode) { AMTranslationTrack amtranslationTrack = this.m_takeNow.findTranslationTrack(this.m_camDummyCamera.gameObject.transform); amtranslationTrack.obj = GameMain.Instance.MainCamera.gameObject.transform; foreach (AMAction amaction in amtranslationTrack.cache) { AMTranslationAction amtranslationAction = (AMTranslationAction)amaction; amtranslationAction.obj = GameMain.Instance.MainCamera.gameObject.transform; } AMRotationTrack amrotationTrack = this.m_takeNow.findRotationTrack(this.m_camDummyCamera.gameObject.transform); amrotationTrack.obj = GameMain.Instance.MainCamera.gameObject.transform; foreach (AMAction amaction2 in amrotationTrack.cache) { AMRotationAction amrotationAction = (AMRotationAction)amaction2; amrotationAction.obj = GameMain.Instance.MainCamera.gameObject.transform; } } else if (GameMain.Instance.CMSystem.GetTmpGenericFlag("ダンスOVRカメラタイプ") != 0) { AMTranslationTrack amtranslationTrack2 = this.m_takeNow.findTranslationTrack(this.m_camDummyCamera.gameObject.transform); amtranslationTrack2.obj = this.m_trOvrDummyCam; foreach (AMAction amaction3 in amtranslationTrack2.cache) { AMTranslationAction amtranslationAction2 = (AMTranslationAction)amaction3; amtranslationAction2.obj = this.m_trOvrDummyCam; } AMRotationTrack amrotationTrack2 = this.m_takeNow.findRotationTrack(this.m_camDummyCamera.gameObject.transform); amrotationTrack2.obj = this.m_trOvrDummyCam; foreach (AMAction amaction4 in amrotationTrack2.cache) { AMRotationAction amrotationAction2 = (AMRotationAction)amaction4; amrotationAction2.obj = this.m_trOvrDummyCam; } } this.m_camDummyCamera.gameObject.SetActive(false); } if (!GameMain.Instance.VRMode) { this.ChangeObj(this.m_takeNow, "CameraMain", GameMain.Instance.MainCamera.gameObject); } else if (GameMain.Instance.CMSystem.GetTmpGenericFlag("ダンスOVRカメラタイプ") == 0) { if (!DanceMain.KaraokeMode) { GameMain.Instance.MainCamera.SetTargetPos(new Vector3(0f, 1.16f, 0f), true); GameMain.Instance.MainCamera.SetAroundAngle(new Vector2(180f, 0f), true); GameMain.Instance.MainCamera.SetDistance(5f, true); } } else { GameObject y = GameObject.Find("__GameMain__/Camera/CameraMain/CameraMain"); AMBinaryDataBaseObject[] binary_data_list = this.time_line_binary_.binary_data_list; if (binary_data_list != null) { for (int i = 0; i < binary_data_list.Length; i++) { if (binary_data_list[i].obj == y) { binary_data_list[i].SetGameObject(this.m_trOvrDummyCam.gameObject); } } } } this.ChangeObj(this.m_takeNow, "MainDirectionalLight", GameMain.Instance.MainLight.gameObject); if (DanceMain.SelectDanceData == null || string.IsNullOrEmpty(DanceMain.SelectDanceData.bgm_file_name)) { GameMain.Instance.SoundMgr.PlayDanceBGM(this.m_strMasterAudioFileName, 0f, true); } else { GameMain.Instance.SoundMgr.PlayDanceBGM(DanceMain.SelectDanceData.bgm_file_name + ".ogg", 0f, true); } AudioSource audioSourceBgm = GameMain.Instance.SoundMgr.GetAudioSourceBgm(); audioSourceBgm.Stop(); AMAudioTrack[] array = this.m_takeNow.findAudioTrack(this.m_strDummyAudioObjectName); foreach (AMAudioTrack amaudioTrack in array) { amaudioTrack.ChangeAudioSource(audioSourceBgm); } this.m_audioNew = audioSourceBgm; if (!this.m_boDebugDummyBody) { for (int k = 0; k < this.m_listAnimName.Count; k++) { this.m_listMaid.Add(GameMain.Instance.CharacterMgr.GetMaid(k)); } for (int l = 0; l < this.m_listMaid.Count; l++) { this.m_listMaid[l].EyeToCamera(Maid.EyeMoveType.目だけ向ける, 0f); } NDebug.Assert(this.m_listKuchiPattern.Length == this.m_listMaid.Count, "メイド数と口パクパターン数が異なります。"); for (int m = 0; m < this.m_listMaid.Count; m++) { if (!string.IsNullOrEmpty(this.m_listKuchiPattern[m])) { this.m_listMaid[m].StartKuchipakuPattern(0f, this.m_listKuchiPattern[m], true); } } } this.m_eMode = DanceMain.Mode.LoadChara; } } else if (this.m_eMode == DanceMain.Mode.LoadChara) { if (!GameMain.Instance.CharacterMgr.IsBusy() || this.m_listMaid.Count == 0) { if (!this.m_boDebugDummyBody) { int num = 1; for (;;) { string arg = "f"; AMAnimationTrack amanimationTrack = this.m_takeNow.findAnimationTrack(arg + num); if (amanimationTrack == null) { break; } int num2 = num - 1; Maid maid = GameMain.Instance.CharacterMgr.GetMaid(num2); IEnumerator enumerator5 = Enum.GetValues(typeof(Maid.AutoTwist)).GetEnumerator(); try { while (enumerator5.MoveNext()) { object obj = enumerator5.Current; maid.SetAutoTwist((Maid.AutoTwist)obj, true); } } finally { IDisposable disposable; if ((disposable = (enumerator5 as IDisposable)) != null) { disposable.Dispose(); } } if (!string.IsNullOrEmpty(this.m_listAnimName[num2])) { string name = maid.CrossFade(this.m_listAnimName[num2] + ".anm", false, false, false, 0f, 1f); Animation component = maid.body0.m_Bones.GetComponent(); component.Stop(); amanimationTrack.obj = maid.body0.m_Bones; foreach (AMAction amaction5 in amanimationTrack.cache) { AMAnimationAction amanimationAction = (AMAnimationAction)amaction5; amanimationAction.amClip = component.GetClip(name); amanimationAction.obj = maid.body0.m_Bones; } } else { this.m_focePauseAnim.Add(new DanceMain.AnimTime { anim = maid.body0.m_Bones.GetComponent() }); } if (this.UseFloorHitY) { maid.body0.SetBoneHitHeightY(this.m_fFloorY); } num++; } for (int n = 0; n < this.m_listDummyAnimChara.Count; n++) { Maid maid2 = GameMain.Instance.CharacterMgr.GetMaid(n); for (int num3 = 0; num3 < this.m_listItemObject.Count; num3++) { Transform transform = CMT.SearchObjObj(this.m_listDummyAnimChara[n].transform, this.m_listItemObject[num3].transform); if (transform != null) { Transform transform2 = transform; string name2 = transform2.parent.name; Transform parent = CMT.SearchObjName(maid2.gameObject.transform, name2, true); transform2.SetParent(parent, false); } } } if (this.m_MoveToDummyCharaPos != null) { NDebug.Assert(this.m_MoveToDummyCharaPos.Length <= this.m_listDummyAnimChara.Count(), "MoveToDummyCharaPos は listDummyAnimChara の数以下である必要があります。"); for (int num4 = 0; num4 < this.m_MoveToDummyCharaPos.Length; num4++) { if (this.m_MoveToDummyCharaPos[num4]) { Vector3 position = this.m_listDummyAnimChara[num4].transform.position; Maid maid3 = GameMain.Instance.CharacterMgr.GetMaid(num4); if (maid3 != null) { maid3.SetPos(position); } } } } if (this.m_LayerChangeToDummyChara != null) { NDebug.Assert(this.m_LayerChangeToDummyChara.Length <= this.m_listDummyAnimChara.Count(), "LayerChangeToDummyChara は listDummyAnimChara の数以下である必要があります。"); for (int num5 = 0; num5 < this.m_LayerChangeToDummyChara.Length; num5++) { if (this.m_LayerChangeToDummyChara[num5]) { int layer = this.m_listDummyAnimChara[num5].layer; Maid maid4 = GameMain.Instance.CharacterMgr.GetMaid(num5); if (maid4 != null) { Transform[] componentsInChildren = maid4.gameObject.GetComponentsInChildren(true); foreach (Transform transform3 in componentsInChildren) { transform3.gameObject.layer = layer; } } } } } if (this.m_EyeTarget != null) { NDebug.Assert(this.m_EyeTarget.Length <= this.m_listDummyAnimChara.Count(), "EyeTarget は listDummyAnimChara の数以下である必要があります。"); for (int num7 = 0; num7 < this.m_EyeTarget.Length; num7++) { if (this.m_EyeTarget[num7] != null) { Maid maid5 = GameMain.Instance.CharacterMgr.GetMaid(num7); if (maid5 != null) { maid5.EyeToCamera(Maid.EyeMoveType.目だけ向ける, 0f); maid5.body0.trsLookTarget = this.m_EyeTarget[num7].transform; } } } } if (this.m_MotionCacheEnable != null) { NDebug.Assert(this.m_MotionCacheEnable.Length <= this.m_listDummyAnimChara.Count(), "MotionCacheEnable は listDummyAnimChara の数以下である必要があります。"); for (int num8 = 0; num8 < this.m_MotionCacheEnable.Length; num8++) { if (this.m_MotionCacheEnable[num8]) { Maid maid6 = GameMain.Instance.CharacterMgr.GetMaid(num8); if (maid6 != null) { for (int num9 = 0; num9 < this.m_MotionCacheFileName.Length; num9++) { maid6.CacheAnime(this.m_MotionCacheFileName[num9], false, false); } } } } } for (int num10 = 0; num10 < this.m_listDebugObj.Count; num10++) { UnityEngine.Object.DestroyImmediate(this.m_listDebugObj[num10]); } this.m_listDebugObj.Clear(); } if (string.IsNullOrEmpty(this.m_AdjustScript)) { this.m_eMode = DanceMain.Mode.LoadAnim; } else { base.StartCoroutine(this.LoadMotionScript()); this.m_eMode = DanceMain.Mode.LoadScript; } } } else if (this.m_eMode == DanceMain.Mode.LoadAnim) { this.m_AnimatorData.Play(this.m_takeNow.name, true, 0f, false, this.time_line_binary_.GetTrackIDList()); this.m_fTakeStartRealTime = Time.realtimeSinceStartup; this.m_fNowRealTime = this.m_fTakeStartRealTime; this.m_eMode = DanceMain.Mode.Exec; } else if (this.m_eMode == DanceMain.Mode.Exec) { bool isPause = RhythmAction_Mgr.Instance.IsPause; if (!isPause) { float num11 = RhythmAction_Mgr.Instance.DanceDeltaTime; if (this.m_audioNew != null && this.m_audioNew.isPlaying) { float time = this.m_audioNew.time; for (int num12 = 0; num12 < this.m_listMaid.Count; num12++) { this.m_listMaid[num12].FoceKuchipakuUpdate(time); } if (this.m_bAudioFirst) { float num13 = time; num11 = Time.realtimeSinceStartup - this.m_fTakeStartRealTime; this.m_bAudioFirst = false; this.m_fOffsetTime = num13 - num11; RhythmAction_Mgr.Instance.RhythmGame_Start(); } } this.m_fNowRealTime += num11; } if (isPause != this.m_pauseBack) { foreach (DanceMain.AnimTime animTime in this.m_focePauseAnim) { if (isPause) { IEnumerator enumerator8 = animTime.anim.GetEnumerator(); try { while (enumerator8.MoveNext()) { object obj2 = enumerator8.Current; AnimationState animationState = (AnimationState)obj2; animTime.stateTimeList.Add(new DanceMain.AnimTime.StateTime { state = animationState, time = animationState.time }); animationState.speed = 0f; } } finally { IDisposable disposable2; if ((disposable2 = (enumerator8 as IDisposable)) != null) { disposable2.Dispose(); } } } else { foreach (DanceMain.AnimTime.StateTime stateTime in animTime.stateTimeList) { stateTime.state.time = stateTime.time; stateTime.state.speed = 1f; } animTime.stateTimeList.Clear(); } } this.m_pauseBack = isPause; } if (this.IsForceDanceEnd || this.m_AnimatorData.takeName == null || this.IsDanceSkip || (DanceMain.KaraokeMode && Input.GetKeyDown(KeyCode.Return))) { this.ToFinish(); } } else if (this.m_eMode == DanceMain.Mode.Finish) { } if (this.m_AnimatorData.takeName != null) { NTime.UpdateNowTime(this.m_fNowRealTime - this.m_fTakeStartRealTime + this.m_fOffsetTime); this.time_line_binary_.Update(NTime.time); } if (GameMain.Instance.VRMode && this.m_trOvrDummyCam != null && this.m_OvrCam != null) { this.m_OvrCam.SetPos(this.m_trOvrDummyCam.position); this.m_OvrCam.SetRotation(this.m_trOvrDummyCam.rotation.eulerAngles); } } private const string m_RhythmMgr_Path = "SceneDance/Rhythm_Action/Prefab/RhythmAction_Mgr"; public static bool IsDanceRecet; public static DanceData SelectDanceData; public static bool KaraokeMode; private DanceMain.Mode m_eMode; public bool m_boDebugDummyBody; public Camera m_camDummyCamera; public List m_listDebugObj; public AnimatorData m_AnimatorData; public List m_listDummyAnimChara; public List m_listAnimName; public List m_listEventObject; private Hashtable m_htEventObj = new Hashtable(); public List m_listTestPreset; public List m_listItemObject = new List(); public List m_listKuchiPakuFile = new List(); private string[] m_listKuchiPattern; private List m_listMaid = new List(); public string m_strDummyAudioObjectName; private AudioSource m_audioNew; public string m_strMasterAudioFileName; public string m_strPlayTakeName = "Take1"; private AMTake m_takeNow; private string m_strScriptLabel = string.Empty; private List m_listTempMaid = new List(); private Maid m_maidUser; [HideInInspector] public bool IsForceDanceEnd; [HideInInspector] public bool IsDanceSkip; private OvrCamera m_OvrCam; private Transform m_trOvrDummyCam; public bool UseBinaryData; public string BinaryFolderName; private DanceObjectDataBinary maid_data_binary_; private DanceObjectDataBinary maid_item_binary_; private DanceObjectDataBinary maid_event_binary_; private AWReadBinaryData time_line_binary_; [Header("物理境界を変更するか?")] public bool UseFloorHitY; public float m_fFloorY; [SerializeField] [Header("被写界深度の焦点")] private float m_DepthFocalSize = 1.2f; [SerializeField] [Header("マイク位置調整等に使うモーションスクリプト名")] private string m_AdjustScript = string.Empty; [SerializeField] private string m_ScriptLabel = string.Empty; [SerializeField] [Header("AdjustScript読み込みに要する時間")] private float m_LoadScriptTime = 3f; [SerializeField] [Header("初期化時にダミーキャラの位置にメイドを移動させるメイド番号スイッチ")] public bool[] m_MoveToDummyCharaPos; [SerializeField] [Header("初期化時にダミーキャラのLayerをメイドに設定させるメイド番号スイッチ")] public bool[] m_LayerChangeToDummyChara; public Light[] m_OffScreenLight; [SerializeField] [Header("初期化時にメイドの視線に設定するオブジェクト対メイド番号")] public GameObject[] m_EyeTarget; [SerializeField] [Header("特定メイド番号からダミーメイドへの容姿のコピー(Elementが元メイド番号/値が先メイド番号")] public int[] m_PresetCopyToDummyChara; [SerializeField] [Header("途中でモーションを変えるメイド番号のファイル名リスト")] public bool[] m_MotionCacheEnable; [SerializeField] [Header("途中でモーションを変える場合のファイル名リスト")] public string[] m_MotionCacheFileName; [SerializeField] [Header("途中で口パクを変える場合のファイル名リスト")] public string[] m_KuchipakuCacheFileName; private Dictionary m_KuchiPatternCache = new Dictionary(); public float[] m_KuchipakuAudioStartTimeAtMaid; private List m_focePauseAnim = new List(); private bool m_pauseBack; private bool m_bFinished; private float m_fNowRealTime; private float m_fTakeStartRealTime; private float m_fOffsetTime; private bool m_bAudioFirst = true; private enum Mode { ActiveCam, LoadChara, LoadAnim, Exec, Finish, LoadScript } private class AnimTime { public Animation anim; public List stateTimeList = new List(); public class StateTime { public AnimationState state; public float time; } } }