// Update is called once per frame void Update() { if (player.GetComponent <Health>().getHealth() <= 0 && MetaScript.GetNPC().getCount() == 0) { gameEnds(); } }
private void starving() { foreach (var aNPC in MetaScript.GetNPC().getNPCs().ToArray()) { if (aNPC != null) { aNPC.GetComponent <Health> ().damage(damageForStarving); } } }
/// <summary> /// Generates the UI for the NPC's. /// </summary> private void generateUI() { GameObject tempGameObject; foreach (var theNPC in MetaScript.GetNPC().getNPCs()) { tempGameObject = Instantiate(Button_Template) as GameObject; tempGameObject.SetActive(true); mainDisplay aButtonScript = tempGameObject.GetComponent <mainDisplay> (); aButtonScript.setNPC(theNPC); tempGameObject.transform.SetParent(mainDisplayContent.transform, false); } }
/// <summary> /// Converts NPC to be an owned NPC and immediately starts gathering wood /// </summary> public void TakeSoul() { MetaScript.GetNPC().addNPC(gameObject); gameObject.tag = "OwnedNPC"; //teleport to town transform.position = MetaScript.getTownCenter().transform.position + new Vector3(0.5f, 0, 0); transform.SetParent(MetaScript.getMetaObject().transform); gameObject.GetComponent <collect>().enabled = true; gameObject.GetComponent <collect>().startCollecting(ResourceTypes.WOOD); Destroy(this); //GetComponent<NavMeshAgent>().enabled = true; }
void Start() { starvingTickTimer = GameObject.Find("Calendar").GetComponent <GameTime>().dayTime; resourceManager = MetaScript.getRes(); allUIGameObjects = GameObject.Find("AllUIObjectsCanvas"); npcManagerGameObject = allUIGameObjects.transform.GetChild(0).GetChild(0).gameObject; setNPCList(MetaScript.GetNPC()); player = GameObject.FindGameObjectWithTag("Player"); buffSystem = new BuffSystem(); noFood = false; //StartCoroutine (starvingTimer (starvingTickTimer)); }
// Update is called once per frame void Update() { timeSinceLastRenewal += Time.deltaTime; if (timeSinceLastRenewal >= slowRenewalTime) { timeSinceLastRenewal = 0; slow(player); List <GameObject> NPCs = MetaScript.GetNPC().getNPCs(); for (int i = 0; i < NPCs.Count; i++) { slow(NPCs[i]); } } }
public void death() { if (CompareTag("OwnedNPC")) { Debug.Log("An NPC has died"); MetaScript.GetNPC().removeNPC(gameObject); MetaScript.Tomb(transform.position, name); } if (CompareTag("Player")) { Debug.Log("The player has died"); StartCoroutine(PerformRitual()); } else { Destroy(gameObject); } }
void Update() { if (keyDown(Follow)) { guards = false; foreach (GameObject npc in MetaScript.GetNPC().getNPCs().ToArray()) { if (npc != null) { npc.GetComponent <collect>().enabled = true; npc.GetComponent <Guard>().enabled = false; npc.GetComponent <follow>().enabled = false; } } } if (keyDown(Guard)) { guards = true; foreach (GameObject npc in MetaScript.GetNPC().getNPCs().ToArray()) { if (npc != null) { npc.GetComponent <collect>().enabled = false; npc.GetComponent <Guard>().enabled = true; npc.GetComponent <follow>().enabled = false; } } } if (keyDown(Collect)) { guards = false; foreach (GameObject npc in MetaScript.GetNPC().getNPCs().ToArray()) { if (npc != null) { npc.GetComponent <collect>().enabled = false; npc.GetComponent <Guard>().enabled = false; npc.GetComponent <follow>().enabled = true; } } } }
/// <summary> /// Is the population above a. /// </summary> /// <returns><c>true</c>, if population above was ised, <c>false</c> otherwise.</returns> /// <param name="a">The alpha component.</param> public static bool isPopulationAbove(int a) { return(MetaScript.GetNPC().getCount() >= a); //return 0 >= a; }