void OnTriggerEnter(Collider other) { if ("Enemy" == other.gameObject.tag) { Camera.main.GetComponent <WHCameraShake> ().doShake(); fortress.ReceiveDamage(other.GetComponent <Enemy> ().strength); other.GetComponent <Enemy> ().Die(); } }
void Fire() { Vector3 direction = transform.TransformDirection(Vector3.forward); RaycastHit hit; if (Physics.Raycast(transform.position, direction, out hit, scope)) { Quaternion tempRot = Quaternion.FromToRotation(Vector3.up, hit.normal); Instantiate(impact, hit.point, tempRot); switch (hit.collider.gameObject.tag) { case "Enemy": hit.collider.gameObject.GetComponent <Enemy> ().ReceiveDamage(damage); break; case "Fortress": fortress.ReceiveDamage(damage); break; } } SoundManager.instance.PlaySound(SoundManager.SoundName.SHOOT); }