public static void CreateNPC(GameObject myObj, string NPC_ID, string EditorSprite ,int npc_whoami)
{
myObj.layer=LayerMask.NameToLayer("NPCs");
myObj.tag="NPCs";
GameObject myInstance = Resources.Load("AI_PREFABS/AI_LAND") as GameObject;
GameObject newObj = (GameObject)GameObject.Instantiate(myInstance);
newObj.name = myObj.name + "_AI";
newObj.transform.position=Vector3.zero; //new Vector3(0,0,0);
newObj.transform.parent=myObj.transform;
newObj.transform.localPosition=Vector3.zero; //new Vector3(0,0,0);
AIRig ai = newObj.GetComponent<AIRig>();
ai.AI.Body=myObj;
NPC npc = myObj.AddComponent<NPC>();
npc.NPC_ID=NPC_ID;
if (npc_whoami == 0)
{
npc.npc_whoami=256+(int.Parse (NPC_ID) -64);
}
//Probably only need to add this when an NPC supports ranged attacks?
GameObject NpcLauncher = new GameObject("NPC_Launcher");
NpcLauncher.transform.position=Vector3.zero;
NpcLauncher.transform.parent=myObj.transform;
NpcLauncher.transform.localPosition=new Vector3(0.0f,0.5f,0.1f);
npc.NPC_Launcher=NpcLauncher;
myInstance = Resources.Load(_RES + "/animation/" + _RES + "_Base_Animator") as GameObject;
newObj = (GameObject)GameObject.Instantiate(myInstance);
newObj.name=myObj.name + "_Sprite";
newObj.transform.parent=myObj.transform;
newObj.transform.position = myObj.transform.position;
SpriteRenderer mysprite = newObj.GetComponent<SpriteRenderer>();
Sprite image = Resources.Load <Sprite> (EditorSprite);//Loads the sprite.
mysprite.material= Resources.Load<Material>("Materials/SpriteShader");
mysprite.sprite = image;//Assigns the sprite to the object.
CharacterController cap = myObj.GetComponent<CharacterController>();
if (cap==null)
{
cap=myObj.GetComponent<CharacterController>();
}
switch(int.Parse(NPC_ID))
{
case 97: //a_ghost
case 99: //a_ghoul
case 100: //a_ghost
case 101: //a_ghost
case 105: //a_dark_ghoul
case 110: //a_ghoul
case 113: //a_dire_ghost
npc.isUndead=true;
break;
}
switch (int.Parse(NPC_ID))
{
//Big
case 70: //a_goblin
case 71: //a_goblin
case 74: //a_skeleton
case 76: //a_goblin
case 77: //a_goblin
case 78: //a_goblin
case 79: //etherealvoidcreatures
case 80: //a_goblin
case 84: //a_mountainman_mountainmen
case 85: //a_green_lizardman_green_lizardmen
case 86: //a_mountainman_mountainmen
case 88: //a_red_lizardman_red_lizardmen
case 89: //a_gray_lizardman_red_lizardmen
case 90: //an_outcast
case 91: //a_headless_headlesses
case 93: //a_fighter
case 94: //a_fighter
case 95: //a_fighter
case 96: //a_troll
case 97: //a_ghost
case 98: //a_fighter
case 99: //a_ghoul
case 100: //a_ghost
case 101: //a_ghost
case 103: //a_mage
case 104: //a_fighter
case 105: //a_dark_ghoul
case 106: //a_mage
case 107: //a_mage
case 108: //a_mage
case 109: //a_mage
case 110: //a_ghoul
case 111: //a_feral_troll
case 112: //a_great_troll
case 113: //a_dire_ghost
case 114: //an_earth_golem
case 115: //a_mage
case 116: //a_deep_lurker
case 117: //a_shadow_beast
case 118: //a_reaper
case 119: //a_stone_golem
case 120: //a_fire_elemental
case 121: //a_metal_golem
case 123: //tybal
case 124: //slasher_of_veils
case 125: //unknown
case 126: //unknown
cap.isTrigger=false;
cap.center = new Vector3(0.0f, 0.4f, 0.0f);
cap.radius=0.2f;
cap.height=0.8f;
break;
//Medium
case 68: //a_giant_spider
case 67: //a_giant_rat
case 72: //a_giant_rat
case 75: //an_imp
case 81: //a_mongbat
case 83: //a_wolf_spider
case 92: //a_dread_spider
case 102: //a_gazer
cap.isTrigger=false;
cap.center = new Vector3(0.0f, 0.5f, 0.0f);
cap.radius=0.5f;
cap.height=0.5f;
break;
//Small
case 64: //a_rotworm
case 65: //a_flesh_slug
case 66: //a_cave_bat
case 69: //a_acid_slug
case 73: //a_vampire_bat
case 82: //a_bloodworm
case 87: //a_lurker
case 122: //a_wisp
cap.isTrigger=false;
cap.center = new Vector3(0.0f, 0.3f, 0.0f);
cap.radius=0.3f;
cap.height=0.3f;
break;
}
}