123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179 |
- 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 textAsset2 = Resources.Load("SceneDance/" + fn) as TextAsset;
- NDebug.Assert(textAsset2 != null, "口パクパターンテキストファイルが開けません。" + fn);
- string text4 = textAsset2.text;
- NDebug.Assert(text4.Length != 0, "口パクパターンファイル内が空です。" + fn);
- return Regex.Replace(text4, "(\\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 && (!RhythmAction_Mgr.IsVSDance || !VsDanceDataMgr.Instance.CurrentSetting.isFixedMaidOrder))
- {
- 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_AF3;
- }
- }
- for (int num4 = 0; num4 < this.m_listTestPreset.Count; num4++)
- {
- Maid maid2 = GameMain.Instance.CharacterMgr.GetMaid(num4);
- if (!maid2 || DanceMain.SelectDanceData == null)
- {
- if (!maid2)
- {
- maid2 = GameMain.Instance.CharacterMgr.AddStockMaid();
- GameMain.Instance.CharacterMgr.SetActiveMaid(maid2, num4);
- this.m_listTempMaid.Add(maid2);
- }
- CharacterMgr.Preset preset = null;
- bool flag2 = DanceMain.SelectDanceData != null && num4 < DanceMain.SelectDanceData.preset_name.Count && !string.IsNullOrEmpty(DanceMain.SelectDanceData.preset_name[num4]);
- string text3 = (!flag2) ? this.m_listTestPreset[num4] : DanceMain.SelectDanceData.preset_name[num4];
- byte[] buffer = null;
- TextAsset textAsset = Resources.Load("Preset/" + text3) as TextAsset;
- if (textAsset == null)
- {
- using (AFileBase afileBase = GameUty.FileSystem.FileOpen(text3 + ".preset"))
- {
- if (afileBase.IsValid())
- {
- buffer = afileBase.ReadAll();
- }
- else
- {
- NDebug.Assert(string.Format("{0}はResourcesにもGameDataにもありませんでした。", text3), false);
- }
- }
- }
- else
- {
- buffer = textAsset.bytes;
- }
- using (MemoryStream memoryStream = new MemoryStream(buffer))
- {
- using (BinaryReader binaryReader = new BinaryReader(memoryStream))
- {
- preset = GameMain.Instance.CharacterMgr.PresetLoad(binaryReader, text3);
- }
- }
- if (preset != null)
- {
- GameMain.Instance.CharacterMgr.PresetSet(maid2, preset);
- }
- maid2.Visible = true;
- }
- }
- if (DanceMain.SelectDanceData != null)
- {
- if (DanceMain.SelectDanceData.maid_order.Count > 0)
- {
- 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);
- }
- }
- }
- else
- {
- for (int num6 = 0; num6 < RhythmAction_Mgr.Instance.FactOrderList.Count; num6++)
- {
- if (!RhythmAction_Mgr.Instance.FactOrderList[num6])
- {
- RhythmAction_Mgr.Instance.FactOrderList[num6] = GameMain.Instance.CharacterMgr.GetMaid(num6);
- }
- }
- }
- }
- IL_AF3:
- if (this.m_PresetCopyToDummyChara != null)
- {
- NDebug.Assert(this.m_PresetCopyToDummyChara.Length <= this.m_listDummyAnimChara.Count<GameObject>(), "PresetCopyToDummyChara は listDummyAnimChara の数以下である必要があります。");
- for (int num7 = 0; num7 < this.m_PresetCopyToDummyChara.Length; num7++)
- {
- int num8 = this.m_PresetCopyToDummyChara[num7];
- if (num8 != num7)
- {
- Maid maid3 = GameMain.Instance.CharacterMgr.GetMaid(num8);
- if (maid3)
- {
- byte[] buffer2 = GameMain.Instance.CharacterMgr.PresetSaveNotWriteFile(maid3, CharacterMgr.PresetType.All);
- BinaryReader binaryReader2 = new BinaryReader(new MemoryStream(buffer2));
- CharacterMgr.Preset f_prest = GameMain.Instance.CharacterMgr.PresetLoad(binaryReader2, string.Empty);
- binaryReader2.Close();
- Maid maidDest = GameMain.Instance.CharacterMgr.GetMaid(num7);
- 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 num9 = 0; num9 < this.m_KuchipakuAudioStartTimeAtMaid.Length; num9++)
- {
- this.m_KuchipakuAudioStartTimeAtMaid[num9] = 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].body0.IKCtrl.SetPelvisPull(false);
- 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;
- }
- }
- }
|