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);
        }
    }
示例#3
0
 public void SendDamage(float Damage)
 {
     boss.TakeDamage(Damage);
 }