private void Shoot()
    {
        GameObject   bulletGO = Instantiate(bulletPrefab, firePoint.position, firePoint.rotation);
        BulletScript bullet   = bulletGO.GetComponent <BulletScript>();

        if (bullet != null)
        {
            bullet.Seek(target);
        }
    }
    //--------------------------------------------------------------------------------------------------------------------------------------------//
    //                                                                                                                                            //
    //                                                                     ShootProjectile();                                                     //
    //                                                                                                                                            //
    //--------------------------------------------------------------------------------------------------------------------------------------------//

    #region Code Summary ShootProjectile
    /// <summary>
    /// Called every time the fire cooldown timer reaches zero
    /// -----------
    /// Instantiates a bullet based on its prefab at the end of the turret's barrel
    /// -----------
    /// if the bullet is not null call bullet.Seek(target) where target is the current target of the turret
    /// </summary>
    #endregion

    virtual public void ShootProjectile()
    {
        GameObject   bulletGameObject = Instantiate(bulletPrefab, firePoint.position, firePoint.rotation);
        BulletScript bullet           = bulletGameObject.GetComponent <BulletScript>();

        if (bullet != null)
        {
            bullet.Seek(target);
        }
    }
示例#3
0
    //Spawns a bullet and targets closet enemy
    void Shoot()
    {
        //Debug.Log("SHOOT!");
        GameObject   bulletGO = (GameObject)Instantiate(bullterPrefab, firePoint.position, firePoint.rotation);
        BulletScript bullet   = bulletGO.GetComponent <BulletScript>();

        if (bullet != null)
        {
            bullet.Seek(target);
        }
        //Play sound for bullet here
        gameObject.GetComponent <AudioSource>().Play();
    }
示例#4
0
    private void MakeShoot()
    {
        GameObject bullet = towerScript.bulletsPool.GetBullet();

        bullet.transform.position = transform.position;
        bullet.SetActive(true);

        GameObject   nearestTarget = GetNearestEnemy();
        BulletScript bulletScript  = bullet.GetComponent <BulletScript>();

        bulletScript.damage = towerScript.mTowerSO.damage;
        bulletScript.speed  = towerScript.mTowerSO.bulletSpeed;
        bulletScript.Seek(nearestTarget.transform);
    }
示例#5
0
    void Shoot()
    {
        //bullet = (GameObject)Instantiate (bulletPrefab, firePoint.position, firePoint.rotation);
        audioSrc.PlayOneShot(audioSrc.clip, 0.2f);
        bullet = AmmoBank.instance.bullets.Pop();
        bullet.transform.position      = firePoint.position;
        bullet.transform.localRotation = firePoint.rotation;
        bullet.SetActive(true);
        bulletScript = bullet.GetComponent <BulletScript> ();

        if (bulletScript != null)
        {
            bulletScript.Seek(target, targetScript);
        }
    }