Ramaraunt1

Untitled

Dec 21st, 2016
113
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 18.34 KB | None | 0 0
  1. using UnityEngine;
  2. using System.Collections;
  3.  
  4. #region Gender Class
  5. public static class Gender
  6. {
  7. private static int male = 1;
  8. private static int female = 0;
  9.  
  10. public static int Male()
  11. {
  12. return male;
  13. }
  14. public static int Female()
  15. {
  16. return female;
  17. }
  18. }
  19. #endregion
  20.  
  21. #region Body Parts Return Class
  22. public class BodyPart
  23. {
  24. public static string Head(int genderID)
  25. {
  26. if (genderID == Gender.Male())
  27. {
  28. return "maleHead";
  29. }
  30. else if (genderID == Gender.Female())
  31. {
  32. return "femaleHead";
  33. }
  34. else
  35. {
  36. return "If you see this there is no gender of this person.";
  37. }
  38. }
  39.  
  40. public static string Arms(int genderID)
  41. {
  42. if (genderID == Gender.Male())
  43. {
  44. return "maleArms";
  45. }
  46. else if (genderID == Gender.Female())
  47. {
  48. return "femaleArms";
  49. }
  50. else
  51. {
  52. return "If you see this there is no gender of this person.";
  53. }
  54. }
  55.  
  56. public static string Legs(int genderID)
  57. {
  58. if (genderID == Gender.Male())
  59. {
  60. return "maleLegs";
  61. }
  62. else if (genderID == Gender.Female())
  63. {
  64. return "femaleLegs";
  65. }
  66. else
  67. {
  68. return "If you see this there is no gender of this person.";
  69. }
  70. }
  71.  
  72. public static string Torso(int genderID)
  73. {
  74. if (genderID == Gender.Male())
  75. {
  76. return "maleTorso";
  77. }
  78. else if (genderID == Gender.Female())
  79. {
  80. return "femaleTorso";
  81. }
  82. else
  83. {
  84. return "If you see this there is no gender of this person.";
  85. }
  86. }
  87.  
  88. public static string Hands(int genderID)
  89. {
  90. if (genderID == Gender.Male())
  91. {
  92. return "maleHands";
  93. }
  94. else if (genderID == Gender.Female())
  95. {
  96. return "femaleHands";
  97. }
  98. else
  99. {
  100. return "If you see this there is no gender of this person.";
  101. }
  102. }
  103.  
  104. public static string Feet(int genderID)
  105. {
  106. if (genderID == Gender.Male())
  107. {
  108. return "maleFeet";
  109. }
  110. else if (genderID == Gender.Female())
  111. {
  112. return "femaleFeet";
  113. }
  114. else
  115. {
  116. return "If you see this there is no gender of this person.";
  117. }
  118. }
  119.  
  120. public static string Ears(int genderID)
  121. {
  122. if (genderID == Gender.Male())
  123. {
  124. return "maleEars";
  125. }
  126. else if (genderID == Gender.Female())
  127. {
  128. return "femaleEars";
  129. }
  130. else
  131. {
  132. return "If you see this there is no gender of this person.";
  133. }
  134. }
  135.  
  136. public static string Mouth(int genderID)
  137. {
  138. if (genderID == Gender.Male())
  139. {
  140. return "maleMouth";
  141. }
  142. else if (genderID == Gender.Female())
  143. {
  144. return "femaleMouth";
  145. }
  146. else
  147. {
  148. return "If you see this there is no gender of this person.";
  149. }
  150. }
  151.  
  152. public static string Eyes(int genderID)
  153. {
  154. if (genderID == Gender.Male())
  155. {
  156. return "maleEyes";
  157. }
  158. else if (genderID == Gender.Female())
  159. {
  160. return "femaleEyes";
  161. }
  162. else
  163. {
  164. return "If you see this there is no gender of this person.";
  165. }
  166. }
  167.  
  168. public static string Tongue(int genderID)
  169. {
  170. if (genderID == Gender.Male())
  171. {
  172. return "maleTongue";
  173. }
  174. else if (genderID == Gender.Female())
  175. {
  176. return "femaleTongue";
  177. }
  178. else
  179. {
  180. return "If you see this there is no gender of this person.";
  181. }
  182. }
  183. }
  184. #endregion
  185.  
  186. #region Skin Color Class
  187. public static class SkinColor
  188. {
  189. private static int caucasian = 0;
  190. private static int black = 1;
  191. private static int brown = 2;
  192. private static int arabian = 3;
  193. private static int oriental = 4;
  194. private static int pale = 5;
  195.  
  196. public static int Caucasian()
  197. {
  198. return caucasian;
  199. }
  200. public static int Black()
  201. {
  202. return black;
  203. }
  204. public static int Brown()
  205. {
  206. return brown;
  207. }
  208. public static int Arabian()
  209. {
  210. return arabian;
  211. }
  212. public static int Oriental()
  213. {
  214. return oriental;
  215. }
  216. public static int Pale()
  217. {
  218. return pale;
  219. }
  220. //etc etc
  221. }
  222. #endregion
  223.  
  224. #region Skin Color Return Material Class
  225. public static class SkinMaterial
  226. {
  227. public static string get(int skinID)
  228. {
  229. if (skinID == SkinColor.Caucasian())
  230. {
  231. return "whiteSkin";
  232. }
  233. else if (skinID == SkinColor.Arabian())
  234. {
  235. return "bronzeSkin";
  236. }
  237. else if (skinID == SkinColor.Oriental())
  238. {
  239. return "asianSkin";
  240. }
  241. else if (skinID == SkinColor.Black())
  242. {
  243. return "blackSkin";
  244. }
  245. else if (skinID == SkinColor.Brown())
  246. {
  247. return "brownSkin";
  248. }
  249. else if (skinID == SkinColor.Pale())
  250. {
  251. return "snowSkin";
  252. }
  253. else
  254. {
  255. return "If you see this there is an improper skin id for this person.";
  256. }
  257. }
  258. }
  259. #endregion
  260.  
  261. #region Eye Color Class
  262. public static class EyeColor
  263. {
  264. private static int black = 0;
  265. private static int brown = 1;
  266. private static int blue = 2;
  267. private static int cyan = 3;
  268. private static int lightBrown = 4;
  269. private static int yellow = 5;
  270. private static int red = 6;
  271. private static int purple = 6;
  272. private static int orange = 8;
  273. private static int white = 9;
  274.  
  275. public static int Black()
  276. {
  277. return black;
  278. }
  279.  
  280. public static int Brown()
  281. {
  282. return brown;
  283. }
  284.  
  285. public static int Blue()
  286. {
  287. return blue;
  288. }
  289.  
  290. public static int Cyan()
  291. {
  292. return cyan;
  293. }
  294.  
  295. public static int LightBrown()
  296. {
  297. return lightBrown;
  298. }
  299.  
  300. public static int Yellow()
  301. {
  302. return yellow;
  303. }
  304.  
  305. public static int Red()
  306. {
  307. return red;
  308. }
  309.  
  310. public static int Purple()
  311. {
  312. return purple;
  313. }
  314.  
  315. public static int Orange()
  316. {
  317. return orange;
  318. }
  319.  
  320. public static int White()
  321. {
  322. return white;
  323. }
  324. }
  325. #endregion
  326.  
  327. #region Eye Color Return Material Class
  328. public static class EyeMaterial
  329. {
  330. public static string get(int eyeID)
  331. {
  332. if (eyeID == EyeColor.Black())
  333. {
  334. return "blackEyes";
  335. }
  336. else if (eyeID == EyeColor.Blue())
  337. {
  338. return "blueEyes";
  339. }
  340. else if (eyeID == EyeColor.Brown())
  341. {
  342. return "brownEyes";
  343. }
  344. else if (eyeID == EyeColor.Cyan())
  345. {
  346. return "cyanEyes";
  347. }
  348. else if (eyeID == EyeColor.LightBrown())
  349. {
  350. return "lightBrownEyes";
  351. }
  352. else if (eyeID == EyeColor.Orange())
  353. {
  354. return "orangeEyes";
  355. }
  356. else if (eyeID == EyeColor.Purple())
  357. {
  358. return "purpleEyes";
  359. }
  360. else if (eyeID == EyeColor.Red())
  361. {
  362. return "redEyes";
  363. }
  364. else if (eyeID == EyeColor.White())
  365. {
  366. return "whiteEyes";
  367. }
  368. else if (eyeID == EyeColor.Yellow())
  369. {
  370. return "yellowEyes";
  371. }
  372. else
  373. {
  374. return "If you see this there is an error getting a materal for someone's eyes!";
  375. }
  376. }
  377. }
  378. #endregion
  379.  
  380. #region Hair Color Class
  381. public static class HairColor
  382. {
  383. private static int white = 0;
  384. private static int red = 1;
  385. private static int black = 2;
  386. private static int blond = 3;
  387. private static int brown = 4;
  388. private static int lightBrown = 5;
  389. //etc etc
  390. }
  391. #endregion
  392.  
  393. #region Item Classes
  394. public static class EqupipableID
  395. {
  396. //to be filled with items
  397. }
  398.  
  399. public class Equipable
  400. {
  401. //this is for what slot the item is equipable in, if it is equpipable. These are the slots.
  402. /*
  403. * 0 = no slot/not equipable
  404. * 1 = right hand
  405. * 2 = left hand
  406. * 3 = ammo
  407. * 4 = feet
  408. * 5 = feet&legs
  409. * 6 = legs
  410. * 7 = torso
  411. * 8 = torso&arms
  412. * 9 = torso&legs&arms
  413. * 10 = arms
  414. * 11 = hands
  415. * 12 = hands&arms
  416. * 14 = head
  417. * 14 = finger
  418. * 15 = neck
  419. */
  420. private int slot;
  421.  
  422. //item id
  423. private int ID;
  424.  
  425. private int damageType;
  426.  
  427. //etc will finish later
  428. }
  429. #endregion
  430.  
  431.  
  432.  
  433. public class Person : MonoBehaviour {
  434.  
  435. //lets link to the frame object, which is the base for all persons.
  436. public GameObject person;
  437.  
  438. //this is false to tell the game to setup the char
  439. private bool setupDone = false;
  440. private bool setupFailed = false;
  441.  
  442. //this is a value that increments with each new person in the current scene. it is used to differentiate between them.
  443. private static int personID_no = 0;
  444. private int personID;
  445.  
  446. //this is where the gender value is stored (call using Gender.male or Gender.female)
  447. private int gender;
  448.  
  449. //this is where the skin color is stored (call using SkinColor.Caucasian etc)
  450. private int skinColor;
  451.  
  452. //eye color (EyeColor.brown etc)
  453. private int eyeColor;
  454.  
  455. //hair color (HairColor.brown etc)
  456. private int hairColor;
  457.  
  458. //hair style (HairStyle.shaved etc)
  459. private int hairStyle;
  460.  
  461. //item slots
  462. private int[] slots = new int[16];
  463.  
  464. //start location
  465. private Vector3 startLocation;
  466. private Vector3 startRotation;
  467.  
  468. //storage
  469. private GameObject Person_cur;
  470. private GameObject head;
  471. private GameObject ears;
  472. private GameObject mouth;
  473. private GameObject arms;
  474. private GameObject hands;
  475. private GameObject feet;
  476. private GameObject legs;
  477. private GameObject tongue;
  478. private GameObject eyes;
  479. private GameObject torso;
  480.  
  481. private GameObject headPrefab;
  482. private GameObject earsPrefab;
  483. private GameObject mouthPrefab;
  484. private GameObject armsPrefab;
  485. private GameObject handsPrefab;
  486. private GameObject feetPrefab;
  487. private GameObject legsPrefab;
  488. private GameObject tonguePrefab;
  489. private GameObject eyesPrefab;
  490. private GameObject torsoPrefab;
  491.  
  492.  
  493. private GameObject[] slotObjects = new GameObject[16];
  494. private GameObject[] slotObjectsPrefabs = new GameObject[16];
  495.  
  496. //building variables
  497. private Material eyeMaterial;
  498. private Material skinMaterial;
  499. private Material tongueMaterial;
  500. private Material mouthMaterial;
  501.  
  502. private string headString;
  503. private string eyeString;
  504. private string tongueString;
  505. private string mouthString;
  506. private string armsString;
  507. private string legsString;
  508. private string earString;
  509. private string handString;
  510. private string torsoString;
  511. private string feetString;
  512.  
  513. /////////////////////////////////////////////////////////////////////////////
  514. //CONSTRUCTORS
  515. /////////////////////////////////////////////////////////////////////////////
  516.  
  517. public Person(int gender, int skinColor, int eyeColor, int hairColor, int hairStyle, int slot0, int slot1, int slot2, int slot3,
  518. int slot4, int slot5, int slot6, int slot7, int slot8, int slot9, int slot10, int slot11, int slot12, int slot13, int slot14, int slot15, Vector3 startLocation, Vector3 startRotation)
  519. {
  520. personID = personID_no;
  521. personID_no++;
  522.  
  523. this.gender = gender;
  524. this.skinColor = skinColor;
  525. this.eyeColor = eyeColor;
  526. this.hairColor = hairColor;
  527. this.hairStyle = hairStyle;
  528.  
  529. slots[0] = slot0;
  530. slots[1] = slot1;
  531. slots[2] = slot2;
  532. slots[3] = slot3;
  533. slots[4] = slot4;
  534. slots[5] = slot5;
  535. slots[6] = slot6;
  536. slots[7] = slot7;
  537. slots[8] = slot8;
  538. slots[9] = slot9;
  539. slots[10] = slot10;
  540. slots[11] = slot11;
  541. slots[12] = slot12;
  542. slots[13] = slot13;
  543. slots[14] = slot14;
  544. slots[15] = slot15;
  545.  
  546. this.startLocation = startLocation;
  547. this.startRotation = startRotation;
  548. this.startRotation.x = 0;
  549. this.startRotation.z = 0;
  550. setupFailed = buildPerson();
  551.  
  552. }
  553.  
  554. #region Build Method
  555. private bool buildPerson()
  556. {
  557. bool not_done = true;
  558.  
  559. Person_cur = Instantiate(person);
  560. Person_cur.transform.Translate(startLocation);
  561. Person_cur.transform.Rotate(startRotation);
  562.  
  563. bool empty = true;
  564. //check if all slots are empty, if so build a naked
  565. for (int cur_slot = 0; cur_slot < 16; cur_slot ++)
  566. {
  567. if (slots[cur_slot] != -4)
  568. {
  569. empty = false;
  570. }
  571. }
  572. if (empty == false) //lets build a naked guy/gal!
  573. {
  574. //first lets get the mats sorted
  575. eyeMaterial = (Material)Resources.Load("Materials/Eyes/" + EyeMaterial.get(eyeColor), typeof(Material));
  576. skinMaterial = (Material)Resources.Load("Materials/Skin/" + SkinMaterial.get(skinColor), typeof(Material));
  577. tongueMaterial = (Material)Resources.Load("Materials/Skin/tongue", typeof(Material));
  578. mouthMaterial = (Material)Resources.Load("Materials/Mouth/mouth", typeof(Material));
  579.  
  580. //now lets get the base models sorted
  581. headString = BodyPart.Head(gender);
  582. eyeString = BodyPart.Eyes(gender);
  583. tongueString = BodyPart.Tongue(gender);
  584. mouthString = BodyPart.Mouth(gender);
  585. armsString = BodyPart.Arms(gender);
  586. legsString = BodyPart.Legs(gender);
  587. earString = BodyPart.Ears(gender);
  588. handString = BodyPart.Hands(gender);
  589. torsoString = BodyPart.Torso(gender);
  590. feetString = BodyPart.Feet(gender);
  591.  
  592.  
  593.  
  594. //ears
  595.  
  596. earsPrefab = (GameObject)Resources.Load(earString, typeof(GameObject));
  597. ears = Instantiate(earsPrefab);
  598. ears.transform.parent = Person_cur.transform;
  599. ears.transform.Translate(startLocation);
  600. ears.transform.Rotate(startRotation);
  601. ears.GetComponent<Renderer>().sharedMaterial = skinMaterial;
  602.  
  603. //head
  604.  
  605. headPrefab = (GameObject)Resources.Load(headString, typeof(GameObject));
  606. head = Instantiate(headPrefab);
  607. head.transform.parent = Person_cur.transform;
  608. head.transform.Translate(startLocation);
  609. head.transform.Rotate(startRotation);
  610. head.GetComponent<Renderer>().sharedMaterial = skinMaterial;
  611.  
  612. //torso
  613.  
  614. torsoPrefab = (GameObject)Resources.Load(torsoString, typeof(GameObject));
  615. torso = Instantiate(torsoPrefab);
  616. torso.transform.parent = Person_cur.transform;
  617. torso.transform.Translate(startLocation);
  618. torso.transform.Rotate(startRotation);
  619. torso.GetComponent<Renderer>().sharedMaterial = skinMaterial;
  620.  
  621. //arms
  622.  
  623. armsPrefab = (GameObject)Resources.Load(armsString, typeof(GameObject));
  624. arms = Instantiate(armsPrefab);
  625. arms.transform.parent = Person_cur.transform;
  626. arms.transform.Translate(startLocation);
  627. arms.transform.Rotate(startRotation);
  628. arms.GetComponent<Renderer>().sharedMaterial = skinMaterial;
  629.  
  630. //hands
  631.  
  632. handsPrefab = (GameObject)Resources.Load(handString, typeof(GameObject));
  633. hands = Instantiate(handsPrefab);
  634. hands.transform.parent = Person_cur.transform;
  635. hands.transform.Translate(startLocation);
  636. hands.transform.Rotate(startRotation);
  637. hands.GetComponent<Renderer>().sharedMaterial = skinMaterial;
  638.  
  639. //legs
  640.  
  641. legsPrefab = (GameObject)Resources.Load(legsString, typeof(GameObject));
  642. legs = Instantiate(legsPrefab);
  643. legs.transform.parent = Person_cur.transform;
  644. legs.transform.Translate(startLocation);
  645. legs.transform.Rotate(startRotation);
  646. legs.GetComponent<Renderer>().sharedMaterial = skinMaterial;
  647.  
  648. //feet
  649.  
  650. feetPrefab = (GameObject)Resources.Load(feetString, typeof(GameObject));
  651. feet = Instantiate(feetPrefab);
  652. feet.transform.parent = Person_cur.transform;
  653. feet.transform.Translate(startLocation);
  654. feet.transform.Rotate(startRotation);
  655. feet.GetComponent<Renderer>().sharedMaterial = skinMaterial;
  656.  
  657. //mouth
  658.  
  659. mouthPrefab = (GameObject)Resources.Load(mouthString, typeof(GameObject));
  660. mouth = Instantiate(mouthPrefab);
  661. mouth.transform.parent = Person_cur.transform;
  662. mouth.transform.Translate(startLocation);
  663. mouth.transform.Rotate(startRotation);
  664. mouth.GetComponent<Renderer>().sharedMaterial = mouthMaterial;
  665.  
  666. //tongue
  667.  
  668. tonguePrefab = (GameObject)Resources.Load(tongueString, typeof(GameObject));
  669. tongue = Instantiate(tonguePrefab);
  670. tongue.transform.parent = Person_cur.transform;
  671. tongue.transform.Translate(startLocation);
  672. tongue.transform.Rotate(startRotation);
  673. tongue.GetComponent<Renderer>().sharedMaterial = tongueMaterial;
  674.  
  675. //eyes
  676. eyesPrefab = (GameObject)Resources.Load(eyeString, typeof(GameObject));
  677. eyes = Instantiate(eyesPrefab);
  678. eyes.transform.parent = Person_cur.transform;
  679. eyes.transform.Translate(startLocation);
  680. eyes.transform.Rotate(startRotation);
  681. tongue.GetComponent<Renderer>().sharedMaterial = eyeMaterial;
  682.  
  683. not_done = false;
  684. }
  685. else //lets sort out its slots
  686. {
  687.  
  688. }
  689.  
  690. return not_done;
  691.  
  692. }
  693. #endregion
  694.  
  695. }
Advertisement
Add Comment
Please, Sign In to add comment