YotogiSkillSelectWaitMotion.cs 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  1. using System;
  2. using System.Collections.Generic;
  3. using MaidStatus;
  4. using UnityEngine;
  5. public static class YotogiSkillSelectWaitMotion
  6. {
  7. public static void Create()
  8. {
  9. if (YotogiSkillSelectWaitMotion.data_dic_ != null)
  10. {
  11. return;
  12. }
  13. YotogiSkillSelectWaitMotion.data_dic_ = new Dictionary<int, List<YotogiSkillSelectWaitMotion.Data>>();
  14. using (AFileBase afileBase = GameUty.FileSystem.FileOpen("yotogi_skill_select_wait_motion.nei"))
  15. {
  16. using (CsvParser csvParser = new CsvParser())
  17. {
  18. bool condition = csvParser.Open(afileBase);
  19. NDebug.Assert(condition, "file open error[yotogi_skill_select_wait_motion.nei]");
  20. for (int i = 1; i < csvParser.max_cell_y; i++)
  21. {
  22. int num = 0;
  23. string cellAsString = csvParser.GetCellAsString(num++, i);
  24. Personal.Data data = Personal.GetData(cellAsString);
  25. if (!YotogiSkillSelectWaitMotion.data_dic_.ContainsKey(data.id))
  26. {
  27. YotogiSkillSelectWaitMotion.data_dic_.Add(data.id, new List<YotogiSkillSelectWaitMotion.Data>());
  28. }
  29. List<YotogiSkillSelectWaitMotion.Data> list = YotogiSkillSelectWaitMotion.data_dic_[data.id];
  30. YotogiSkillSelectWaitMotion.Data item = default(YotogiSkillSelectWaitMotion.Data);
  31. Relation relation = Relation.Contact;
  32. try
  33. {
  34. relation = (Relation)Enum.Parse(typeof(Relation), csvParser.GetCellAsString(num++, i));
  35. }
  36. catch (Exception e)
  37. {
  38. NDebug.AssertParseError("MaidStatus.Relation", e);
  39. }
  40. item.relation = relation;
  41. item.motion_script_file = csvParser.GetCellAsString(num++, i) + ".ks";
  42. item.motion_script_label = csvParser.GetCellAsString(num++, i);
  43. item.face_blend_name = csvParser.GetCellAsString(num++, i);
  44. item.face_name = csvParser.GetCellAsString(num++, i);
  45. list.Add(item);
  46. }
  47. }
  48. }
  49. }
  50. public static bool ApplyMaidGesture(Maid maid, YotogiStage.Data stage_data)
  51. {
  52. if (YotogiSkillSelectWaitMotion.wait_count_ == 0)
  53. {
  54. YotogiSkillSelectWaitMotion.Create();
  55. YotogiSkillSelectWaitMotion.Data data = YotogiSkillSelectWaitMotion.GetData(maid);
  56. ScriptManager scriptMgr = GameMain.Instance.ScriptMgr;
  57. scriptMgr.is_motion_blend = false;
  58. scriptMgr.LoadMotionScript(0, false, data.motion_script_file, data.motion_script_label, string.Empty, string.Empty, false, true);
  59. scriptMgr.is_motion_blend = true;
  60. maid.FaceAnime(data.face_name, 0f, 0);
  61. maid.FaceBlend("無し");
  62. maid.OpenMouth(false);
  63. }
  64. if (YotogiSkillSelectWaitMotion.wait_count_ < 10)
  65. {
  66. YotogiSkillSelectWaitMotion.wait_count_++;
  67. return false;
  68. }
  69. maid.body0.SetMaskMode(TBody.MaskMode.None);
  70. maid.EyeToCamera(Maid.EyeMoveType.目と顔を向ける, 0f);
  71. YotogiSkillSelectWaitMotion.ApplyEnvSetting(maid, stage_data);
  72. GameMain.Instance.MainCamera.SetTargetOffset(new Vector3((float)Screen.width / 256f * 154f - (float)Screen.width / 2f, 0f, 0f), false);
  73. YotogiSkillSelectWaitMotion.wait_count_ = 0;
  74. return true;
  75. }
  76. public static void ApplyEnvSetting(Maid maid, YotogiStage.Data stage_data)
  77. {
  78. stage_data.skillSelectcharacterData.Apply();
  79. stage_data.skillSelectLightData.Apply();
  80. CameraMain mainCamera = GameMain.Instance.MainCamera;
  81. Transform bone = maid.body0.GetBone("Bip01 Head");
  82. mainCamera.SetTargetPos(bone.position - new Vector3(0.00503452f, 0.02758344f, -0.0292511f), true);
  83. mainCamera.SetDistance(1.1f, true);
  84. mainCamera.SetAroundAngle(stage_data.skillSelectcharacterData.cameraAngle, true);
  85. }
  86. public static YotogiSkillSelectWaitMotion.Data GetData(Maid maid)
  87. {
  88. Status status = maid.status;
  89. NDebug.Assert(YotogiSkillSelectWaitMotion.data_dic_.ContainsKey(status.personal.id), "error.");
  90. List<YotogiSkillSelectWaitMotion.Data> list = YotogiSkillSelectWaitMotion.data_dic_[status.personal.id];
  91. YotogiSkillSelectWaitMotion.Data result = default(YotogiSkillSelectWaitMotion.Data);
  92. for (int i = 0; i < list.Count; i++)
  93. {
  94. if (list[i].relation == status.relation)
  95. {
  96. result = list[i];
  97. break;
  98. }
  99. }
  100. NDebug.Assert(!string.IsNullOrEmpty(result.motion_script_file), "error.");
  101. return result;
  102. }
  103. private static Dictionary<int, List<YotogiSkillSelectWaitMotion.Data>> data_dic_;
  104. private static int wait_count_;
  105. public struct Data
  106. {
  107. public Relation relation;
  108. public string motion_script_file;
  109. public string motion_script_label;
  110. public string face_blend_name;
  111. public string face_name;
  112. }
  113. }