Example #1
0
    // Update is called once per frame
    void Update()
    {
        if (!(barrels[0].cooldownRemaining <= 0) && !(barrels[1].cooldownRemaining <= 0))
        {
            barrels[0].cooldownRemaining -= Time.deltaTime;
            barrels[1].cooldownRemaining -= Time.deltaTime;
        }

        if (teamToHit == GameController.Teams.Player && autoAim)
        {
            transform.LookAt(player.transform);
        }

        if (isFiring || autoFire)
        {
            for (int i = 0; i < barrels.Length; i++)
            {
                if (barrels[i].cooldownRemaining <= 0)
                {
                    GameObject    laser  = Instantiate(laserShotPrefab, barrels[i].barrelEnd.position, barrels[i].barrelEnd.rotation) as GameObject;
                    Blaster_Laser blaser = laser.GetComponent <Blaster_Laser>();
                    blaser.Initialize(laserColor, damage, teamToHit);
                    barrels[i].cooldownRemaining = fireRate;
                    //bulletSound.PlayOneShot(bulletSound.clip);
                    bulletSound.Play();
                }
            }
        }
    }
Example #2
0
    // Update is called once per frame
    void Update()
    {
        if (fireRateCooldown > 0)
        {
            fireRateCooldown -= Time.deltaTime;
        }

        if (teamToHit == GameController.Teams.Player && autoAim)
        {
            transform.LookAt(player.transform);
        }

        if (isFiring || autoFire)
        {
            if (fireRateCooldown <= 0)
            {
                GameObject    laser  = Instantiate(laserShotPrefab, _shootOrigin[0].position, _shootOrigin[0].rotation) as GameObject;
                Blaster_Laser blaser = laser.GetComponent <Blaster_Laser>();
                blaser.Initialize(laserColor, damage, teamToHit);
                fireRateCooldown = fireRate;
                bulletSound.Play();
            }
        }
    }