Example #1
0
    IEnumerator Shoot()
    {
        muzzleFlash.Play();
        m_animator.SetTrigger("Shoot");
        soundEmitted.Play();
        RaycastHit hit;

        if (Physics.Raycast(fpsCam.transform.position, fpsCam.transform.forward, out hit, range))
        {
            // Prints to the console what has been hit by the raycast
            Debug.Log(hit.transform.name);

            // If the raycast hits an enemy, it will take damage
            GetShot target = hit.transform.GetComponent <GetShot>();
            if (target != null)
            {
                target.TakeDamage(damage);
            }
        }

        // Delay between shots, and subtracting the ammo count
        yield return(new WaitForSecondsRealtime(shootTime));

        isShooting = false;
        currentAmmo--;
    }
Example #2
0
    private void ShootCiv(GameObject civ)
    {
        print("I hit: " + civ.transform.name + " who is a civ");
        GetShot getShot = civ.GetComponent <GetShot>();

        if (!getShot.haveIBeenShot)
        {
            GM.numberOfCiviliansShot++;
        }
        getShot.Shot();
    }
Example #3
0
    private void ShootEnemy(GameObject enemy)
    {
        print("I hit: " + enemy.transform.name + " who is an enemy");
        GetShot getShot = enemy.GetComponent <GetShot>();

        if (!getShot.haveIBeenShot)
        {
            GM.numberOfEnemiesShot++;
        }
        getShot.Shot();
    }