PhotoFaceData.cs 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151
  1. using System;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. public class PhotoFaceData
  5. {
  6. private PhotoFaceData()
  7. {
  8. }
  9. public static void Create()
  10. {
  11. if (PhotoFaceData.face_data_ != null)
  12. {
  13. return;
  14. }
  15. PhotoFaceData.face_data_ = new List<PhotoFaceData>();
  16. using (AFileBase afileBase = GameUty.FileSystem.FileOpen("phot_face_list.nei"))
  17. {
  18. using (CsvParser csvParser = new CsvParser())
  19. {
  20. bool condition = csvParser.Open(afileBase);
  21. NDebug.Assert(condition, "phot_face_list.nei\nopen failed.");
  22. for (int i = 1; i < csvParser.max_cell_y; i++)
  23. {
  24. if (csvParser.IsCellToExistData(0, i))
  25. {
  26. int num = 0;
  27. PhotoFaceData photoFaceData = new PhotoFaceData();
  28. photoFaceData.id = csvParser.GetCellAsInteger(num++, i);
  29. photoFaceData.category = csvParser.GetCellAsString(num++, i);
  30. photoFaceData.name = csvParser.GetCellAsString(num++, i);
  31. photoFaceData.setting_name = csvParser.GetCellAsString(num++, i);
  32. PhotoFaceData.face_data_.Add(photoFaceData);
  33. if (photoFaceData.setting_name == "通常")
  34. {
  35. PhotoFaceData.init_data_ = photoFaceData;
  36. }
  37. }
  38. }
  39. }
  40. }
  41. PhotoFaceData.category_list_ = new Dictionary<string, List<PhotoFaceData>>();
  42. PhotoFaceData.popup_menu_list_ = new List<KeyValuePair<string, UnityEngine.Object>>();
  43. PhotoFaceData.popup_category_term_list = new List<string>();
  44. HashSet<string> hashSet = new HashSet<string>();
  45. List<PhotoFaceData> data = PhotoFaceData.data;
  46. for (int j = 0; j < data.Count; j++)
  47. {
  48. if (!PhotoFaceData.category_list_.ContainsKey(data[j].category))
  49. {
  50. PhotoFaceData.category_list_.Add(data[j].category, new List<PhotoFaceData>());
  51. }
  52. PhotoFaceData.category_list_[data[j].category].Add(data[j]);
  53. if (!hashSet.Contains(data[j].category))
  54. {
  55. PhotoFaceData.popup_menu_list_.Add(new KeyValuePair<string, UnityEngine.Object>(data[j].category, null));
  56. PhotoFaceData.popup_category_term_list.Add("ScenePhotoMode/表情/カテゴリー/" + data[j].category);
  57. hashSet.Add(data[j].category);
  58. }
  59. }
  60. }
  61. public string termName
  62. {
  63. get
  64. {
  65. return "ScenePhotoMode/表情タイプ/" + this.name.TrimEnd(new char[0]);
  66. }
  67. }
  68. public void Apply(Maid maid)
  69. {
  70. if (maid == null || maid.body0 == null || maid.body0.m_Bones == null || maid.IsBusy)
  71. {
  72. return;
  73. }
  74. maid.FaceAnime(this.setting_name, 0f, 0);
  75. }
  76. public float[] BlendArray(Maid maid)
  77. {
  78. if (maid == null || maid.body0 == null || maid.body0.m_Bones == null || maid.IsBusy)
  79. {
  80. return null;
  81. }
  82. return maid.body0.Face.morph.dicBlendSet[this.setting_name];
  83. }
  84. public static List<PhotoFaceData> data
  85. {
  86. get
  87. {
  88. return PhotoFaceData.face_data_;
  89. }
  90. }
  91. public static PhotoFaceData init_data
  92. {
  93. get
  94. {
  95. return PhotoFaceData.init_data_;
  96. }
  97. }
  98. public static Dictionary<string, List<PhotoFaceData>> category_list
  99. {
  100. get
  101. {
  102. return PhotoFaceData.category_list_;
  103. }
  104. }
  105. public static List<string> popup_category_term_list { get; private set; }
  106. public static List<KeyValuePair<string, UnityEngine.Object>> popup_category_list
  107. {
  108. get
  109. {
  110. return PhotoFaceData.popup_menu_list_;
  111. }
  112. }
  113. public static PhotoFaceData Get(long id)
  114. {
  115. for (int i = 0; i < PhotoFaceData.face_data_.Count; i++)
  116. {
  117. if ((long)PhotoFaceData.face_data_[i].id == id)
  118. {
  119. return PhotoFaceData.face_data_[i];
  120. }
  121. }
  122. return null;
  123. }
  124. public int id;
  125. public string category;
  126. public string name;
  127. public string setting_name;
  128. private static PhotoFaceData init_data_;
  129. private static List<PhotoFaceData> face_data_;
  130. private static Dictionary<string, List<PhotoFaceData>> category_list_;
  131. private static List<KeyValuePair<string, UnityEngine.Object>> popup_menu_list_;
  132. }