MaidParts.cs 6.0 KB

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