void createPathNPC(Vector2 spawnPoint) { GameObject newNPC = createNPC(this.pathNPC, pathAIList, spawnPoint); SubpathScript movePath = GameObject.Find(pathTag).GetComponent <PathingScript> ().getRandomPath().GetComponent <SubpathScript>(); newNPC.GetComponent <PathAIController>().setMovingPath(movePath); GameObject skin; if (Random.Range(0, 2) == 0) { skin = (GameObject)Instantiate(Resources.Load("prefabs/AI/NPCSkinPrefabs/bopper_skin")); newNPC.GetComponent <SpriteRenderer> ().sprite = skin.GetComponent <SpriteRenderer> ().sprite; newNPC.GetComponent <Animator> ().runtimeAnimatorController = skin.GetComponent <Animator> ().runtimeAnimatorController; } else { skin = (GameObject)Instantiate(Resources.Load("prefabs/AI/NPCSkinPrefabs/mower_skin")); newNPC.GetComponent <SpriteRenderer> ().sprite = skin.GetComponent <SpriteRenderer> ().sprite; // NOT functional yet newNPC.GetComponent <Animator> ().runtimeAnimatorController = skin.GetComponent <Animator> ().runtimeAnimatorController; } Destroy(skin); }
private void initMap() { // 3 pathing npcs GameObject[] paths = GameObject.FindGameObjectsWithTag("Path"); for (int i = 0; i < paths.Length; i++) { GameObject path = paths[i]; SubpathScript movePath = path.GetComponent <SubpathScript>(); Vector2 pathPos = movePath.transform.position; createPathNPC(pathPos); //GameObject newPathNPC = createNPC(this.pathNPC, pathAIList, pathPos); //newPathNPC.GetComponent<PathAIController>().setMovingPath(movePath); } //3 bench npcs GameObject[] benches = GameObject.FindGameObjectsWithTag(benchTag); for (int i = 0; i < 3; i++) { int rand = Random.Range(0, benches.Length); GameObject bench = benches[rand]; Vector2 spawnPos = bench.transform.position; GameObject newStationary = createNPC(this.stationaryNPC, stationaryAIList, spawnPos); newStationary.GetComponent <StationaryAIController> ().setStationaryPoint(bench); } }
void createPathNPC(Vector2 spawnPoint, SubpathScript movePath) { GameObject newNPC = createNPC (this.pathNPC, pathAIList, spawnPoint); PathAIController controller = newNPC.GetComponent<PathAIController> (); controller.setMovingPath(movePath); controller.setInMaze (isMaze); if (isMaze) { switch (Random.Range(0,5)) { case 0: loadNPCWithSkin(newNPC, "bopper_skin", NPCSkinType.Bopper); break; case 1: loadNPCWithSkin(newNPC, "hottie_skin", NPCSkinType.Hottie); break; case 2: loadNPCWithSkin(newNPC, "mower_skin", NPCSkinType.MowerMan); break; case 3: loadNPCWithSkin(newNPC, "hippie_skin", NPCSkinType.Hippie); break; case 4: loadNPCWithSkin(newNPC, "oldman_skin", NPCSkinType.OldMan); break; case 5: loadNPCWithSkin(newNPC, "boppina_skin", NPCSkinType.Boppina); break; } } else { if (Random.Range(0,2) == 0) { loadNPCWithSkin(newNPC, "bopper_skin", NPCSkinType.Bopper); } else { loadNPCWithSkin(newNPC, "hottie_skin", NPCSkinType.Hottie); } } }
public void setMovingPath(SubpathScript movePath) { this.movePath = movePath; }
// Shouldn't need to overwrite /* protected override void investigate() { if (nextInvestigateTime <= Time.time) { investigating = false; if (Random.value > 0.5) { GameObject tree = null; int rand = 0; while(tree == null) { if (treeList.Count == 0) break; rand = Random.Range(0, treeList.Count); tree = (GameObject)treeList[rand]; if (tree.Equals(player) && Vector3.Distance(player.transform.position, panickedNPCPosition) > wanderRadius) { tree = null; treeList.RemoveAt(rand); } } if (tree != null) { Vector3 nextTreePosition = tree.transform.position; treeList.RemoveAt(rand); // Remove the tree so it won't be chopped again nextPath.transform.position = new Vector3(nextTreePosition.x, nextTreePosition.y - transform.renderer.bounds.size.y/5); treePath = true; investigatePath = false; checkingPlayer = tree.Equals(player); Debug.Log (checkingPlayer); return; } } //* treePath = false; investigatePath = true; Vector2 position = Random.insideUnitCircle * wanderRadius; nextPath.transform.position = new Vector3(position.x, position.y, 0.0f) + panickedNPCPosition; } } //*/ public void setMovingPath(SubpathScript movePath) { this.movePath = movePath; nextPath = movePath.getNextPath (null, gameObject); initAxeMan (); }