Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using UnityEngine;
- using System.Collections;
- #region Gender Class
- public static class Gender
- {
- private static int male = 1;
- private static int female = 0;
- public static int Male()
- {
- return male;
- }
- public static int Female()
- {
- return female;
- }
- }
- #endregion
- #region Body Parts Return Class
- public class BodyPart
- {
- public static string Head(int genderID)
- {
- if (genderID == Gender.Male())
- {
- return "maleHead";
- }
- else if (genderID == Gender.Female())
- {
- return "femaleHead";
- }
- else
- {
- return "If you see this there is no gender of this person.";
- }
- }
- public static string Arms(int genderID)
- {
- if (genderID == Gender.Male())
- {
- return "maleArms";
- }
- else if (genderID == Gender.Female())
- {
- return "femaleArms";
- }
- else
- {
- return "If you see this there is no gender of this person.";
- }
- }
- public static string Legs(int genderID)
- {
- if (genderID == Gender.Male())
- {
- return "maleLegs";
- }
- else if (genderID == Gender.Female())
- {
- return "femaleLegs";
- }
- else
- {
- return "If you see this there is no gender of this person.";
- }
- }
- public static string Torso(int genderID)
- {
- if (genderID == Gender.Male())
- {
- return "maleTorso";
- }
- else if (genderID == Gender.Female())
- {
- return "femaleTorso";
- }
- else
- {
- return "If you see this there is no gender of this person.";
- }
- }
- public static string Hands(int genderID)
- {
- if (genderID == Gender.Male())
- {
- return "maleHands";
- }
- else if (genderID == Gender.Female())
- {
- return "femaleHands";
- }
- else
- {
- return "If you see this there is no gender of this person.";
- }
- }
- public static string Feet(int genderID)
- {
- if (genderID == Gender.Male())
- {
- return "maleFeet";
- }
- else if (genderID == Gender.Female())
- {
- return "femaleFeet";
- }
- else
- {
- return "If you see this there is no gender of this person.";
- }
- }
- public static string Ears(int genderID)
- {
- if (genderID == Gender.Male())
- {
- return "maleEars";
- }
- else if (genderID == Gender.Female())
- {
- return "femaleEars";
- }
- else
- {
- return "If you see this there is no gender of this person.";
- }
- }
- public static string Mouth(int genderID)
- {
- if (genderID == Gender.Male())
- {
- return "maleMouth";
- }
- else if (genderID == Gender.Female())
- {
- return "femaleMouth";
- }
- else
- {
- return "If you see this there is no gender of this person.";
- }
- }
- public static string Eyes(int genderID)
- {
- if (genderID == Gender.Male())
- {
- return "maleEyes";
- }
- else if (genderID == Gender.Female())
- {
- return "femaleEyes";
- }
- else
- {
- return "If you see this there is no gender of this person.";
- }
- }
- public static string Tongue(int genderID)
- {
- if (genderID == Gender.Male())
- {
- return "maleTongue";
- }
- else if (genderID == Gender.Female())
- {
- return "femaleTongue";
- }
- else
- {
- return "If you see this there is no gender of this person.";
- }
- }
- }
- #endregion
- #region Skin Color Class
- public static class SkinColor
- {
- private static int caucasian = 0;
- private static int black = 1;
- private static int brown = 2;
- private static int arabian = 3;
- private static int oriental = 4;
- private static int pale = 5;
- public static int Caucasian()
- {
- return caucasian;
- }
- public static int Black()
- {
- return black;
- }
- public static int Brown()
- {
- return brown;
- }
- public static int Arabian()
- {
- return arabian;
- }
- public static int Oriental()
- {
- return oriental;
- }
- public static int Pale()
- {
- return pale;
- }
- //etc etc
- }
- #endregion
- #region Skin Color Return Material Class
- public static class SkinMaterial
- {
- public static string get(int skinID)
- {
- if (skinID == SkinColor.Caucasian())
- {
- return "whiteSkin";
- }
- else if (skinID == SkinColor.Arabian())
- {
- return "bronzeSkin";
- }
- else if (skinID == SkinColor.Oriental())
- {
- return "asianSkin";
- }
- else if (skinID == SkinColor.Black())
- {
- return "blackSkin";
- }
- else if (skinID == SkinColor.Brown())
- {
- return "brownSkin";
- }
- else if (skinID == SkinColor.Pale())
- {
- return "snowSkin";
- }
- else
- {
- return "If you see this there is an improper skin id for this person.";
- }
- }
- }
- #endregion
- #region Eye Color Class
- public static class EyeColor
- {
- private static int black = 0;
- private static int brown = 1;
- private static int blue = 2;
- private static int cyan = 3;
- private static int lightBrown = 4;
- private static int yellow = 5;
- private static int red = 6;
- private static int purple = 6;
- private static int orange = 8;
- private static int white = 9;
- public static int Black()
- {
- return black;
- }
- public static int Brown()
- {
- return brown;
- }
- public static int Blue()
- {
- return blue;
- }
- public static int Cyan()
- {
- return cyan;
- }
- public static int LightBrown()
- {
- return lightBrown;
- }
- public static int Yellow()
- {
- return yellow;
- }
- public static int Red()
- {
- return red;
- }
- public static int Purple()
- {
- return purple;
- }
- public static int Orange()
- {
- return orange;
- }
- public static int White()
- {
- return white;
- }
- }
- #endregion
- #region Eye Color Return Material Class
- public static class EyeMaterial
- {
- public static string get(int eyeID)
- {
- if (eyeID == EyeColor.Black())
- {
- return "blackEyes";
- }
- else if (eyeID == EyeColor.Blue())
- {
- return "blueEyes";
- }
- else if (eyeID == EyeColor.Brown())
- {
- return "brownEyes";
- }
- else if (eyeID == EyeColor.Cyan())
- {
- return "cyanEyes";
- }
- else if (eyeID == EyeColor.LightBrown())
- {
- return "lightBrownEyes";
- }
- else if (eyeID == EyeColor.Orange())
- {
- return "orangeEyes";
- }
- else if (eyeID == EyeColor.Purple())
- {
- return "purpleEyes";
- }
- else if (eyeID == EyeColor.Red())
- {
- return "redEyes";
- }
- else if (eyeID == EyeColor.White())
- {
- return "whiteEyes";
- }
- else if (eyeID == EyeColor.Yellow())
- {
- return "yellowEyes";
- }
- else
- {
- return "If you see this there is an error getting a materal for someone's eyes!";
- }
- }
- }
- #endregion
- #region Hair Color Class
- public static class HairColor
- {
- private static int white = 0;
- private static int red = 1;
- private static int black = 2;
- private static int blond = 3;
- private static int brown = 4;
- private static int lightBrown = 5;
- //etc etc
- }
- #endregion
- #region Item Classes
- public static class EqupipableID
- {
- //to be filled with items
- }
- public class Equipable
- {
- //this is for what slot the item is equipable in, if it is equpipable. These are the slots.
- /*
- * 0 = no slot/not equipable
- * 1 = right hand
- * 2 = left hand
- * 3 = ammo
- * 4 = feet
- * 5 = feet&legs
- * 6 = legs
- * 7 = torso
- * 8 = torso&arms
- * 9 = torso&legs&arms
- * 10 = arms
- * 11 = hands
- * 12 = hands&arms
- * 14 = head
- * 14 = finger
- * 15 = neck
- */
- private int slot;
- //item id
- private int ID;
- private int damageType;
- //etc will finish later
- }
- #endregion
- public class Person : MonoBehaviour {
- //lets link to the frame object, which is the base for all persons.
- public GameObject person;
- //this is false to tell the game to setup the char
- private bool setupDone = false;
- private bool setupFailed = false;
- //this is a value that increments with each new person in the current scene. it is used to differentiate between them.
- private static int personID_no = 0;
- private int personID;
- //this is where the gender value is stored (call using Gender.male or Gender.female)
- private int gender;
- //this is where the skin color is stored (call using SkinColor.Caucasian etc)
- private int skinColor;
- //eye color (EyeColor.brown etc)
- private int eyeColor;
- //hair color (HairColor.brown etc)
- private int hairColor;
- //hair style (HairStyle.shaved etc)
- private int hairStyle;
- //item slots
- private int[] slots = new int[16];
- //start location
- private GameObject spawner;
- //storage
- private GameObject Person_cur;
- private GameObject head;
- private GameObject ears;
- private GameObject mouth;
- private GameObject arms;
- private GameObject hands;
- private GameObject feet;
- private GameObject legs;
- private GameObject tongue;
- private GameObject eyes;
- private GameObject torso;
- private GameObject headPrefab;
- private GameObject earsPrefab;
- private GameObject mouthPrefab;
- private GameObject armsPrefab;
- private GameObject handsPrefab;
- private GameObject feetPrefab;
- private GameObject legsPrefab;
- private GameObject tonguePrefab;
- private GameObject eyesPrefab;
- private GameObject torsoPrefab;
- private GameObject[] slotObjects = new GameObject[16];
- private GameObject[] slotObjectsPrefabs = new GameObject[16];
- //building variables
- private Material eyeMaterial;
- private Material skinMaterial;
- private Material tongueMaterial;
- private Material mouthMaterial;
- private string headString;
- private string eyeString;
- private string tongueString;
- private string mouthString;
- private string armsString;
- private string legsString;
- private string earString;
- private string handString;
- private string torsoString;
- private string feetString;
- /////////////////////////////////////////////////////////////////////////////
- //CONSTRUCTORS
- /////////////////////////////////////////////////////////////////////////////
- public Person(int gender, int skinColor, int eyeColor, int hairColor, int hairStyle, int slot0, int slot1, int slot2, int slot3,
- int slot4, int slot5, int slot6, int slot7, int slot8, int slot9, int slot10, int slot11, int slot12, int slot13, int slot14, int slot15, GameObject spawner)
- {
- personID = personID_no;
- personID_no++;
- this.gender = gender;
- this.skinColor = skinColor;
- this.eyeColor = eyeColor;
- this.hairColor = hairColor;
- this.hairStyle = hairStyle;
- slots[0] = slot0;
- slots[1] = slot1;
- slots[2] = slot2;
- slots[3] = slot3;
- slots[4] = slot4;
- slots[5] = slot5;
- slots[6] = slot6;
- slots[7] = slot7;
- slots[8] = slot8;
- slots[9] = slot9;
- slots[10] = slot10;
- slots[11] = slot11;
- slots[12] = slot12;
- slots[13] = slot13;
- slots[14] = slot14;
- slots[15] = slot15;
- this.spawner = spawner;
- setupFailed = buildPerson();
- }
- #region Build Method
- private bool buildPerson()
- {
- bool not_done = true;
- Person_cur = (GameObject)Instantiate(person,spawner.transform.position, spawner.transform.rotation);
- bool empty = true;
- //check if all slots are empty, if so build a naked
- for (int cur_slot = 0; cur_slot < 16; cur_slot ++)
- {
- if (slots[cur_slot] != -4)
- {
- empty = false;
- }
- }
- if (empty == false) //lets build a naked guy/gal!
- {
- //first lets get the mats sorted
- eyeMaterial = (Material)Resources.Load("Materials/Eyes/" + EyeMaterial.get(eyeColor), typeof(Material));
- skinMaterial = (Material)Resources.Load("Materials/Skin/" + SkinMaterial.get(skinColor), typeof(Material));
- tongueMaterial = (Material)Resources.Load("Materials/Skin/tongue", typeof(Material));
- mouthMaterial = (Material)Resources.Load("Materials/Mouth/mouth", typeof(Material));
- //now lets get the base models sorted
- headString = BodyPart.Head(gender);
- eyeString = BodyPart.Eyes(gender);
- tongueString = BodyPart.Tongue(gender);
- mouthString = BodyPart.Mouth(gender);
- armsString = BodyPart.Arms(gender);
- legsString = BodyPart.Legs(gender);
- earString = BodyPart.Ears(gender);
- handString = BodyPart.Hands(gender);
- torsoString = BodyPart.Torso(gender);
- feetString = BodyPart.Feet(gender);
- //ears
- earsPrefab = (GameObject)Resources.Load(earString, typeof(GameObject));
- ears = (GameObject)Instantiate(earsPrefab, spawner.transform.position, spawner.transform.rotation);
- ears.transform.parent = Person_cur.transform;
- ears.GetComponent<Renderer>().sharedMaterial = skinMaterial;
- //head
- headPrefab = (GameObject)Resources.Load(headString, typeof(GameObject));
- head = (GameObject)Instantiate(headPrefab, spawner.transform.position, spawner.transform.rotation);
- head.transform.parent = Person_cur.transform;
- head.GetComponent<Renderer>().sharedMaterial = skinMaterial;
- //torso
- torsoPrefab = (GameObject)Resources.Load(torsoString, typeof(GameObject));
- torso = (GameObject)Instantiate(torsoPrefab, spawner.transform.position, spawner.transform.rotation);
- torso.transform.parent = Person_cur.transform;
- torso.GetComponent<Renderer>().sharedMaterial = skinMaterial;
- //arms
- armsPrefab = (GameObject)Resources.Load(armsString, typeof(GameObject));
- arms = (GameObject)Instantiate(armsPrefab, spawner.transform.position, spawner.transform.rotation);
- arms.transform.parent = Person_cur.transform;
- arms.GetComponent<Renderer>().sharedMaterial = skinMaterial;
- //hands
- handsPrefab = (GameObject)Resources.Load(handString, typeof(GameObject));
- hands = (GameObject)Instantiate(handsPrefab, spawner.transform.position, spawner.transform.rotation);
- hands.transform.parent = Person_cur.transform;
- hands.GetComponent<Renderer>().sharedMaterial = skinMaterial;
- //legs
- legsPrefab = (GameObject)Resources.Load(legsString, typeof(GameObject));
- legs = (GameObject)Instantiate(legsPrefab, spawner.transform.position, spawner.transform.rotation);
- legs.transform.parent = Person_cur.transform;
- legs.GetComponent<Renderer>().sharedMaterial = skinMaterial;
- //feet
- feetPrefab = (GameObject)Resources.Load(feetString, typeof(GameObject));
- feet = (GameObject)Instantiate(feetPrefab, spawner.transform.position, spawner.transform.rotation);
- feet.transform.parent = Person_cur.transform;
- feet.GetComponent<Renderer>().sharedMaterial = skinMaterial;
- //mouth
- mouthPrefab = (GameObject)Resources.Load(mouthString, typeof(GameObject));
- mouth = (GameObject)Instantiate(mouthPrefab, spawner.transform.position, spawner.transform.rotation);
- mouth.transform.parent = Person_cur.transform;
- mouth.GetComponent<Renderer>().sharedMaterial = mouthMaterial;
- //tongue
- tonguePrefab = (GameObject)Resources.Load(tongueString, typeof(GameObject));
- tongue = (GameObject)Instantiate(tonguePrefab, spawner.transform.position, spawner.transform.rotation);
- tongue.transform.parent = Person_cur.transform;
- tongue.GetComponent<Renderer>().sharedMaterial = tongueMaterial;
- //eyes
- eyesPrefab = (GameObject)Resources.Load(eyeString, typeof(GameObject));
- eyes = Instantiate(eyesPrefab);
- eyes.transform.parent = Person_cur.transform;
- tongue.GetComponent<Renderer>().sharedMaterial = eyeMaterial;
- not_done = false;
- }
- else //lets sort out its slots
- {
- }
- return not_done;
- }
- #endregion
- }
Advertisement
Add Comment
Please, Sign In to add comment