1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141 |
- 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<Maid> 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<string, string> 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<string, string> 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<Camera>().enabled = false;
- this.m_OvrCam = GameMain.Instance.OvrMgr.OvrCamera;
- }
- GameObject gameObject = GameObject.Find("RhythmAction_Mgr");
- if (!gameObject)
- {
- gameObject = UnityEngine.Object.Instantiate<GameObject>(Resources.Load<GameObject>("SceneDance/Rhythm_Action/Prefab/RhythmAction_Mgr"));
- }
- if (!RhythmAction_Mgr.Instance)
- {
- gameObject.GetComponent<RhythmAction_Mgr>().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<Maid> list = new List<Maid>();
- 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<GameObject>(), "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<GameObject>()];
- 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<ParticleSystem>(true);
- foreach (ParticleSystem particleSystem in componentsInChildren)
- {
- Renderer component = particleSystem.GetComponent<Renderer>();
- 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<Transform>(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<Animation>();
- 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<Animation>()
- });
- }
- 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<GameObject>(), "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<GameObject>(), "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<Transform>(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<GameObject>(), "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<GameObject>(), "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<GameObject> m_listDebugObj;
- public AnimatorData m_AnimatorData;
- public List<GameObject> m_listDummyAnimChara;
- public List<string> m_listAnimName;
- public List<GameObject> m_listEventObject;
- private Hashtable m_htEventObj = new Hashtable();
- public List<string> m_listTestPreset;
- public List<GameObject> m_listItemObject = new List<GameObject>();
- public List<string> m_listKuchiPakuFile = new List<string>();
- private string[] m_listKuchiPattern;
- private List<Maid> m_listMaid = new List<Maid>();
- 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<Maid> m_listTempMaid = new List<Maid>();
- 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<string, string> m_KuchiPatternCache = new Dictionary<string, string>();
- public float[] m_KuchipakuAudioStartTimeAtMaid;
- private List<DanceMain.AnimTime> m_focePauseAnim = new List<DanceMain.AnimTime>();
- 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<DanceMain.AnimTime.StateTime> stateTimeList = new List<DanceMain.AnimTime.StateTime>();
- public class StateTime
- {
- public AnimationState state;
- public float time;
- }
- }
- }
|