protected override void Shoot( ) { RaycastHit hit; //Debug.DrawRay(playerCamera.transform.position, playerCamera.transform.forward*Range, Color.red, 5f); if (Physics.Raycast(playerCamera.transform.position, playerCamera.transform.forward, out hit, Range)) { Debug.DrawLine(hit.point, hit.point, Color.black, 5f); if (hit.collider.gameObject.tag == "Enemy") { if (hit.collider.gameObject.GetComponent <Enemy>()) { Enemy target = hit.collider.gameObject.GetComponent <Enemy>(); target.TakeDamage(Damage); } } //if (hit.collider.gameObject.tag == "CQEnemy") { // if (hit.collider.gameObject.GetComponent<CQEnemy>()) { // CQEnemy target = hit.collider.gameObject.GetComponent<CQEnemy>(); // target.TakeDamage(Damage); // } //} //if (hit.collider.gameObject.tag == "EnemyStatic") //{ // if (hit.collider.gameObject.GetComponent<EnemyStatic>()) // { // EnemyStatic target = hit.collider.gameObject.GetComponent<EnemyStatic>(); // target.TakeDamage(Damage); // } //} //if (hit.collider.gameObject.tag == "EnemyRanged") //{ // if (hit.collider.gameObject.GetComponent<EnemyRanged>()) // { // EnemyRanged target = hit.collider.gameObject.GetComponent<EnemyRanged>(); // target.TakeDamage(Damage); // } //} //if (hit.collider.gameObject.tag == "EnemyExploding") //{ // Debug.Log("EnemyExploding hit"); // if (hit.collider.gameObject.GetComponent<EnemyExploding>()) // { // EnemyExploding target = hit.collider.gameObject.GetComponent<EnemyExploding>(); // target.TakeDamage(Damage); // } //} if (hit.collider.gameObject.tag == "WeakSpot") { if (hit.collider.gameObject.GetComponent <WeakSpot>()) { WeakSpot target = hit.collider.gameObject.GetComponent <WeakSpot>(); target.SendDamage(Damage); } } } }
protected override void Shoot() { RaycastHit hit; Ammo--; anim.Play("tilt"); audio.Play(); if (Physics.Raycast(cam.transform.position, cam.transform.forward, out hit, Range)) { Debug.Log("Hit " + hit.transform.name); //anim.SetTrigger("tilt"); if (hit.collider.gameObject.tag == "Enemy") { if (hit.collider.gameObject.GetComponent <Enemy>()) { Enemy target = hit.collider.gameObject.GetComponent <Enemy>(); target.TakeDamage(Damage); } } if (hit.collider.gameObject.tag == "WeakSpot") { if (hit.collider.gameObject.GetComponent <WeakSpot>()) { WeakSpot target = hit.collider.gameObject.GetComponent <WeakSpot>(); target.SendDamage(Damage); } } Debug.DrawRay(transform.position, transform.forward, Color.green, 5f); GameObject obj = Instantiate(impact, hit.point, Quaternion.LookRotation(hit.normal)); //impact.transform.localscale = new Vector3(5f, 5f, 5f); Destroy(obj, .1f); } }
protected override void Shoot() { audio.Play(); Ammo -= 1; Ray ray; ray = new Ray(playerCamera.transform.position, playerCamera.transform.forward); RaycastHit hit; if (Physics.Raycast(ray, out hit, Mathf.Infinity, (layerEnemy | layerGround), QueryTriggerInteraction.Ignore)) { if (hit.collider.gameObject.tag == "untagged") { Shootlaser(); } else { Shootlaser(hit.point); if (hit.collider.gameObject.tag == "Enemy") { if (hit.collider.gameObject.GetComponent <Enemy>()) { Enemy target = hit.collider.gameObject.GetComponent <Enemy>(); target.TakeDamage(CalculateDamage(hit.distance)); } } if (hit.collider.gameObject.tag == "WeakSpot") { if (hit.collider.gameObject.GetComponent <WeakSpot>()) { WeakSpot target = hit.collider.gameObject.GetComponent <WeakSpot>(); target.SendDamage(CalculateDamage(hit.distance)); } if (hit.collider.gameObject.GetComponent <BossBlueprint>()) { BossBlueprint target = hit.collider.gameObject.GetComponent <BossBlueprint>(); target.TakeDamage(CalculateDamage(hit.distance)); } } } } }
private void OnCollisionEnter(Collision collision) { ParticleSystem ExplosionInstance; if (collision.gameObject.tag == "Enemy" || collision.gameObject.tag == "WeakSpot") { CollisionTransform = this.transform; if (collision.gameObject.GetComponent <Enemy>()) { collision.gameObject.GetComponent <Enemy>().TakeDamage(Damage); } if (collision.gameObject.GetComponent <WeakSpot>()) { WeakSpot target = collision.gameObject.GetComponent <WeakSpot>(); target.SendDamage(Damage); } if (collision.gameObject.GetComponent <BossBlueprint>()) { BossBlueprint target = collision.gameObject.GetComponent <BossBlueprint>(); target.TakeDamage(Damage); } ExplosionInstance = Instantiate(explosion, CollisionTransform.position, Quaternion.identity) as ParticleSystem; AudioSource.PlayClipAtPoint(explosionSound, this.gameObject.transform.position); Destroy(this.gameObject); //Destroy(explosion.gameObject, 0.5f); } else if (collision.gameObject.tag == "Untagged") { CollisionTransform = this.transform; ExplosionInstance = Instantiate(explosion, CollisionTransform.position, Quaternion.identity) as ParticleSystem; AudioSource.PlayClipAtPoint(explosionSound, this.gameObject.transform.position); Destroy(this.gameObject); //Destroy(explosion.gameObject, 0.5f); } }