YotogiOldSkillSelectWaitMotion.cs 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171
  1. using System;
  2. using System.Collections.Generic;
  3. using MaidStatus;
  4. using MaidStatus.Old;
  5. using UnityEngine;
  6. public static class YotogiOldSkillSelectWaitMotion
  7. {
  8. public static void Create()
  9. {
  10. if (YotogiOldSkillSelectWaitMotion.data_dic_ != null)
  11. {
  12. return;
  13. }
  14. YotogiOldSkillSelectWaitMotion.data_dic_ = new Dictionary<int, List<YotogiOldSkillSelectWaitMotion.Data>>();
  15. using (AFileBase afileBase = GameUty.FileSystemOld.FileOpen("yotogi_skil_select_wait_motion.nei"))
  16. {
  17. using (CsvParser csvParser = new CsvParser())
  18. {
  19. bool condition = csvParser.Open(afileBase);
  20. NDebug.Assert(condition, "file open error[yotogi_skil_select_wait_motion.nei]");
  21. for (int i = 1; i < csvParser.max_cell_y; i++)
  22. {
  23. int num = 0;
  24. string cellAsString = csvParser.GetCellAsString(num++, i);
  25. MaidStatus.Personal.Data data = MaidStatus.Personal.GetData(cellAsString);
  26. if (!YotogiOldSkillSelectWaitMotion.data_dic_.ContainsKey(data.id))
  27. {
  28. YotogiOldSkillSelectWaitMotion.data_dic_.Add(data.id, new List<YotogiOldSkillSelectWaitMotion.Data>());
  29. }
  30. List<YotogiOldSkillSelectWaitMotion.Data> list = YotogiOldSkillSelectWaitMotion.data_dic_[data.id];
  31. YotogiOldSkillSelectWaitMotion.Data item = default(YotogiOldSkillSelectWaitMotion.Data);
  32. if (csvParser.IsCellToExistData(num, i))
  33. {
  34. MaidStatus.Old.Relation relation = MaidStatus.Old.Relation.Contact;
  35. try
  36. {
  37. relation = (MaidStatus.Old.Relation)Enum.Parse(typeof(MaidStatus.Old.Relation), csvParser.GetCellAsString(num++, i));
  38. }
  39. catch (Exception e)
  40. {
  41. NDebug.AssertParseError("MaidStatus.Old.Relation", e);
  42. }
  43. num++;
  44. item.relation = relation;
  45. item.condition_sp = Condition.Null;
  46. }
  47. else if (csvParser.IsCellToExistData(++num, i))
  48. {
  49. Condition condition_sp = Condition.Null;
  50. try
  51. {
  52. condition_sp = (Condition)Enum.Parse(typeof(Condition), csvParser.GetCellAsString(num++, i));
  53. }
  54. catch (Exception e2)
  55. {
  56. NDebug.AssertParseError("MaidStatus.Old.Condition", e2);
  57. }
  58. item.relation = MaidStatus.Old.Relation.Contact;
  59. item.condition_sp = condition_sp;
  60. }
  61. else
  62. {
  63. NDebug.Assert("error.", false);
  64. }
  65. item.motion_script_file = csvParser.GetCellAsString(num++, i) + ".ks";
  66. item.motion_script_label = csvParser.GetCellAsString(num++, i);
  67. item.face_blend_name = csvParser.GetCellAsString(num++, i);
  68. item.face_name = csvParser.GetCellAsString(num++, i);
  69. list.Add(item);
  70. }
  71. }
  72. }
  73. }
  74. public static bool ApplyMaidGesture(Maid maid, YotogiOld.Stage stage)
  75. {
  76. if (YotogiOldSkillSelectWaitMotion.wait_count_ == 0)
  77. {
  78. YotogiOldSkillSelectWaitMotion.Create();
  79. YotogiOldSkillSelectWaitMotion.Data data = YotogiOldSkillSelectWaitMotion.GetData(maid);
  80. ScriptManager scriptMgr = GameMain.Instance.ScriptMgr;
  81. scriptMgr.is_motion_blend = false;
  82. bool compatibilityMode = scriptMgr.compatibilityMode;
  83. scriptMgr.compatibilityMode = true;
  84. scriptMgr.LoadMotionScript(0, false, data.motion_script_file, data.motion_script_label, string.Empty, string.Empty, false, true);
  85. scriptMgr.compatibilityMode = compatibilityMode;
  86. scriptMgr.is_motion_blend = true;
  87. maid.FaceAnime(data.face_name, 0f, 0);
  88. maid.FaceBlend("無し");
  89. maid.OpenMouth(false);
  90. }
  91. if (YotogiOldSkillSelectWaitMotion.wait_count_ < 10)
  92. {
  93. YotogiOldSkillSelectWaitMotion.wait_count_++;
  94. return false;
  95. }
  96. maid.body0.SetMaskMode(TBody.MaskMode.None);
  97. maid.EyeToCamera(Maid.EyeMoveType.目と顔を向ける, 0f);
  98. YotogiOldSkillSelectWaitMotion.ApplyEnvSetting(maid, stage);
  99. GameMain.Instance.MainCamera.SetTargetOffset(new Vector3((float)Screen.width / 256f * 154f - (float)Screen.width / 2f, 0f, 0f), false);
  100. YotogiOldSkillSelectWaitMotion.wait_count_ = 0;
  101. return true;
  102. }
  103. public static void ApplyEnvSetting(Maid maid, YotogiOld.Stage stage)
  104. {
  105. YotogiOld.StageData stageData = YotogiOld.stage_data_list[stage];
  106. GameMain.Instance.CharacterMgr.SetCharaAllPos(stageData.camera_data.skill_select_chara_pos);
  107. GameMain.Instance.CharacterMgr.SetCharaAllRot(stageData.camera_data.skill_select_chara_rotate);
  108. CameraMain mainCamera = GameMain.Instance.MainCamera;
  109. Transform bone = maid.body0.GetBone("Bip01 Head");
  110. mainCamera.SetTargetPos(bone.position - new Vector3(0.00503452f, 0.02758344f, -0.0292511f), true);
  111. mainCamera.SetDistance(1.1f, true);
  112. mainCamera.SetAroundAngle(stageData.camera_data.skill_select_camera_rotate, true);
  113. GameMain.Instance.MainLight.SetRotation(stageData.camera_data.skill_select_light_pos);
  114. GameMain.Instance.MainLight.SetIntensity(stageData.camera_data.skill_select_light_intensity);
  115. }
  116. public static YotogiOldSkillSelectWaitMotion.Data GetData(Maid maid)
  117. {
  118. MaidStatus.Old.Status oldStatus = maid.status.OldStatus;
  119. NDebug.Assert(YotogiOldSkillSelectWaitMotion.data_dic_.ContainsKey(oldStatus.mainStatus.personal.id), "error.");
  120. List<YotogiOldSkillSelectWaitMotion.Data> list = YotogiOldSkillSelectWaitMotion.data_dic_[oldStatus.mainStatus.personal.id];
  121. YotogiOldSkillSelectWaitMotion.Data result = default(YotogiOldSkillSelectWaitMotion.Data);
  122. if (oldStatus.condition == Condition.Null)
  123. {
  124. MaidStatus.Old.Relation relation = (oldStatus.relation == MaidStatus.Old.Relation.Null) ? MaidStatus.Old.Relation.Trust : oldStatus.relation;
  125. for (int i = 0; i < list.Count; i++)
  126. {
  127. if (list[i].relation == relation)
  128. {
  129. result = list[i];
  130. break;
  131. }
  132. }
  133. }
  134. else
  135. {
  136. for (int j = 0; j < list.Count; j++)
  137. {
  138. if (list[j].condition_sp == oldStatus.condition)
  139. {
  140. result = list[j];
  141. break;
  142. }
  143. }
  144. }
  145. NDebug.Assert(!string.IsNullOrEmpty(result.motion_script_file), "error.");
  146. return result;
  147. }
  148. private static Dictionary<int, List<YotogiOldSkillSelectWaitMotion.Data>> data_dic_;
  149. private static int wait_count_;
  150. public struct Data
  151. {
  152. public MaidStatus.Old.Relation relation;
  153. public Condition condition_sp;
  154. public string motion_script_file;
  155. public string motion_script_label;
  156. public string face_blend_name;
  157. public string face_name;
  158. }
  159. }