PhotoFaceData.cs 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147
  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. HashSet<string> hashSet = new HashSet<string>();
  44. List<PhotoFaceData> data = PhotoFaceData.data;
  45. for (int j = 0; j < data.Count; j++)
  46. {
  47. if (!PhotoFaceData.category_list_.ContainsKey(data[j].category))
  48. {
  49. PhotoFaceData.category_list_.Add(data[j].category, new List<PhotoFaceData>());
  50. }
  51. PhotoFaceData.category_list_[data[j].category].Add(data[j]);
  52. if (!hashSet.Contains(data[j].category))
  53. {
  54. PhotoFaceData.popup_menu_list_.Add(new KeyValuePair<string, UnityEngine.Object>(data[j].category, null));
  55. hashSet.Add(data[j].category);
  56. }
  57. }
  58. }
  59. public string termName
  60. {
  61. get
  62. {
  63. return "ScenePhotoMode/表情タイプ/" + this.name.TrimEnd(new char[0]);
  64. }
  65. }
  66. public void Apply(Maid maid)
  67. {
  68. if (maid == null || maid.body0 == null || maid.body0.m_Bones == null || maid.IsBusy)
  69. {
  70. return;
  71. }
  72. maid.FaceAnime(this.setting_name, 0f, 0);
  73. }
  74. public float[] BlendArray(Maid maid)
  75. {
  76. if (maid == null || maid.body0 == null || maid.body0.m_Bones == null || maid.IsBusy)
  77. {
  78. return null;
  79. }
  80. return maid.body0.Face.morph.dicBlendSet[this.setting_name];
  81. }
  82. public static List<PhotoFaceData> data
  83. {
  84. get
  85. {
  86. return PhotoFaceData.face_data_;
  87. }
  88. }
  89. public static PhotoFaceData init_data
  90. {
  91. get
  92. {
  93. return PhotoFaceData.init_data_;
  94. }
  95. }
  96. public static Dictionary<string, List<PhotoFaceData>> category_list
  97. {
  98. get
  99. {
  100. return PhotoFaceData.category_list_;
  101. }
  102. }
  103. public static List<KeyValuePair<string, UnityEngine.Object>> popup_category_list
  104. {
  105. get
  106. {
  107. return PhotoFaceData.popup_menu_list_;
  108. }
  109. }
  110. public static PhotoFaceData Get(long id)
  111. {
  112. for (int i = 0; i < PhotoFaceData.face_data_.Count; i++)
  113. {
  114. if ((long)PhotoFaceData.face_data_[i].id == id)
  115. {
  116. return PhotoFaceData.face_data_[i];
  117. }
  118. }
  119. return null;
  120. }
  121. public int id;
  122. public string category;
  123. public string name;
  124. public string setting_name;
  125. private static PhotoFaceData init_data_;
  126. private static List<PhotoFaceData> face_data_;
  127. private static Dictionary<string, List<PhotoFaceData>> category_list_;
  128. private static List<KeyValuePair<string, UnityEngine.Object>> popup_menu_list_;
  129. }