private void Update() { NPCMove(); // El siguiente bloque de código lee la posición de los aldeanos, cuando la distancia es menor al rango, los zombies pasan a perseguirlos. Villagers closest = null; float closestDistance = 5.0f; foreach (var v in FindObjectsOfType <Villagers>()) { float distance = Vector3.Distance(v.transform.position, transform.position); if (distance < closestDistance) { m = Move.Pursuing; closest = v; closestDistance = distance; direction = Vector3.Normalize(v.transform.position - transform.position); transform.position += direction * npcSpeed * Time.deltaTime; } } // El siguiente bloque de código imprime los mensajes cuando el héroe entra en el rango de ataque. float zombieAttack = Vector3.Distance(target.position, transform.position); if (zombieAttack <= 5.0f && closest == null) { StartCoroutine("PrintMessages"); } }
void Update() { if (Input.GetKeyDown(KeyCode.R)) { GameManager.instance.NextLevel(); } if (Input.GetMouseButtonDown(0)) { hitOrigin = Camera.main.ScreenToWorldPoint(Input.mousePosition); colliders = Physics2D.OverlapCircleAll(hitOrigin, 0.25f, villagerLayer); if (colliders != null) { Villagers enemy = gameManager.enemyVillager; for (int i = 0; i < colliders.Length; i++) { if (colliders[i].GetComponent <Villagers>() == enemy) { gameManager.NextLevel(); } else { audioSource.clip = incorrectSelectionSound; audioSource.Play(); gameManager.IncrementStrikes(); colliders[i].GetComponent <Villagers>().BlowUp(); } } } } movementDirection = new Vector2(Input.GetAxisRaw("Horizontal"), Input.GetAxisRaw("Vertical")); movementDirection = movementDirection.normalized; }
IEnumerator PrintMessages(Villagers villager) // Esta Corutina es la que asigna los mensajes de los ciudadanos. { Message.text = villager.PrintNames(); yield return(new WaitForSeconds(3)); Message.text = ""; }
/// <summary> /// Clean up any resources being used. /// </summary> /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param> protected override void Dispose(bool disposing) { if (disposing && (components != null)) { components.Dispose(); Villagers.Dispose(); } base.Dispose(disposing); }
IEnumerator PrintMessages(Villagers villager) // Esta Corutina es la que asigna los mensajes de los ciudadanos. { message.text = villager.Message(); yield return(new WaitForSeconds(3)); message.text = ""; if (Creator.inGame == false) { message.text = ""; } }
public Villager findVillagerByVillagerType(VillagerTypes vType) { Villagers v = new Villagers(); foreach(Villagers vv in villagers) { if(vv.vType == vType) v = vv; } if(v != null) return v.villager.GetComponent<Villager>(); else return null; }
public void SaveVillager(Villager villager) { Villagers.Remove(villager.gameObject); vFollowers.Remove(villager.Follower.gameObject); Followers.Remove(villager); Destroy(villager.Follower.gameObject); Destroy(villager.Follower); Destroy(villager.gameObject); //CreateNewVillager(); savedVillagers++; SavedVillagersText.guiText.text = "Villagers Saved: " + savedVillagers; }
public GameObject findVillagerGameObjectByVillagerType(VillagerTypes vType) { Villagers v = new Villagers(); foreach(Villagers vv in villagers) { if(vv.vType == vType) v = vv; } if(v != null) return v.villager; else return null; }
void OnEnable() { // ? Instantiate what needs to be initiated before game start here. places = Instantiate(placesPrefab, placesOrigin.position, Quaternion.identity).GetComponent <Places>(); villagers = Instantiate(villagersPrefab, villagersOrigin.position, Quaternion.identity).GetComponent <Villagers>(); // ? Link object between them here. gameCanvas.throwDices.onClick.AddListener(new UnityEngine.Events.UnityAction(DicesStep_ThrowDices)); gameCanvas.nextStep.onClick.AddListener(new UnityEngine.Events.UnityAction(NextStep)); gameCanvas.eventOption1.onClick.AddListener(new UnityEngine.Events.UnityAction(NextStep)); gameCanvas.eventOption1.onClick.AddListener(new UnityEngine.Events.UnityAction(() => PickEffect(0))); gameCanvas.eventOption2.onClick.AddListener(new UnityEngine.Events.UnityAction(NextStep)); gameCanvas.eventOption2.onClick.AddListener(new UnityEngine.Events.UnityAction(() => PickEffect(1))); }
void Start() { gameManager = GameManager.instance; int amount = gameManager.GetVillagerAmountToSpawn(); int randomIndex = Random.Range(0, amount); for (int i = 0; i < amount; i++) { Villagers v = Instantiate(villagerPrefab); if (i == randomIndex) { gameManager.enemyVillager = v; } } }
public VillagerNode CreateVillager(string villagerName, Vector3 position) { GameObject newVillager = Instantiate(VillageData.villagerPrefab, position, Quaternion.identity); UtilityFunctions.PutObjectOnGround(newVillager.transform); VillagerNode villagerNode = newVillager.AddComponent <VillagerNode>(); villagerNode.SetUp(villagerName); villagerNode.transform.parent = transform; Villagers.Add(villagerNode); AddLink(villagerNode); return(villagerNode); }
public IPeople GetPeople(PeopleType type) { IPeople people = null; switch (type) { case PeopleType.Rural: people = new Villagers(); break; case PeopleType.Urban: people = new CityPeople(); break; } return(people); }
public IPeople GetPeople(PeopleType type) { IPeople people = null; switch (type) { case PeopleType.RURAL: people = new Villagers(); break; case PeopleType.URBAN: people = new CityPeople(); break; default: break; } return people; }
// La siguiente función lee la posición de los aldeanos, cuando la distancia es menor al rango, los enemigos pasan a perseguirlos. public void GetTarget() { Villagers closest = null; float closestDistance = 5.0f; foreach (var v in FindObjectsOfType <Villagers>()) { float distance = Vector3.Distance(v.transform.position, transform.position); if (distance < closestDistance) { m = Move.Reacting; closest = v; closestDistance = distance; direction = Vector3.Normalize(v.transform.position - transform.position); transform.position += direction * npcSpeed * Time.deltaTime; } } }
public Villager findVillagerByVillagerType(VillagerTypes vType) { Villagers v = new Villagers(); foreach (Villagers vv in villagers) { if (vv.vType == vType) { v = vv; } } if (v != null) { return(v.villager.GetComponent <Villager>()); } else { return(null); } }
public void KillVillager(Villager villager) { //Debug.Log (villager); // Remove the Villager from everything and stuff Villagers.Remove(villager.gameObject); vFollowers.Remove(villager.Follower.gameObject); Followers.Remove(villager); Destroy(villager.Follower.gameObject); Destroy(villager.Follower); Destroy(villager.gameObject); // create new villager //CreateNewVillager(); // increment deadVillagers++; // Update text DeadVillagersText.guiText.text = "Villagers Killed: " + deadVillagers; }
public GameObject findVillagerGameObjectByVillagerType(VillagerTypes vType) { Villagers v = new Villagers(); foreach (Villagers vv in villagers) { if (vv.vType == vType) { v = vv; } } if (v != null) { return(v.villager); } else { return(null); } }
public void AddVillager(Villager villager) { Villagers.Add(NbVillagers, villager); NbVillagers++; }