private void Shoot()
    {
        // To allow for infinite shots until the game has started
        if (_bossManager._gameActive)
        {
            ResetBaton();
        }
        _audioSource.PlayOneShot(_attackSound);

        var attackEndPoint = _pointerOrigin.position + _pointerOrigin.forward * _pointerLineLength;

        RaycastHit hit;

        if (Physics.Raycast(_pointerOrigin.position, _pointerOrigin.forward, out hit, _pointerLineLength))
        {
            if (hit.collider.CompareTag("Boss"))
            {
                // To make sure that the baton resets when it hits the boss for the first time
                if (!_bossManager._gameActive)
                {
                    ResetBaton();
                }

                _bossManager.TakeDamage(_shotDamage);
                attackEndPoint = hit.point;
            }
        }

        StartCoroutine(ShotAnimation(attackEndPoint));
    }
Example #2
0
 public void TakeDamage(float damage)
 {
     FindObjectOfType <AudioManager>().Play("HitSound");
     StartCoroutine(FlashDamage());
     bossManag.TakeDamage(damage);
     Instantiate(bloodEffect, transform.position, Quaternion.identity);
     CinemachineShake.Instance.ShakeCam(1f, .2f);
 }
Example #3
0
    void OnTriggerEnter2D(Collider2D hitInfo) // when the bullet collides with an enemy/object
    {
        if (hitInfo.gameObject.tag.Equals("Enemy"))
        {
            Enemy enemy = hitInfo.GetComponent <Enemy>(); // stores the collidee as an enemy
            if (enemy != null)                            // if it actually collides with an enemy
            {                                             // enemy takes damage
                enemy.TakeDamage();
            }

            //Instantiate(impactEffect, transform.position, transform.rotation); // similar to deathEffect, if we want an animation for impact

            RemoveBullet();
        }
        else if (hitInfo.gameObject.tag.Equals("Boss"))
        {
            BossManager boss = hitInfo.GetComponent <BossManager>();
            if (boss != null)
            {
                boss.TakeDamage();
            }
        }
    }