MaidParts.cs 4.5 KB

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