private void Start() { villager = GetComponent <VillagerScript>(); animatedText = InterfaceManager.instance.animatedText; animatedText.onTextReveal.AddListener((newChar) => ReproduceSound(newChar)); }
private void OnTriggerExit(Collider other) { if (other.CompareTag("Villager")) { currentVillager = null; ui.currentVillager = currentVillager; } }
private void OnTriggerEnter(Collider other) { if (other.CompareTag("Villager")) { currentVillager = other.GetComponent <VillagerScript>(); ui.currentVillager = currentVillager; } }
public void AssignVillagerToWork(VillagerScript villager) { if (!villagersWorkingHere.Contains(villager) && numberOfWorkersAllowed > villagersWorkingHere.Count) { villagersWorkingHere.Add(villager); Debug.Log("Villager Added to building" + villager.villagerName); villager.SetDestination(this.transform.Find("NavPoint").gameObject); } }
private void nTriggerExit(Collider other) { // 시민 Object의 충돌체에서 떨어진 경우, 대화 대상에서 제거 if (other.CompareTag("Villager")) { currentVillager = null; ui.currentVillager = null; } }
private void OnTriggerEnter(Collider other) { // 시민 Object의 충돌체와 충돌한 경우, 해당 시민들 대화 대상으로 정의 if (other.CompareTag("Villager")) { currentVillager = other.GetComponent <VillagerScript>(); ui.currentVillager = currentVillager; } }
public void ChangeVillager(VillagerScript vs) { currentVillager = vs; dialogueCam = currentVillager.dialogueCam; }
//Takes a scene object that was clicked and populates the appropriate UI elements with the info needed. public void ObjectClicked(GameObject objectClicked) { //check attached scripts to find what type of object has been clicked, activate and populate appropriate UI elements if (objectClicked.GetComponent <VillagerScript>()) { if (selectedVillager != null) { selectedVillager.transform.GetComponent <Renderer>().material.SetColor("_Color", Color.grey); } selectedVillager = objectClicked; selectedVillager.transform.GetComponent <Renderer>().material.SetColor("_Color", Color.green); VillagerScript v = objectClicked.GetComponent <VillagerScript>(); villagerPanel.SetActive(true); var villagerPanelTextElements = villagerPanel.GetComponentsInChildren <Text>(); if (selectedVillager == null) { selectedVillagerText.text = "No Villager Selected"; } else { selectedVillagerText.text = "Selected Villager: " + v.villagerName; } //set all of our text elements foreach (Text t in villagerPanelTextElements) { if (t.name == "Header") { t.text = v.villagerName; } else if (t.name == "HP") { t.text = "HP: " + v.health.currentHP + " / " + v.health.maxHP; } else if (t.name == "ProfessionText") { t.text = "Level " + v.prof.professionLevels[v.prof.assignedProfession] + " " + v.prof.assignedProfession; } } //get the stats panel var statsPanel = villagerPanel.transform.Find("StatsPanel"); //clear stats panel foreach (Transform child in statsPanel) { GameObject.Destroy(child.gameObject); } //populate stats panel foreach (KeyValuePair <string, int> stat in v.stats.StatsList) { var element = Instantiate(statsTextElement); element.transform.SetParent(statsPanel, false); element.GetComponent <Text>().fontSize = 14; element.GetComponent <Text>().fontStyle = FontStyle.Bold; element.GetComponent <Text>().text = stat.Key + " " + stat.Value; } foreach (KeyValuePair <Professions, int> professionStat in v.prof.professionLevels) { var element = Instantiate(statsTextElement); element.transform.SetParent(statsPanel, false); element.GetComponent <Text>().text = professionStat.Key.ToString() + " " + professionStat.Value; } } //Workshop UI display if (objectClicked.GetComponent <Workshop>()) { Workshop s = objectClicked.GetComponent <Workshop>(); structurePanel.SetActive(true); var structurePanelTextElements = structurePanel.GetComponentsInChildren <Text>(); foreach (Text t in structurePanelTextElements) { if (t.name == "Header") { t.text = s.structureName; } if (t.name == "LevelDisplay") { t.text = "Lvl " + s.upgradeLevel + " Workshop"; } } var structureTextPanel = structurePanel.transform.Find("StructureInfoPanel"); foreach (Transform child in structureTextPanel) { Destroy(child.gameObject); } foreach (Transform child in workerPanel.transform) { Destroy(child.gameObject); } foreach (VillagerScript worker in s.villagersWorkingHere) { var workerInfo = Instantiate(workerUIPrefab); workerInfo.transform.SetParent(workerPanel.transform, false); workerInfo.transform.Find("WorkerText").GetComponent <Text>().text = worker.villagerName + " " + s.requiredProfession.ToString() + " " + worker.prof.professionLevels[s.requiredProfession] + "/10"; } var element = Instantiate(structureTextElementPrefab); element.transform.SetParent(structureTextPanel, false); element.GetComponent <Text>().text = "Workers: " + s.villagersWorkingHere.Count + "/" + s.numberOfWorkersAllowed; element = Instantiate(structureTextElementPrefab); element.transform.SetParent(structureTextPanel, false); element.GetComponent <Text>().text = "Level: " + s.upgradeLevel; } }
//where player hits rock private void OnTriggerEnter2D(Collider2D otherCollider) { smallRock smallRockObject = otherCollider.gameObject.GetComponent <smallRock>(); BigRock BigRockObject = otherCollider.gameObject.GetComponent <BigRock>(); PowerUps PowerUpObject = otherCollider.gameObject.GetComponent <PowerUps>(); VillagerScript VillagerObject = otherCollider.gameObject.GetComponent <VillagerScript>(); RockMasterShotScript RockMasterShot = otherCollider.gameObject.GetComponent <RockMasterShotScript>(); //if the collliding object is small rock if (smallRockObject != null) { EnemyMaker.movingSmallRock1 = false; EnemyMaker.smallRockTimer1 = 0f; //destroy object rock and player smallRockObject.transform.position = new Vector2(smallRockObject.transform.position.x, myScreen.y + 1f); ReAudioManager.myAudioClipsSFXs[4].Play(); //play player explode Destroy(PlayerObject.gameObject); Instantiate(PlayerExplosionObject, PlayerObject.transform.position, transform.rotation); //player to explode //make lose menu appear WhenPlayerDies(); } //if the collliding object is big rock if (BigRockObject != null) { EnemyMaker.movingBigRock = false; EnemyMaker.bigRockTimer = 0f; //destroy object rock and player BigRockObject.transform.position = new Vector2(BigRockObject.transform.position.x, myScreen.y + 1f); ReAudioManager.myAudioClipsSFXs[4].Play(); //play player explode Destroy(PlayerObject.gameObject); Instantiate(PlayerExplosionObject, PlayerObject.transform.position, transform.rotation); //player to explode //make lose menu appear WhenPlayerDies(); } //if the collliding object is rockmaster fire if (RockMasterShot != null) { RockMasterShotScript.RockMasterShotMoving = false; //destroy object rock and player RockMasterShot.transform.position = new Vector2(RockMasterShot.transform.position.x, myScreen.y + 1f); ReAudioManager.myAudioClipsSFXs[4].Play(); //play player explode Destroy(PlayerObject.gameObject); Instantiate(PlayerExplosionObject, PlayerObject.transform.position, transform.rotation); //player to explode //make lose menu appear WhenPlayerDies(); } //if the collliding object is power up if (PowerUpObject != null) { //destroy power up Destroy(PowerUpObject.gameObject); ReAudioManager.myAudioClipsSFXs[6].Play(); //play get powerup Instantiate(BulletAcquiredAnimObject, PlayerObject.transform.position, transform.rotation); //show animation for getting power up //Give Player more bullets if (availableBullet < numberOfPossibleBullets) //check the possible bullets that can be gotten { availableBullet += numberOfBulletsPerPotion; //Increase shootable bullets if (availableBullet > numberOfPossibleBullets) { availableBullet = numberOfPossibleBullets; } } } //if the collliding object is villager if (VillagerObject != null) { VillagerManager.villagerMoving = false; VillagerManager.VillagerCountDown = 0f; //destroy object rock and player VillagerObject.transform.position = new Vector2(VillagerObject.transform.position.x, myScreen.y + 1f); ReAudioManager.myAudioClipsSFXs[8].Play(); //play get village Instantiate(PlayerExplosionObject, PlayerObject.transform.position, transform.rotation); //player to explode intVillagersAcquired += 1; VillageAcquiredTextObject.text = intVillagersAcquired.ToString() + "/" + intVillagersToAcquire + " Villagers"; //For Level To End if (intVillagersAcquired == intVillagersToAcquire) { PlayerPrefs.SetInt("Current_Score", intPlayerScore); //Get The number of Villagers saved so far and add to the saved ones PlayerPrefs.GetInt("Villager_Total_Amount"); PlayerPrefs.SetInt("Villager_Total_Amount", PlayerPrefs.GetInt("Villager_Total_Amount") + intVillagersAcquired); PlayerPrefs.SetInt("Level_Amount", intVillagersAcquired); SceneManager.LoadScene("SecondAnimation"); SceneManager.UnloadSceneAsync("RockEvaders"); } } }