void HitTarget() { if (nearestenemy.gameObject.tag == "spot") { ShotSpot = nearestenemy.gameObject.GetComponent <PlaceMonster>(); ShotSpot.monster.GetComponent <FireTower>().damageScale = damageScale; Destroy(gameObject); } else { //kejin modify: Transform healthBarTransform = nearestenemy.transform.Find("HealthBar"); HealthBar healthBar = healthBarTransform.gameObject.GetComponent <HealthBar>(); if (healthBar.currentHealth > 0) { healthBar.currentHealth -= Mathf.Max(damage, 0); //AudioSource audioSource = nearestenemy.GetComponent<AudioSource>(); //AudioSource.PlayClipAtPoint(audioSource.clip, transform.position); } //Debug.Log("health " + Healthtrans.localScale); // kejin end Destroy(gameObject); } }
// private GameObject CircleObj; // Use this for initialization void Start() { //UIEventListener.Get(transform.gameObject).onClick = CanCostGold; foreach (UIEventListener g in soldAndUpEvent) { g.onClick += CanCostGold; } //gm = GameObject.Find("GameManager").GetComponent<GameManagerBehavior>(); placeMonster = PlaceMonster.mySelfGameObject.GetComponent <PlaceMonster>(); //AtackOBJ = Resources.Load<GameObject>("wroop") as GameObject; //getAtackobjComponent = AtackOBJ.transform.Find(PlaceMonster.towerName); msData = PlaceMonster.mySelfGameObject.GetComponent <MonsterData>(); //placeMonster = getAtackobjComponent.GetComponent<PlaceMonster>(); shootEnemies = PlaceMonster.mySelfGameObject.GetComponent <ShootEnemies>(); // CircleObj = PlaceMonster.mySelfGameObject.transform.Find("Circle").gameObject; msData.CurrentLevel = msData.levels[0]; }