public void selectVillagerById(int id) { unselectAllBuildings(); List <GameObject> people = getAllVillagerObjects(); for (int i = 0; i < people.Count; i++) { VillagerStats stats = people[i].GetComponent <VillagerStats>(); if (stats.id == id) { stats.setSelected(true); return; } } }
public void arrivedAtBuilding() { if (enrouteToBuilding) { // Work on building if (buildingSiteController.donePercent < 100) { buildingSiteController.doWork(); building = true; timeBuildingStarted = Time.time; animator.SetBool("working", true); stats.setSelected(false); enrouteToBuilding = false; if (buildingSiteController.gameObject.transform.position.x < transform.position.x) { spriteRenderer.flipX = true; } } } else if (enrouteToTree) { // Harvest Tree if (treeController.resourcesLeft > 0) { treeController.resourcesLeft--; treeController.checkIfEmpty(); progressBarObject.SetActive(true); choppingTree = true; timeGatheringStarted = Time.time; animator.SetBool("working", true); stats.setSelected(false); enrouteToTree = false; if (treeController.gameObject.transform.position.x < transform.position.x) { spriteRenderer.flipX = true; } } } else if (enrouteToBoulder) { // Harvest Boulder if (rockController.resourcesLeft > 0) { rockController.resourcesLeft--; rockController.checkIfEmpty(); progressBarObject.SetActive(true); hittingRock = true; timeGatheringStarted = Time.time; animator.SetBool("working", true); stats.setSelected(false); enrouteToBoulder = false; if (rockController.gameObject.transform.position.x < transform.position.x) { spriteRenderer.flipX = true; } } } else { // Gather resources if (buildingController.currentResourcesHeld > 0) { buildingController.currentResourcesHeld--; progressBarObject.SetActive(true); gathering = true; timeGatheringStarted = Time.time; animator.SetBool("working", true); stats.setSelected(false); if (buildingController.gameObject.transform.position.x < transform.position.x) { spriteRenderer.flipX = true; } } } }