MaidParts.cs 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283
  1. using System;
  2. using System.IO;
  3. using UnityEngine;
  4. public class MaidParts : MonoBehaviour
  5. {
  6. public bool Initialize(GameObject f_objMaid, Maid f_Maid)
  7. {
  8. this.m_objMaid = f_objMaid;
  9. this.m_Maid = f_Maid;
  10. for (int i = 0; i < 13; i++)
  11. {
  12. this.m_aryPartsColor[i] = MaidParts.m_aryPartsColorDefault[i];
  13. this.m_aryPartsColorTable[i] = new Texture2D(256, 1, TextureFormat.RGBA32, false);
  14. this.m_aryPartsColorTable[i].wrapMode = TextureWrapMode.Clamp;
  15. }
  16. return true;
  17. }
  18. public void SetPartsColor(MaidParts.PARTS_COLOR f_eColorType, MaidParts.PartsColor f_cColor)
  19. {
  20. this.m_aryPartsColor[(int)f_eColorType] = f_cColor;
  21. UTY.UpdateColorTableTexture(f_cColor, ref this.m_aryPartsColorTable[(int)f_eColorType]);
  22. this.m_Maid.body0.UpdateInfinityColor(f_eColorType);
  23. }
  24. public MaidParts.PartsColor GetPartsColor(MaidParts.PARTS_COLOR f_eColorType)
  25. {
  26. return this.m_aryPartsColor[(int)f_eColorType];
  27. }
  28. public Texture2D GetPartsColorTableTex(MaidParts.PARTS_COLOR f_eColorType)
  29. {
  30. return this.m_aryPartsColorTable[(int)f_eColorType];
  31. }
  32. public unsafe bool Serialize(BinaryWriter f_bwWrite)
  33. {
  34. f_bwWrite.Write("CM3D2_MULTI_COL");
  35. f_bwWrite.Write(1570);
  36. f_bwWrite.Write(this.m_aryPartsColor.Length);
  37. for (int i = 0; i < this.m_aryPartsColor.Length; i++)
  38. {
  39. MaidParts.PARTS_COLOR parts_COLOR = (MaidParts.PARTS_COLOR)i;
  40. f_bwWrite.Write(parts_COLOR.ToString());
  41. fixed (MaidParts.PartsColor* ptr = &this.m_aryPartsColor[i])
  42. {
  43. f_bwWrite.Write(ptr->m_bUse);
  44. f_bwWrite.Write(ptr->m_nMainHue);
  45. f_bwWrite.Write(ptr->m_nMainChroma);
  46. f_bwWrite.Write(ptr->m_nMainBrightness);
  47. f_bwWrite.Write(ptr->m_nMainContrast);
  48. f_bwWrite.Write(ptr->m_nShadowRate);
  49. f_bwWrite.Write(ptr->m_nShadowHue);
  50. f_bwWrite.Write(ptr->m_nShadowChroma);
  51. f_bwWrite.Write(ptr->m_nShadowBrightness);
  52. f_bwWrite.Write(ptr->m_nShadowContrast);
  53. }
  54. }
  55. f_bwWrite.Write(MaidParts.PARTS_COLOR.MAX.ToString());
  56. return true;
  57. }
  58. public unsafe static MaidParts.PartsColor[] DeserializePre(BinaryReader f_brRead)
  59. {
  60. MaidParts.PartsColor[] array = new MaidParts.PartsColor[13];
  61. for (int i = 0; i < 13; i++)
  62. {
  63. array[i] = MaidParts.m_aryPartsColorDefault[i];
  64. }
  65. string a = f_brRead.ReadString();
  66. NDebug.Assert(a == "CM3D2_MULTI_COL", "無限色のヘッダーが不正です。");
  67. int num = f_brRead.ReadInt32();
  68. int num2 = f_brRead.ReadInt32();
  69. if (num <= 1200 && ((200 > num) ? (7 != num2) : (9 != num2)))
  70. {
  71. NDebug.Assert("無限色数が異なります。セーブデータが破損しています。", false);
  72. }
  73. if (num <= 1200)
  74. {
  75. string[] array2 = new string[]
  76. {
  77. "EYE_L",
  78. "EYE_R",
  79. "HAIR",
  80. "EYE_BROW",
  81. "UNDER_HAIR",
  82. "SKIN",
  83. "NIPPLE",
  84. "HAIR_OUTLINE",
  85. "SKIN_OUTLINE"
  86. };
  87. for (int j = 0; j < num2; j++)
  88. {
  89. MaidParts.PartsColor partsColor = default(MaidParts.PartsColor);
  90. partsColor.m_bUse = f_brRead.ReadBoolean();
  91. partsColor.m_nMainHue = f_brRead.ReadInt32();
  92. partsColor.m_nMainChroma = f_brRead.ReadInt32();
  93. partsColor.m_nMainBrightness = f_brRead.ReadInt32();
  94. partsColor.m_nMainContrast = f_brRead.ReadInt32();
  95. partsColor.m_nShadowRate = f_brRead.ReadInt32();
  96. partsColor.m_nShadowHue = f_brRead.ReadInt32();
  97. partsColor.m_nShadowChroma = f_brRead.ReadInt32();
  98. partsColor.m_nShadowBrightness = f_brRead.ReadInt32();
  99. partsColor.m_nShadowContrast = f_brRead.ReadInt32();
  100. MaidParts.PARTS_COLOR parts_COLOR = (MaidParts.PARTS_COLOR)Enum.Parse(typeof(MaidParts.PARTS_COLOR), array2[j], true);
  101. array[(int)parts_COLOR] = partsColor;
  102. }
  103. }
  104. else
  105. {
  106. string value;
  107. while ((value = f_brRead.ReadString()) != MaidParts.PARTS_COLOR.MAX.ToString())
  108. {
  109. MaidParts.PARTS_COLOR parts_COLOR2 = (MaidParts.PARTS_COLOR)Enum.Parse(typeof(MaidParts.PARTS_COLOR), value, true);
  110. fixed (MaidParts.PartsColor* ptr = &array[(int)parts_COLOR2])
  111. {
  112. ptr->m_bUse = f_brRead.ReadBoolean();
  113. ptr->m_nMainHue = f_brRead.ReadInt32();
  114. ptr->m_nMainChroma = f_brRead.ReadInt32();
  115. ptr->m_nMainBrightness = f_brRead.ReadInt32();
  116. ptr->m_nMainContrast = f_brRead.ReadInt32();
  117. ptr->m_nShadowRate = f_brRead.ReadInt32();
  118. ptr->m_nShadowHue = f_brRead.ReadInt32();
  119. ptr->m_nShadowChroma = f_brRead.ReadInt32();
  120. ptr->m_nShadowBrightness = f_brRead.ReadInt32();
  121. ptr->m_nShadowContrast = f_brRead.ReadInt32();
  122. }
  123. }
  124. }
  125. return array;
  126. }
  127. private static readonly MaidParts.PartsColor[] m_aryPartsColorDefault = new MaidParts.PartsColor[]
  128. {
  129. new MaidParts.PartsColor
  130. {
  131. m_nMainHue = 6,
  132. m_nMainChroma = 117,
  133. m_nMainBrightness = 179,
  134. m_nMainContrast = 94
  135. },
  136. new MaidParts.PartsColor
  137. {
  138. m_nMainHue = 6,
  139. m_nMainChroma = 117,
  140. m_nMainBrightness = 179,
  141. m_nMainContrast = 94
  142. },
  143. new MaidParts.PartsColor
  144. {
  145. m_nMainHue = 69,
  146. m_nMainChroma = 186,
  147. m_nMainBrightness = 270,
  148. m_nMainContrast = 94
  149. },
  150. new MaidParts.PartsColor
  151. {
  152. m_nMainHue = 0,
  153. m_nMainChroma = 0,
  154. m_nMainBrightness = 183,
  155. m_nMainContrast = 0
  156. },
  157. new MaidParts.PartsColor
  158. {
  159. m_nMainHue = 0,
  160. m_nMainChroma = 0,
  161. m_nMainBrightness = 0,
  162. m_nMainContrast = 0
  163. },
  164. new MaidParts.PartsColor
  165. {
  166. m_nMainHue = 18,
  167. m_nMainChroma = 149,
  168. m_nMainBrightness = 247,
  169. m_nMainContrast = 100
  170. },
  171. new MaidParts.PartsColor
  172. {
  173. m_nMainHue = 18,
  174. m_nMainChroma = 149,
  175. m_nMainBrightness = 247,
  176. m_nMainContrast = 100
  177. },
  178. new MaidParts.PartsColor
  179. {
  180. m_nMainHue = 69,
  181. m_nMainChroma = 0,
  182. m_nMainBrightness = 67,
  183. m_nMainContrast = 100
  184. },
  185. new MaidParts.PartsColor
  186. {
  187. m_nMainHue = 18,
  188. m_nMainChroma = 100,
  189. m_nMainBrightness = 138,
  190. m_nMainContrast = 85
  191. },
  192. new MaidParts.PartsColor
  193. {
  194. m_nMainHue = 18,
  195. m_nMainChroma = 36,
  196. m_nMainBrightness = 434,
  197. m_nMainContrast = 100,
  198. m_nShadowRate = 255,
  199. m_nShadowHue = 18,
  200. m_nShadowChroma = 79,
  201. m_nShadowBrightness = 321,
  202. m_nShadowContrast = 0
  203. },
  204. new MaidParts.PartsColor
  205. {
  206. m_nMainHue = 0,
  207. m_nMainChroma = 56,
  208. m_nMainBrightness = 185,
  209. m_nMainContrast = 47
  210. },
  211. new MaidParts.PartsColor
  212. {
  213. m_nMainHue = 0,
  214. m_nMainChroma = 56,
  215. m_nMainBrightness = 185,
  216. m_nMainContrast = 47
  217. },
  218. new MaidParts.PartsColor
  219. {
  220. m_nMainHue = 18,
  221. m_nMainChroma = 60,
  222. m_nMainBrightness = 200,
  223. m_nMainContrast = 128
  224. }
  225. };
  226. private MaidParts.PartsColor[] m_aryPartsColor = new MaidParts.PartsColor[13];
  227. private Texture2D[] m_aryPartsColorTable = new Texture2D[13];
  228. private GameObject m_objMaid;
  229. private Maid m_Maid;
  230. public enum PARTS_COLOR
  231. {
  232. NONE = -1,
  233. EYE_L,
  234. EYE_R,
  235. HAIR,
  236. EYE_BROW,
  237. UNDER_HAIR,
  238. SKIN,
  239. NIPPLE,
  240. HAIR_OUTLINE,
  241. SKIN_OUTLINE,
  242. EYE_WHITE,
  243. MATSUGE_UP,
  244. MATSUGE_LOW,
  245. FUTAE,
  246. MAX
  247. }
  248. public struct PartsColor
  249. {
  250. public bool m_bUse;
  251. public int m_nMainHue;
  252. public int m_nMainChroma;
  253. public int m_nMainBrightness;
  254. public int m_nMainContrast;
  255. public int m_nShadowRate;
  256. public int m_nShadowHue;
  257. public int m_nShadowChroma;
  258. public int m_nShadowBrightness;
  259. public int m_nShadowContrast;
  260. }
  261. }