CharacterDataSetting.cs 50 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. using System;
  5. using System.Text;
  6. #if UNITY_EDITOR
  7. using UnityEditor;
  8. #endif
  9. namespace SoftKitty.MasterCharacterCreator
  10. {
  11. #region Enum
  12. public enum WeaponType
  13. {
  14. TwoHanded,
  15. LeftHand,
  16. RightHand,
  17. Custom1,
  18. Custom2,
  19. Custom3,
  20. Custom4,
  21. Custom5,
  22. Custom6,
  23. }
  24. public enum WeaponState
  25. {
  26. Carry,
  27. Hold,
  28. Hide
  29. }
  30. public enum SaveMethod
  31. {
  32. BytesFile,
  33. PngFile
  34. }
  35. public enum BlurPrintType
  36. {
  37. BodyShape,
  38. Character,
  39. Outfits,
  40. AllAppearance
  41. }
  42. public enum Sex
  43. {
  44. Male,
  45. Female
  46. }
  47. public enum OutfitSlots
  48. {
  49. Armor,
  50. Helmet,
  51. Gauntlet,
  52. Boot,
  53. Pants,
  54. Back,
  55. Tail
  56. }
  57. #endregion
  58. #region EquipmentAppearance Class
  59. [System.Serializable]
  60. public class EquipmentAppearance
  61. {
  62. public OutfitSlots Type;
  63. public int MaleMeshId;
  64. public int FemaleMeshId;
  65. public bool UseCustomColor = false;
  66. public Color CustomColor1;
  67. public Color CustomColor2;
  68. public Color CustomColor3;
  69. [HideInInspector]
  70. public bool uiFold = false;
  71. public EquipmentAppearance() { }
  72. public EquipmentAppearance(OutfitSlots _type,int _maleMeshId, int _femaleMeshId,bool _useCustomColor=false,Color _color1= default(Color), Color _color2 = default(Color), Color _color3 = default(Color))
  73. {
  74. Type = _type;
  75. MaleMeshId = _maleMeshId;
  76. FemaleMeshId = _femaleMeshId;
  77. UseCustomColor = _useCustomColor;
  78. CustomColor1 = _color1;
  79. CustomColor2 = _color2;
  80. CustomColor3 = _color3;
  81. uiFold = false;
  82. }
  83. public int GetId(Sex _sex)
  84. {
  85. return _sex == Sex.Male ? MaleMeshId : FemaleMeshId;
  86. }
  87. }
  88. #endregion
  89. #region Character Class
  90. [System.Serializable]
  91. public class CharacterAppearance
  92. {
  93. public string _Name = "unnamed";
  94. public CharacterData _CharacterData;
  95. public byte[] _OutfitID;
  96. public Uint8Color[] _CusColor1;
  97. public Uint8Color[] _CusColor2;
  98. public Uint8Color[] _CusColor3;
  99. public enum DataVersions
  100. {
  101. Before_v1_3,
  102. Before_v1_5,
  103. Lastest
  104. }
  105. public Sex _Sex
  106. {
  107. get
  108. {
  109. return (Sex)_CharacterData.Sex;
  110. }
  111. }
  112. public int _Race
  113. {
  114. get
  115. {
  116. return (int)_CharacterData.Race;
  117. }
  118. }
  119. public bool isSameAs(CharacterAppearance _target)
  120. {
  121. for (int i = 0; i < _OutfitID.Length; i++)
  122. {
  123. if (_OutfitID[i] != _target._OutfitID[i]) return false;
  124. }
  125. for (int i = 0; i < _CusColor1.Length; i++)
  126. {
  127. if (_CusColor1[i] != _target._CusColor1[i]) return false;
  128. }
  129. for (int i = 0; i < _CusColor2.Length; i++)
  130. {
  131. if (_CusColor2[i] != _target._CusColor2[i]) return false;
  132. }
  133. for (int i = 0; i < _CusColor3.Length; i++)
  134. {
  135. if (_CusColor3[i] != _target._CusColor3[i]) return false;
  136. }
  137. if(_target._CharacterData.Sex != _CharacterData.Sex) return false;
  138. if (_target._CharacterData.Race != _CharacterData.Race) return false;
  139. for (int i = 0; i < _CharacterData.DataFloat.Length; i++)
  140. {
  141. if (_target._CharacterData.DataFloat[i] != _CharacterData.DataFloat[i]) return false;
  142. }
  143. for (int i = 0; i < _CharacterData.DataColor.Length; i++)
  144. {
  145. if (_target._CharacterData.DataColor[i] != _CharacterData.DataColor[i]) return false;
  146. }
  147. for (int i = 0; i < _CharacterData.DataInt.Length; i++)
  148. {
  149. if (_target._CharacterData.DataInt[i] != _CharacterData.DataInt[i]) return false;
  150. }
  151. return true;
  152. }
  153. public CharacterAppearance Copy()
  154. {
  155. CharacterAppearance _copy = new CharacterAppearance();
  156. _copy._CharacterData= _CharacterData.Copy();
  157. _copy._Name = _Name;
  158. _copy._OutfitID = new byte[_OutfitID.Length];
  159. _copy._CusColor1 = new Uint8Color[_CusColor1.Length];
  160. _copy._CusColor2 = new Uint8Color[_CusColor2.Length];
  161. _copy._CusColor3 = new Uint8Color[_CusColor3.Length];
  162. for (int i = 0; i < _OutfitID.Length; i++)
  163. {
  164. _copy._OutfitID[i] = _OutfitID[i];
  165. }
  166. for (int i = 0; i < _CusColor1.Length; i++)
  167. {
  168. _copy._CusColor1[i] = new Uint8Color(_CusColor1[i].r, _CusColor1[i].g, _CusColor1[i].b, _CusColor1[i].a);
  169. }
  170. for (int i = 0; i < _CusColor2.Length; i++)
  171. {
  172. _copy._CusColor2[i] = new Uint8Color(_CusColor2[i].r, _CusColor2[i].g, _CusColor2[i].b, _CusColor2[i].a);
  173. }
  174. for (int i = 0; i < _CusColor3.Length; i++)
  175. {
  176. _copy._CusColor3[i] = new Uint8Color(_CusColor3[i].r, _CusColor3[i].g, _CusColor3[i].b, _CusColor3[i].a);
  177. }
  178. return _copy;
  179. }
  180. public void DefaultValue()
  181. {
  182. _Name = "unnamed";
  183. int _outfitSlotsCount = System.Enum.GetValues(typeof(OutfitSlots)).Length;
  184. _OutfitID = new byte[_outfitSlotsCount];
  185. for (int i = 0; i < _outfitSlotsCount; i++)
  186. {
  187. _OutfitID[i] = 0;
  188. }
  189. _CusColor1 = new Uint8Color[_outfitSlotsCount];
  190. _CusColor2 = new Uint8Color[_outfitSlotsCount];
  191. _CusColor3 = new Uint8Color[_outfitSlotsCount];
  192. for (int i = 0; i < _outfitSlotsCount; i++)
  193. {
  194. _CusColor1[i] = Uint8Color.Set(Color.gray);
  195. _CusColor2[i] = Uint8Color.Set(Color.gray);
  196. _CusColor3[i] = Uint8Color.Set(Color.gray);
  197. }
  198. }
  199. public CharacterAppearance() { }
  200. public CharacterAppearance(CharacterData _cData)
  201. {
  202. _CharacterData = _cData;
  203. DefaultValue();
  204. }
  205. public void Load(byte[] _bytes, DataVersions _dataVersion= DataVersions.Lastest)
  206. {
  207. int _outfitSlotsCount = Enum.GetValues(typeof(OutfitSlots)).Length;
  208. if (_dataVersion == DataVersions.Before_v1_5)
  209. {
  210. _outfitSlotsCount = 5; //Before v1.5 there were only 5 outfit slots
  211. }
  212. else if (_dataVersion == DataVersions.Before_v1_3)
  213. {
  214. _outfitSlotsCount = 4; //Before v1.3 there were only 4 outfit slots
  215. }
  216. int _index = 0;
  217. BlurPrintType _bluePrintType = (BlurPrintType)_bytes[_index];
  218. _index++;
  219. _CharacterData.Sex = _bytes[_index];
  220. _index++;
  221. if (_dataVersion == DataVersions.Lastest)//Before v1,5 there is no race setting.
  222. {
  223. if (_bluePrintType != BlurPrintType.BodyShape && _bluePrintType != BlurPrintType.Outfits) _CharacterData.Race = _bytes[_index];
  224. _index++;
  225. }
  226. if (_bluePrintType != BlurPrintType.Outfits)
  227. {
  228. if (_bluePrintType == BlurPrintType.BodyShape)
  229. {
  230. byte[] _bodyBytes = new byte[120];
  231. Array.Copy(_bytes, _index, _bodyBytes, 0, 120);
  232. for (int i=0;i<120;i++) {
  233. if (i == 1 || (i >= 81 && i <= 119)) _CharacterData.DataFloat[i] = _bodyBytes[i];
  234. }
  235. _index += 120;
  236. }
  237. else
  238. {
  239. Array.Copy(_bytes, _index, _CharacterData.DataFloat, 0, 120);
  240. _index += 120;
  241. }
  242. if (_bluePrintType != BlurPrintType.BodyShape)
  243. {
  244. for (int i = 0; i < 15; i++)
  245. {
  246. byte[] _color = new byte[4];
  247. Array.Copy(_bytes, _index, _color, 0, 4);
  248. _CharacterData.DataColor[i] = new Uint8Color(_color);
  249. _index += 4;
  250. }
  251. Array.Copy(_bytes, _index, _CharacterData.DataInt, 0, 10);
  252. _index += 10;
  253. }
  254. }
  255. if (_bluePrintType == BlurPrintType.Outfits || _bluePrintType == BlurPrintType.AllAppearance)
  256. {
  257. byte _tail = _OutfitID[6];
  258. Uint8Color _tailColor1 = _CusColor1[6].Copy();
  259. Uint8Color _tailColor2 = _CusColor1[6].Copy();
  260. Uint8Color _tailColor3 = _CusColor1[6].Copy();
  261. byte _back = _OutfitID[5];
  262. Uint8Color _backColor1 = _CusColor1[5].Copy();
  263. Uint8Color _backColor2 = _CusColor1[5].Copy();
  264. Uint8Color _backColor3 = _CusColor1[5].Copy();
  265. Array.Copy(_bytes, _index, _OutfitID, 0, _outfitSlotsCount);
  266. _index += _outfitSlotsCount;
  267. for (int i = 0; i < _outfitSlotsCount; i++)
  268. {
  269. byte[] _color1 = new byte[4];
  270. Array.Copy(_bytes, _index, _color1, 0, 4);
  271. _CusColor1[i] = new Uint8Color(_color1);
  272. _index += 4;
  273. byte[] _color2 = new byte[4];
  274. Array.Copy(_bytes, _index, _color2, 0, 4);
  275. _CusColor2[i] = new Uint8Color(_color2);
  276. _index += 4;
  277. byte[] _color3 = new byte[4];
  278. Array.Copy(_bytes, _index, _color3, 0, 4);
  279. _CusColor3[i] = new Uint8Color(_color3);
  280. _index += 4;
  281. }
  282. if (_bluePrintType == BlurPrintType.Outfits) {
  283. if (CharacterDataSetting.instance.RaceSettings[_CharacterData.Race].DefaultBackAccessory != 0)
  284. {
  285. _OutfitID[5] = _back;
  286. _CusColor1[5] = _backColor1;
  287. _CusColor2[5] = _backColor2;
  288. _CusColor3[5] = _backColor3;
  289. }
  290. if (CharacterDataSetting.instance.RaceSettings[_CharacterData.Race].DefaultTail != 0)
  291. {
  292. _OutfitID[6] = _tail;
  293. _CusColor1[6] = _tailColor1;
  294. _CusColor2[6] = _tailColor2;
  295. _CusColor3[6] = _tailColor3;
  296. }
  297. }
  298. if (_dataVersion == DataVersions.Before_v1_3)//We need to add settings of pants and cape for data from older version before v1.3
  299. {
  300. _OutfitID[4] = _OutfitID[0];
  301. _CusColor1[4] = _CusColor1[0].Copy();
  302. _CusColor2[4] = _CusColor2[0].Copy();
  303. _CusColor3[4] = _CusColor3[0].Copy();
  304. _OutfitID[5] = 0;
  305. _CusColor1[5] = Uint8Color.Set(Color.white);
  306. _CusColor2[5] = Uint8Color.Set(Color.white);
  307. _CusColor3[5] = Uint8Color.Set(Color.white);
  308. _OutfitID[6] = 0;
  309. _CusColor1[6] = Uint8Color.Set(Color.white);
  310. _CusColor2[6] = Uint8Color.Set(Color.white);
  311. _CusColor3[6] = Uint8Color.Set(Color.white);
  312. }
  313. if (_dataVersion == DataVersions.Before_v1_5)//We need to add settings of cape for data from older version before v1.3
  314. {
  315. _OutfitID[5] = 0;
  316. _CusColor1[5] = Uint8Color.Set(Color.white);
  317. _CusColor2[5] = Uint8Color.Set(Color.white);
  318. _CusColor3[5] = Uint8Color.Set(Color.white);
  319. _OutfitID[6] = 0;
  320. _CusColor1[6] = Uint8Color.Set(Color.white);
  321. _CusColor2[6] = Uint8Color.Set(Color.white);
  322. _CusColor3[6] = Uint8Color.Set(Color.white);
  323. }
  324. }
  325. if (_bluePrintType == BlurPrintType.AllAppearance)
  326. {
  327. int _length = _bytes.Length - _index;
  328. byte[] _nameBytes = new byte[_length];
  329. Array.Copy(_bytes, _index, _nameBytes, 0, _length);
  330. _Name = Encoding.ASCII.GetString(_nameBytes);
  331. }
  332. }
  333. public CharacterAppearance(byte[] _bytes)
  334. {
  335. _CharacterData = new CharacterData();
  336. DefaultValue();
  337. Load(_bytes);
  338. }
  339. public CharacterAppearance(byte[] _bytes, DataVersions dataVersions)
  340. {
  341. _CharacterData = new CharacterData();
  342. DefaultValue();
  343. Load(_bytes, dataVersions);
  344. }
  345. public byte[] ToBytes(BlurPrintType _bluePrintType = BlurPrintType.AllAppearance)
  346. {
  347. int _outfitSlotsCount = System.Enum.GetValues(typeof(OutfitSlots)).Length;
  348. List<byte> _bytes = new List<byte>();
  349. _bytes.Add((byte)_bluePrintType);
  350. _bytes.Add(_CharacterData.Sex);
  351. _bytes.Add(_CharacterData.Race);
  352. if (_bluePrintType!= BlurPrintType.Outfits) {
  353. _bytes.AddRange(_CharacterData.DataFloat);
  354. if (_bluePrintType != BlurPrintType.BodyShape)
  355. {
  356. for (int i = 0; i < 15; i++)
  357. {
  358. _bytes.AddRange(_CharacterData.DataColor[i].ToBytes());
  359. }
  360. _bytes.AddRange(_CharacterData.DataInt);
  361. }
  362. }
  363. if (_bluePrintType == BlurPrintType.Outfits || _bluePrintType== BlurPrintType.AllAppearance)
  364. {
  365. _bytes.AddRange(_OutfitID);
  366. for (int i=0;i< _outfitSlotsCount;i++) {
  367. _bytes.AddRange(_CusColor1[i].ToBytes());
  368. _bytes.AddRange(_CusColor2[i].ToBytes());
  369. _bytes.AddRange(_CusColor3[i].ToBytes());
  370. }
  371. }
  372. if (_bluePrintType == BlurPrintType.AllAppearance) {
  373. byte[] bytes = Encoding.ASCII.GetBytes(_Name);
  374. _bytes.AddRange(bytes);
  375. }
  376. return _bytes.ToArray();
  377. }
  378. }
  379. [System.Serializable]
  380. public class CharacterData
  381. {
  382. public byte Sex = 0;
  383. public byte Race=0;
  384. public byte[] DataFloat = new byte[120];
  385. public Uint8Color[] DataColor = new Uint8Color[15];
  386. public byte[] DataInt = new byte[10];
  387. public CharacterData Copy()
  388. {
  389. CharacterData _copy = new CharacterData();
  390. _copy.Sex = Sex;
  391. _copy.Race = Race;
  392. _copy.DataFloat = new byte[120];
  393. _copy.DataColor = new Uint8Color[15];
  394. _copy.DataInt = new byte[10];
  395. for (int i = 0; i < DataFloat.Length; i++)
  396. {
  397. _copy.DataFloat[i] = DataFloat[i];
  398. }
  399. for (int i = 0; i < DataColor.Length; i++)
  400. {
  401. _copy.DataColor[i] = new Uint8Color(DataColor[i].r, DataColor[i].g, DataColor[i].b, DataColor[i].a);
  402. }
  403. for (int i = 0; i < DataInt.Length; i++)
  404. {
  405. _copy.DataInt[i] = DataInt[i];
  406. }
  407. return _copy;
  408. }
  409. public void Random(Color[] _skinColors, Color[] _hairColors)
  410. {
  411. Race = (byte)Mathf.Max(UnityEngine.Random.Range(-10, CharacterDataSetting.instance.RaceSettings.Length),0);
  412. for (int i = 0; i < 120; i++)
  413. {
  414. if (i == 115 || i == 119)
  415. {
  416. DataFloat[i] = (byte)UnityEngine.Random.Range(0, 100);
  417. }
  418. else if (i == 1 || i >= 108)
  419. {
  420. DataFloat[i] = (byte)UnityEngine.Random.Range(30, 70);
  421. }
  422. else if (i == 107)
  423. {
  424. DataFloat[i] = 50;
  425. }
  426. else if (i == 81 || i == 106)
  427. {
  428. DataFloat[i] = (byte)UnityEngine.Random.Range(35, 65);
  429. }
  430. else
  431. {
  432. DataFloat[i] = (byte)UnityEngine.Random.Range(20, 80);
  433. }
  434. }
  435. DataColor[0] = Uint8Color.Random();
  436. DataColor[1] = Uint8Color.Set(_skinColors[UnityEngine.Random.Range(0, _skinColors.Length)]);//skin
  437. DataColor[2] = Uint8Color.RandomOffset(DataColor[1], 30, 20, 20, 200);//lip
  438. DataColor[3] = Uint8Color.RandomOffset(DataColor[1], 20, 20, 0, 100);//makeup
  439. DataColor[4] = Uint8Color.Set(_hairColors[UnityEngine.Random.Range(0, _hairColors.Length)]);//hair
  440. DataColor[5] = Uint8Color.RandomOffset(DataColor[1], 80, 0, 80, 240);//Face Tattoo
  441. DataColor[6] = Uint8Color.RandomOffset(DataColor[1], 80, 0, 80, 240);//Body Tattoo
  442. DataColor[7] = Uint8Color.Random();//Eye
  443. DataColor[8] = Uint8Color.RandomOffset(DataColor[7], 30, 100, 50, 255);//Eye_Highlights_Color
  444. DataColor[9] = DataColor[4].Copy();//Eyebrows
  445. DataColor[9].a = (byte)UnityEngine.Random.Range(0, 200);
  446. int[] IntMaxMale = new int[10]{
  447. 0,
  448. CharacterDataSetting.instance.MaleMaterialSettings[9].TextureIdMax+1,
  449. CharacterDataSetting.instance.MaleMaterialSettings[10].TextureIdMax+1,
  450. CharacterDataSetting.instance.MaleMaterialSettings[11].TextureIdMax+1,
  451. CharacterDataSetting.instance.MaleMaterialSettings[12].TextureIdMax+1,
  452. CharacterDataSetting.instance.MaleMaterialSettings[13].TextureIdMax+1,
  453. CharacterDataSetting.instance.MaleMaterialSettings[14].TextureIdMax+1,
  454. CharacterDataSetting.instance.MaleMaterialSettings[15].TextureIdMax+1,
  455. CharacterDataSetting.instance.MaleAccessorySettings[0].MaxValue+1,
  456. CharacterDataSetting.instance.MaleAccessorySettings[1].MaxValue+1
  457. };
  458. int[] IntMaxFemale = new int[10]{
  459. 0,
  460. CharacterDataSetting.instance.FemaleMaterialSettings[9].TextureIdMax+1,
  461. CharacterDataSetting.instance.FemaleMaterialSettings[10].TextureIdMax+1,
  462. CharacterDataSetting.instance.FemaleMaterialSettings[11].TextureIdMax+1,
  463. CharacterDataSetting.instance.FemaleMaterialSettings[12].TextureIdMax+1,
  464. CharacterDataSetting.instance.FemaleMaterialSettings[13].TextureIdMax+1,
  465. CharacterDataSetting.instance.FemaleMaterialSettings[14].TextureIdMax+1,
  466. CharacterDataSetting.instance.FemaleMaterialSettings[15].TextureIdMax+1,
  467. CharacterDataSetting.instance.FemaleAccessorySettings[0].MaxValue+1,
  468. CharacterDataSetting.instance.FemaleAccessorySettings[1].MaxValue+1
  469. };
  470. for (int i = 0; i < 10; i++)
  471. {
  472. DataInt[i] = (byte)UnityEngine.Random.Range(0, Sex == 0 ? IntMaxMale[i] : IntMaxFemale[i]);
  473. }
  474. }
  475. public CharacterData()
  476. {
  477. DataFloat = new byte[120];
  478. DataColor = new Uint8Color[15];
  479. DataInt = new byte[10];
  480. Race = 0;
  481. for (int i = 0; i < DataFloat.Length; i++)
  482. {
  483. DataFloat[i] = 50;
  484. }
  485. DataFloat[119] = 0;
  486. DataFloat[115] = 100;
  487. for (int i = 0; i < DataColor.Length; i++)
  488. {
  489. DataColor[i] = Uint8Color.Set(Color.white);
  490. }
  491. for (int i = 0; i < DataInt.Length; i++)
  492. {
  493. DataInt[i] = 0;
  494. }
  495. DataColor[1] = Uint8Color.Set(new Color(1F, 0.835F, 0.75F, 1F));
  496. DataInt[8] = 1;
  497. }
  498. public static CharacterData Create(byte _sex)
  499. {
  500. CharacterData _data = new CharacterData();
  501. _data.Sex = _sex;
  502. if (_sex == 0)
  503. {
  504. _data.DataColor[2] = Uint8Color.Set(new Color(1F, 0.5F, 0.45F, 1F));
  505. _data.DataColor[4] = Uint8Color.Set(new Color(0.6F, 0.4F, 0.25F, 1F));
  506. _data.DataColor[7] = Uint8Color.Set(new Color(0.6F, 1F, 1F, 0.7F));
  507. _data.DataColor[9] = Uint8Color.Set(new Color(0.6F, 0.4F, 0.25F, 1F));
  508. _data.DataInt[8] = 5;
  509. }
  510. else
  511. {
  512. _data.DataColor[2] = Uint8Color.Set(new Color(1F, 0.44F, 0.35F, 1F));
  513. _data.DataColor[3] = Uint8Color.Set(new Color(1F, 0.34F, 0.2F, 1F));
  514. _data.DataColor[4] = Uint8Color.Set(new Color(1F, 0.69F, 0.5F, 1F));
  515. _data.DataColor[7] = Uint8Color.Set(new Color(0.6F, 1F, 1F, 0.7F));
  516. _data.DataColor[9] = Uint8Color.Set(new Color(0.6F, 0.4F, 0.25F, 1F));
  517. }
  518. return _data;
  519. }
  520. }
  521. [System.Serializable]
  522. public class RaceSetting
  523. {
  524. public string RaceName = "Human";
  525. [Header("> Base Settings")]
  526. public int[] RaceMorph = new int[10] { 0,0,0,0,0,0,0,0,0,0};
  527. public int[] TeethMorph = new int[4] {0,0,0,0 };
  528. public Color DefaultSkinColor=Color.white;
  529. public Color DefaultEyeColor= Color.blue;
  530. public int DefaultEyeID = 0;
  531. [Header("> Ear Settings")]
  532. [Range(0, 100)]
  533. public int DefaultEarsShape = 50;
  534. [Range(0, 100)]
  535. public int DefaultEarsScale = 50;
  536. [Range(0, 100)]
  537. public int DefaultEarsTipOffset = 50;
  538. [Header("> Male Texture Settings")]
  539. public Texture MaleBodyColorTexture;
  540. public Texture MaleBodyNormalTexture;
  541. public Texture MaleHeadColorTexture;
  542. public Texture MaleHeadNormalTexture;
  543. public Texture MaleHandColorTexture;
  544. public Texture MaleFeetColorTexture;
  545. public Texture MaleHairTexture;
  546. [Header("> Female Texture Settings")]
  547. public Texture FemaleBodyColorTexture;
  548. public Texture FemaleBodyNormalTexture;
  549. public Texture FemaleHeadColorTexture;
  550. public Texture FemaleHeadNormalTexture;
  551. public Texture FemaleHandColorTexture;
  552. public Texture FemaleFeetColorTexture;
  553. public Texture FemaleHairTexture;
  554. [Header("> Accessories Settings")]
  555. public int DefaultMaleHeadAccessory = 0;
  556. public int DefaultFemaleHeadAccessory = 0;
  557. public int DefaultBackAccessory = 0;
  558. public int DefaultTail = 0;
  559. }
  560. #endregion
  561. #region Outfit Class
  562. [System.Serializable]
  563. public class OutfitColorSetting
  564. {
  565. public bool ToggleCustomColor1 = true;
  566. public Color DefaultColor1 = Color.white;
  567. public bool ToggleCustomColor2 = true;
  568. public Color DefaultColor2 = Color.white;
  569. public bool ToggleCustomColor3 = true;
  570. public Color DefaultColor3 = Color.white;
  571. }
  572. [System.Serializable]
  573. public class OutfitInfo
  574. {
  575. public string DisplayName;
  576. public Texture Icon;
  577. public OutfitSlots Slot;
  578. public string MeshPath;
  579. public string MaterialPath;
  580. public OutfitColorSetting ColorSetting;
  581. public bool HideHair = false;
  582. public bool HideFace = false;
  583. public bool PossibleIntersect = false;
  584. public int BreastMorphID = -1;
  585. public bool CanBeOverride = false;
  586. public bool OverrideTexture = false;
  587. public OutfitSlots OverrideSlot;
  588. public Texture OverrideMask1;
  589. public bool[] AvailableForRaces = new bool[10] { true, true, true, true, true, true, true, true, true, true };
  590. public string[] BoneNames;
  591. public OutfitInfo copy()
  592. {
  593. OutfitInfo _copy = new OutfitInfo();
  594. _copy.DisplayName = this.DisplayName;
  595. _copy.Slot = this.Slot;
  596. _copy.MeshPath = this.MeshPath;
  597. _copy.MaterialPath = this.MaterialPath;
  598. _copy.BoneNames = new string[this.BoneNames.Length];
  599. for (int i=0;i< BoneNames.Length;i++) {
  600. _copy.BoneNames[i] = this.BoneNames[i];
  601. }
  602. return _copy;
  603. }
  604. }
  605. [System.Serializable]
  606. public class AccessoryInfo
  607. {
  608. public string DisplayName;
  609. public CharacterDataSetting.CharacterTextureNames Slot;
  610. public string MatSlotName = "_Color";
  611. public string PrefabPath;
  612. public string ThumbPath;
  613. public CharacterDataSetting.CharacterColorNames ColorType;
  614. public string RootBoneNames;
  615. public int MinValue;
  616. public int MaxValue;
  617. public bool ZeroForNull=true;
  618. public string SkinnedRendererName = "";
  619. public AccessoryInfo copy()
  620. {
  621. AccessoryInfo _copy = new AccessoryInfo();
  622. _copy.DisplayName = this.DisplayName;
  623. _copy.Slot = this.Slot;
  624. _copy.MatSlotName = this.MatSlotName;
  625. _copy.PrefabPath = this.PrefabPath;
  626. _copy.ThumbPath = this.ThumbPath;
  627. _copy.ColorType = this.ColorType;
  628. _copy.RootBoneNames = this.RootBoneNames;
  629. _copy.MinValue = this.MinValue;
  630. _copy.MaxValue = this.MaxValue;
  631. _copy.ZeroForNull = this.ZeroForNull;
  632. return _copy;
  633. }
  634. }
  635. [System.Serializable]
  636. public class Uint8Color
  637. {
  638. public byte r;
  639. public byte g;
  640. public byte b;
  641. public byte a;
  642. public Uint8Color() { }
  643. public Uint8Color(byte [] _bytes)
  644. {
  645. r = _bytes[0];
  646. g = _bytes[1];
  647. b = _bytes[2];
  648. a = _bytes[3];
  649. }
  650. public Uint8Color(byte red,byte green,byte blue,byte alpha )
  651. {
  652. r = red;
  653. g = green;
  654. b = blue;
  655. a = alpha;
  656. }
  657. public Uint8Color Copy()
  658. {
  659. return new Uint8Color(r,g,b,a);
  660. }
  661. public static Uint8Color RandomOffset(Uint8Color _baseColor,byte _offsetMinimal, byte _offsetMaxuium, int _alphaMinimal=0, int _alphaMaxuium=255)
  662. {
  663. return new Uint8Color()
  664. {
  665. r = (byte)Mathf.FloorToInt(Mathf.Clamp(_baseColor.r + UnityEngine.Random.Range(-_offsetMinimal, _offsetMaxuium), 0, 255)),
  666. g = (byte)Mathf.FloorToInt(Mathf.Clamp(_baseColor.g + UnityEngine.Random.Range(-_offsetMinimal, _offsetMaxuium), 0, 255)),
  667. b = (byte)Mathf.FloorToInt(Mathf.Clamp(_baseColor.b + UnityEngine.Random.Range(-_offsetMinimal, _offsetMaxuium), 0, 255)),
  668. a = (byte)Mathf.FloorToInt(UnityEngine.Random.Range(_alphaMinimal, _alphaMaxuium))
  669. };
  670. }
  671. public static Uint8Color Random()
  672. {
  673. return new Uint8Color()
  674. {
  675. r = (byte)UnityEngine.Random.Range(0, 255),
  676. g = (byte)UnityEngine.Random.Range(0, 255),
  677. b = (byte)UnityEngine.Random.Range(0, 255),
  678. a = 255
  679. };
  680. }
  681. public static Uint8Color Set(Color _color)
  682. {
  683. return new Uint8Color() {
  684. r = (byte)Mathf.FloorToInt(_color.r * 255),
  685. g = (byte)Mathf.FloorToInt(_color.g * 255),
  686. b = (byte)Mathf.FloorToInt(_color.b * 255),
  687. a = (byte)Mathf.FloorToInt(_color.a * 255)
  688. };
  689. }
  690. public static Color Get(Uint8Color _color)
  691. {
  692. return new Color((_color.r*1F)/255F, (_color.g * 1F) / 255F, (_color.b * 1F) / 255F, (_color.a * 1F) / 255F);
  693. }
  694. public byte[] ToBytes()
  695. {
  696. return new byte[4] {r,g,b,a };
  697. }
  698. }
  699. #endregion
  700. #region Customization Class
  701. [System.Serializable]
  702. public class CharacterBoneDeformSetting
  703. {
  704. public string BoneNmae;
  705. public bool SetPos = false;
  706. public bool SetRot = false;
  707. public bool SetScale = false;
  708. public Vector3 OriPos;
  709. public Vector3 OriRot;
  710. public Vector3 OriScale;
  711. public CharacterBoneSlider[] PositionSliders;
  712. public CharacterBoneSlider[] RotationSliders;
  713. public CharacterBoneSlider[] ScaleSliders;
  714. public CharacterBoneDeformSetting copy()
  715. {
  716. CharacterBoneDeformSetting _copy = new CharacterBoneDeformSetting();
  717. _copy.BoneNmae = this.BoneNmae;
  718. _copy.SetPos = this.SetPos;
  719. _copy.SetRot = this.SetRot;
  720. _copy.SetScale = this.SetScale;
  721. _copy.OriPos = this.OriPos;
  722. _copy.OriRot = this.OriRot;
  723. _copy.OriScale = this.OriScale;
  724. _copy.PositionSliders =new CharacterBoneSlider [this.PositionSliders.Length];
  725. for (int i=0;i < _copy.PositionSliders.Length;i++) {
  726. _copy.PositionSliders[i] = this.PositionSliders[i].copy();
  727. }
  728. _copy.RotationSliders = new CharacterBoneSlider[this.RotationSliders.Length];
  729. for (int i = 0; i < _copy.RotationSliders.Length; i++)
  730. {
  731. _copy.RotationSliders[i] = this.RotationSliders[i].copy();
  732. }
  733. _copy.ScaleSliders = new CharacterBoneSlider[this.ScaleSliders.Length];
  734. for (int i = 0; i < _copy.ScaleSliders.Length; i++)
  735. {
  736. _copy.ScaleSliders[i] = this.ScaleSliders[i].copy();
  737. }
  738. return _copy;
  739. }
  740. }
  741. [System.Serializable]
  742. public class CharacterBoneSlider
  743. {
  744. public CharacterDataSetting.CharacterBoneSliderNames SliderType;
  745. public float DefaultValue;
  746. public float MinOffset;
  747. public float MaxOffset;
  748. public float Mutiplier = 1F;
  749. public CharacterBoneSlider copy()
  750. {
  751. CharacterBoneSlider _copy = new CharacterBoneSlider();
  752. _copy.SliderType = this.SliderType;
  753. _copy.DefaultValue = this.DefaultValue;
  754. _copy.MinOffset = this.MinOffset;
  755. _copy.MaxOffset = this.MaxOffset;
  756. _copy.Mutiplier = this.Mutiplier;
  757. return _copy;
  758. }
  759. }
  760. [System.Serializable]
  761. public class CharacterMaterialSetting
  762. {
  763. public string SettingName;
  764. public string[] RendererName;
  765. public string SlotName = "";
  766. public CharacterDataSetting.CharacterColorNames ColorType;
  767. public CharacterDataSetting.CharacterTextureNames TextureType;
  768. public CharacterDataSetting.CharacterBoneSliderNames FloatType;
  769. public string TextureBaseName = "";
  770. public int TextureIdMin = 0;
  771. public int TextureIdMax = 0;
  772. public float SliderMin = 0F;
  773. public float SliderMax = 1F;
  774. public CharacterMaterialSetting copy()
  775. {
  776. CharacterMaterialSetting _copy = new CharacterMaterialSetting();
  777. _copy.SettingName = this.SettingName;
  778. _copy.RendererName = new string[ this.RendererName.Length];
  779. for (int i = 0; i < _copy.RendererName.Length; i++)
  780. {
  781. _copy.RendererName[i] = this.RendererName[i];
  782. }
  783. _copy.SlotName = this.SlotName;
  784. _copy.ColorType = this.ColorType;
  785. _copy.TextureType = this.TextureType;
  786. _copy.FloatType = this.FloatType;
  787. _copy.TextureBaseName = this.TextureBaseName;
  788. _copy.TextureIdMin = this.TextureIdMin;
  789. _copy.TextureIdMax = this.TextureIdMax;
  790. _copy.SliderMin = this.SliderMin;
  791. _copy.SliderMax = this.SliderMax;
  792. return _copy;
  793. }
  794. }
  795. /// <summary>
  796. /// The EmotionSetting class is used to combine the head/eyelash/teeth morphs to create preset emotions.
  797. /// </summary>
  798. [System.Serializable]
  799. public class EmotionSetting
  800. {
  801. public bool fold = false;
  802. /// <summary>
  803. /// Unique string id, will be used when calling <CharacterEntity>().PlayEmotion(string _uid)
  804. /// </summary>
  805. public string uid = "";
  806. /// <summary>
  807. /// Morph settings of this emotion.
  808. /// </summary>
  809. public List<Vector2> HeadMorphs = new List<Vector2>();
  810. /// <summary>
  811. /// Reset all morph settings of this emotion.
  812. /// </summary>
  813. public void Reset()
  814. {
  815. HeadMorphs.Clear();
  816. }
  817. /// <summary>
  818. /// Get the display name of an emotion by its id.
  819. /// </summary>
  820. /// <param name="_id"></param>
  821. /// <returns></returns>
  822. public static string GetEmotionName(int _id)
  823. {
  824. if (_id < 0 || _id >= 16) return "None";
  825. return MorphName[_id];
  826. }
  827. /// <summary>
  828. /// Get the head blendshape value by its index.
  829. /// </summary>
  830. /// <param name="_morphIndex"></param>
  831. /// <returns></returns>
  832. public int GetHeadMorph(int _morphIndex)
  833. {
  834. if (_morphIndex < 0 || _morphIndex >= 22) return 0;
  835. for (int i=0;i< HeadMorphs.Count;i++) {
  836. if (HeadMorphMapping[Mathf.FloorToInt(HeadMorphs[i].x)] == _morphIndex) return Mathf.FloorToInt(HeadMorphs[i].y);
  837. }
  838. return 0;
  839. }
  840. /// <summary>
  841. /// Get the eyelash blendshape value by its index.
  842. /// </summary>
  843. /// <param name="_morphIndex"></param>
  844. /// <returns></returns>
  845. public int GetEyelashMorph(int _morphIndex)
  846. {
  847. if (_morphIndex < 0 || _morphIndex > 2) return 0;
  848. for (int i = 0; i < HeadMorphs.Count; i++)
  849. {
  850. if (EyelashMorphMapping[Mathf.FloorToInt(HeadMorphs[i].x)] == _morphIndex) return Mathf.FloorToInt(HeadMorphs[i].y);
  851. }
  852. return 0;
  853. }
  854. /// <summary>
  855. /// Get the teeth open blendshape value.
  856. /// </summary>
  857. /// <returns></returns>
  858. public int GetTeethOpen()
  859. {
  860. int _result = 0;
  861. for (int i = 0; i < HeadMorphs.Count; i++)
  862. {
  863. _result =Mathf.Max(_result,TeethMorphMapping[Mathf.FloorToInt(HeadMorphs[i].x)]);
  864. }
  865. return _result;
  866. }
  867. /// <summary>
  868. /// The head morph id of each emotion
  869. /// </summary>
  870. private static int[] HeadMorphMapping = new int[16]{
  871. 0,
  872. 21,
  873. 4,
  874. 5,
  875. 19,
  876. 20,
  877. 2,
  878. 3,
  879. 1,
  880. 6,
  881. 7,
  882. 8,
  883. 9,
  884. 10,
  885. 11,
  886. 12
  887. };
  888. /// <summary>
  889. /// The eyelash morph id of each emotion
  890. /// </summary>
  891. private static int[] EyelashMorphMapping = new int[16]{
  892. 0,
  893. 2,
  894. -1,
  895. -1,
  896. -1,
  897. -1,
  898. -1,
  899. 1,
  900. -1,
  901. -1,
  902. -1,
  903. -1,
  904. -1,
  905. -1,
  906. -1,
  907. -1
  908. };
  909. /// <summary>
  910. /// How much the teeth open for each emotion
  911. /// </summary>
  912. private static int[] TeethMorphMapping = new int[16]{
  913. 0,
  914. 0,
  915. 0,
  916. 0,
  917. 0,
  918. 0,
  919. 0,
  920. 0,
  921. 100,
  922. 38,
  923. 22,
  924. 28,
  925. 100,
  926. 100,
  927. 0,
  928. 25
  929. };
  930. /// <summary>
  931. /// The display name of each emotion
  932. /// </summary>
  933. public static string[] MorphName=new string[16] {
  934. "Eye Close",//0
  935. "Eye Squint",//1
  936. "Eyebrow Down",//2
  937. "Eyebrow Up",//3
  938. "Angry",//4
  939. "Sad",//5
  940. "Happy",//6
  941. "Pain",//7
  942. "Open Mouth",//8
  943. "Viseme w",//9
  944. "Viseme th",//10
  945. "Viseme t",//11
  946. "Viseme ow",//12
  947. "Viseme oo",//13
  948. "Viseme f",//14
  949. "Viseme ee",//15
  950. };
  951. }
  952. #endregion
  953. public class CharacterDataSetting : MonoBehaviour
  954. {
  955. public static CharacterDataSetting instance
  956. {
  957. get
  958. {
  959. if (_instance == null)
  960. {
  961. #if UNITY_EDITOR
  962. if (!Application.isPlaying) return ((GameObject)AssetDatabase.LoadAssetAtPath("Assets/SoftKitty/MasterCharacterCreator/Resources/MasterCharacterCreator/Core/CharacterData.prefab",typeof(GameObject))).GetComponent< CharacterDataSetting>();
  963. #endif
  964. _instance = Instantiate(Resources.Load<GameObject>("MasterCharacterCreator/Core/CharacterData")).GetComponent<CharacterDataSetting>();
  965. }
  966. return _instance;
  967. }
  968. }
  969. private static CharacterDataSetting _instance;
  970. #region Settings
  971. public RaceSetting[] RaceSettings;
  972. public CharacterBoneDeformSetting[] MaleBoneSettings;
  973. public CharacterBoneDeformSetting[] FemaleBoneSettings;
  974. public CharacterMaterialSetting[] MaleMaterialSettings;
  975. public CharacterMaterialSetting[] FemaleMaterialSettings;
  976. public AccessoryInfo[] MaleAccessorySettings;
  977. public AccessoryInfo[] FemaleAccessorySettings;
  978. public OutfitInfo[] MaleArmorSetting;
  979. public OutfitInfo[] MalePantsSetting;
  980. public OutfitInfo[] MaleBootSetting;
  981. public OutfitInfo[] MaleGloveSetting;
  982. public OutfitInfo[] MaleHelmetSetting;
  983. public OutfitInfo[] FemaleArmorSetting;
  984. public OutfitInfo[] FemalePantsSetting;
  985. public OutfitInfo[] FemaleBootSetting;
  986. public OutfitInfo[] FemaleGloveSetting;
  987. public OutfitInfo[] FemaleHelmetSetting;
  988. #endregion
  989. #region Enum
  990. public enum CharacterBoneSliderNames
  991. {
  992. None,
  993. Head_Size,
  994. Upper_Face_Width,
  995. Upper_Face_Length,
  996. Upper_Face_Depth,
  997. Upper_Face_Height,
  998. Lower_Face_Width,
  999. Lower_Face_Length,
  1000. Lower_Face_Depth,
  1001. Lower_Face_Height,
  1002. ForeHead_Width,
  1003. ForeHead_Height,
  1004. ForeHead_Depth,
  1005. Cheek_Width,
  1006. Cheek_Length,
  1007. Cheek_Height,
  1008. Cheek_Depth,
  1009. Jaw_Width,
  1010. Jaw_Height,
  1011. Jaw_Depth,
  1012. Chin_Width,
  1013. Chin_Length,
  1014. Chin_Height,
  1015. Chin_Depth,
  1016. Ears_Scale,
  1017. Ears_Shape,
  1018. Ear_Tips_Offset,
  1019. Eyebrows_Depth,
  1020. Eyebrows_Space,
  1021. Outer_Eyebrows_Width,
  1022. Outer_Eyebrows_Height,
  1023. Inner_Eyebrows_Angle,
  1024. Eyes_Width,
  1025. Eyes_Length,
  1026. Eyes_Depth,
  1027. Eyes_Height,
  1028. Pupils_Width,
  1029. Pupils_Length,
  1030. Retinas_Width,
  1031. Retinas_Length,
  1032. Upper_Eyelid_Height,
  1033. Upper_Eyelid_Shape,
  1034. Lower_Eyelid_Height,
  1035. Lower_Eyelid_Shape,
  1036. Inner_Eye_Corner_Height,
  1037. Inner_Eye_Corner_Shape,
  1038. Outer_Eye_Corner_Height,
  1039. Outer_Eye_Corner_Shape,
  1040. Nose_Width,
  1041. Nose_Length,
  1042. Nose_Depth,
  1043. Nose_Height,
  1044. Nose_Bridge_Width,
  1045. Nose_Bridge_Depth,
  1046. Nose_Tip_Width,
  1047. Nose_Tip_Length,
  1048. Nose_Tip_Height,
  1049. Nose_Tip_Depth,
  1050. Nose_Wing_Width,
  1051. Nose_Wing_Length,
  1052. Nose_Wing_Height,
  1053. Nose_Wing_Depth,
  1054. Mouth_Width,
  1055. Mouth_Length,
  1056. Mouth_Depth,
  1057. Mouth_Height,
  1058. Upper_Lip_Width,
  1059. Upper_Lip_Length,
  1060. Upper_Lip_Depth,
  1061. Upper_Lip_Height,
  1062. Lower_Lip_Width,
  1063. lower_Lip_Length,
  1064. Lower_Lip_Depth,
  1065. Lower_Lip_Height,
  1066. Mouth_Corners_Width,
  1067. Mouth_Corners_Height,
  1068. Mouth_Corners_Length,
  1069. Mouth_Corners_Depth,
  1070. Teeth_Width,
  1071. Teeth_Height,
  1072. Teeth_Depth,
  1073. Body_Height,
  1074. Neck_Width,
  1075. Neck_Depth,
  1076. Chest_Width,
  1077. Chest_Length,
  1078. Chest_Depth,
  1079. Breast_Size,
  1080. Stomach_Width,
  1081. Stomach_Depth,
  1082. Waist_Width,
  1083. Waist_Length,
  1084. Waist_Depth,
  1085. Hip_Width,
  1086. Hip_Depth,
  1087. Ass_Width,
  1088. Ass_Length,
  1089. Ass_Depth,
  1090. Shoulder_Width,
  1091. Shoulder_Length,
  1092. Shoulder_Depth,
  1093. Upperarm_Size,
  1094. Forearm_Size,
  1095. Hand_Size,
  1096. Thigh_Size,
  1097. Calf_Size,
  1098. Feet_Size,
  1099. Toe_Size,
  1100. Mouth_Underbite,
  1101. Upper_Lip_Bite,
  1102. Upper_Lip_Flip,
  1103. Lower_Lip_Bite,
  1104. Lower_Lip_Flip,
  1105. Eye_Space,
  1106. Retinas_Z,
  1107. Muscular,
  1108. Eyebrows_X,
  1109. Eyebrows_Y,
  1110. Eyebrows_Thickness,
  1111. Age,
  1112. Title_Head,
  1113. Title_Upper_Face,
  1114. Title_Lower_Face,
  1115. Title_ForeHead,
  1116. Title_Cheek,
  1117. Title_Chin,
  1118. Title_Jaw,
  1119. Title_Ear,
  1120. Title_Eyebrows,
  1121. Title_Eyes,
  1122. Title_Pupils,
  1123. Title_Retinas,
  1124. Title_Upper_Eyelid,
  1125. Title_Lower_Eyelid,
  1126. Title_Inner_Eye_Corner,
  1127. Title_Outer_Eye_Corner,
  1128. Title_Nose,
  1129. Title_Nose_Bridge,
  1130. Title_Nose_Tip,
  1131. Title_Nose_Wing,
  1132. Title_Mouth,
  1133. Title_Upper_Lip,
  1134. Title_Lower_Lip,
  1135. Title_Mouth_Corners,
  1136. Title_Teeth,
  1137. Title_Body,
  1138. Title_Neck,
  1139. Title_Chest,
  1140. Title_Breast,
  1141. Title_Stomach,
  1142. Title_Waist,
  1143. Title_Hip,
  1144. Title_Buttocks,
  1145. Title_Shoulders,
  1146. Title_Upperarms,
  1147. Title_Forearms,
  1148. Title_Hands,
  1149. Title_Thighs,
  1150. Title_Calfs,
  1151. Title_Feet,
  1152. Title_Toes
  1153. };
  1154. public enum CharacterColorNames
  1155. {
  1156. None,
  1157. Skin_Color,
  1158. Lip_Color,
  1159. Makeup_Color,
  1160. Hair_Color,
  1161. Face_Tattoo_Color,
  1162. Body_Tattoo_Color,
  1163. Eye_Color,
  1164. Eye_Highlights_Color,
  1165. Eyebrows_Color
  1166. }
  1167. public enum CharacterTextureNames
  1168. {
  1169. None,
  1170. Lip,
  1171. Makeup,
  1172. Face_Tattoo,
  1173. Body_Tattoo,
  1174. Eyes,
  1175. Eye_Highlights,
  1176. Eyebrows,
  1177. HairID,
  1178. BeardID,
  1179. Back,
  1180. Tail
  1181. }
  1182. #endregion
  1183. public OutfitColorSetting GetOutfitColorSetting(Sex _sex,OutfitSlots _slot, int _id)
  1184. {
  1185. return GetOutfitSettings(_sex, _slot)[_id].ColorSetting;
  1186. }
  1187. public OutfitInfo [] GetOutfitSettings(Sex _sex, OutfitSlots _slot)
  1188. {
  1189. switch (_slot)
  1190. {
  1191. default:
  1192. return _sex == Sex.Female ? FemaleArmorSetting : MaleArmorSetting;
  1193. case OutfitSlots.Helmet:
  1194. return _sex == Sex.Female ? FemaleHelmetSetting: MaleHelmetSetting;
  1195. case OutfitSlots.Gauntlet:
  1196. return _sex == Sex.Female ? FemaleGloveSetting: MaleGloveSetting;
  1197. case OutfitSlots.Boot:
  1198. return _sex == Sex.Female ? FemaleBootSetting: MaleBootSetting;
  1199. case OutfitSlots.Pants:
  1200. return _sex == Sex.Female ? FemalePantsSetting : MalePantsSetting;
  1201. case OutfitSlots.Back:
  1202. OutfitInfo [] _infosBack = new OutfitInfo[(_sex == Sex.Female ? instance.FemaleAccessorySettings[2].MaxValue:instance.MaleAccessorySettings[2].MaxValue)+1];
  1203. string _iconPathBack = _sex == Sex.Female ? instance.FemaleAccessorySettings[2].ThumbPath : instance.MaleAccessorySettings[2].ThumbPath;
  1204. string _modelPathBack = _sex == Sex.Female ? instance.FemaleAccessorySettings[2].PrefabPath : instance.MaleAccessorySettings[2].PrefabPath;
  1205. for (int i = 0; i < _infosBack.Length; i++) {
  1206. _infosBack[i]= new OutfitInfo();
  1207. _infosBack[i].DisplayName = i == 0 ? "None" : _sex.ToString() + " Back " + i.ToString();
  1208. #if UNITY_EDITOR
  1209. if (i == 0)
  1210. _infosBack[i].Icon = (Texture)AssetDatabase.LoadAssetAtPath("Assets/SoftKitty/MasterCharacterCreator/Resources/MasterCharacterCreator/Icons/Empty.png", typeof(Texture));
  1211. else
  1212. _infosBack[i].Icon = (Texture)AssetDatabase.LoadAssetAtPath("Assets/SoftKitty/MasterCharacterCreator/Resources/" + _iconPathBack + i.ToString() + ".png", typeof(Texture));
  1213. #else
  1214. if (i == 0)
  1215. _infosBack[i].Icon = Resources.Load<Texture>("Assets/SoftKitty/MasterCharacterCreator/Resources/MasterCharacterCreator/Icons/Empty");
  1216. else
  1217. _infosBack[i].Icon = Resources.Load<Texture>(_iconPathBack + i.ToString());
  1218. #endif
  1219. _infosBack[i].MeshPath = _modelPathBack + i.ToString("00");
  1220. _infosBack[i].MaterialPath = "";
  1221. _infosBack[i].ColorSetting = new OutfitColorSetting();
  1222. _infosBack[i].ColorSetting.ToggleCustomColor1 = true;
  1223. _infosBack[i].ColorSetting.ToggleCustomColor2 = true;
  1224. _infosBack[i].ColorSetting.ToggleCustomColor3 = true;
  1225. _infosBack[i].ColorSetting.DefaultColor1 = Color.white;
  1226. _infosBack[i].ColorSetting.DefaultColor2 = Color.white;
  1227. _infosBack[i].ColorSetting.DefaultColor3 = Color.white;
  1228. _infosBack[i].Slot = OutfitSlots.Back;
  1229. }
  1230. return _infosBack;
  1231. case OutfitSlots.Tail:
  1232. OutfitInfo[] _infosTail = new OutfitInfo[(_sex == Sex.Female ? instance.FemaleAccessorySettings[3].MaxValue : instance.MaleAccessorySettings[3].MaxValue)+1];
  1233. string _iconPathTail = _sex == Sex.Female ? instance.FemaleAccessorySettings[3].ThumbPath : instance.MaleAccessorySettings[3].ThumbPath;
  1234. string _modelPathTail = _sex == Sex.Female ? instance.FemaleAccessorySettings[3].PrefabPath : instance.MaleAccessorySettings[3].PrefabPath;
  1235. for (int i = 0; i < _infosTail.Length; i++)
  1236. {
  1237. _infosTail[i] = new OutfitInfo();
  1238. _infosTail[i].DisplayName =i==0?"None": _sex.ToString() + " Tail " + i.ToString() ;
  1239. #if UNITY_EDITOR
  1240. if (i == 0)
  1241. _infosTail[i].Icon = (Texture)AssetDatabase.LoadAssetAtPath("Assets/SoftKitty/MasterCharacterCreator/Resources/MasterCharacterCreator/Icons/Empty.png", typeof(Texture));
  1242. else
  1243. _infosTail[i].Icon = (Texture)AssetDatabase.LoadAssetAtPath("Assets/SoftKitty/MasterCharacterCreator/Resources/" + _iconPathTail + i.ToString() + ".png", typeof(Texture));
  1244. #else
  1245. if (i == 0)
  1246. _infosTail[i].Icon = Resources.Load<Texture>("Assets/SoftKitty/MasterCharacterCreator/Resources/MasterCharacterCreator/Icons/Empty");
  1247. else
  1248. _infosTail[i].Icon = Resources.Load<Texture>(_iconPathTail + i.ToString());
  1249. #endif
  1250. _infosTail[i].MeshPath = _modelPathTail + i.ToString("00") ;
  1251. _infosTail[i].MaterialPath = "";
  1252. _infosTail[i].ColorSetting = new OutfitColorSetting();
  1253. _infosTail[i].ColorSetting.ToggleCustomColor1 = true;
  1254. _infosTail[i].ColorSetting.ToggleCustomColor2 = true;
  1255. _infosTail[i].ColorSetting.ToggleCustomColor3 = true;
  1256. _infosTail[i].ColorSetting.DefaultColor1 = Color.white;
  1257. _infosTail[i].ColorSetting.DefaultColor2 = Color.white;
  1258. _infosTail[i].ColorSetting.DefaultColor3 = Color.white;
  1259. _infosTail[i].Slot = OutfitSlots.Tail;
  1260. }
  1261. return _infosTail;
  1262. }
  1263. }
  1264. void Awake()
  1265. {
  1266. if (_instance != null && _instance != this)
  1267. {
  1268. Destroy(gameObject);
  1269. return;
  1270. }
  1271. _instance = this;
  1272. DontDestroyOnLoad(gameObject);
  1273. }
  1274. }
  1275. }