Example #1
0
    /// <summary>
    /// Shoots the bullets.
    /// </summary>
    public override void Shoot(Vector2 direction)
    {
        if (canShoot == true)
        {
            coolTimer = 0;
            var bullet = inactiveBullets.First();
            if (bullet != null)
            {
                inactiveBullets.RemoveAt(0);
                activeBullets.Add(bullet);

                var offset = BulletPositionOffset;
                var initialDirectionChanged = direction.x < 0;
                if (initialDirectionChanged)
                {
                    offset *= -1;
                }

                bullet.gameObject.transform.position = gameObject.transform.position;
                bullet.gameObject.transform.Translate(offset, 0, 0);
                bullet.Direction = direction;
                bullet.gameObject.SetActive(true);
                emitter.Play();

                forwardMuzzleFlashScript.Play();
                upMuzzleFlashScript.Play(initialDirectionChanged);
                downMuzzleFlashScript.Play(initialDirectionChanged);
            }
        }
    }
Example #2
0
    public void Shoot()
    {
        MuzzleFlash.Play();
        foreach (GameObject spawnpoint in Spawnpoints)
        {
            if (Physics.Raycast(spawnpoint.transform.position, spawnpoint.transform.forward, out RaycastHit hit))
            {
                //hit effects
                if (hit.rigidbody != null)
                {
                    hit.rigidbody.AddForce(-hit.normal * ImpactForce);
                }
                GameObject impactFX = Instantiate(UsedImpactPrefab, hit.point, Quaternion.LookRotation(hit.normal, transform.up));
                impactFX.transform.SetParent(hit.collider.transform);

                //hitting an enemy turret
                if (hit.transform.CompareTag("EnemyTurret"))
                {
                    //instantiate a metal impact prefab
                    DeployableHealth hitHealth = hit.transform.GetComponent <DeployableHealth>();
                    hitHealth.Health -= 3f;
                }
            }
        }
        ShotBeamAmmoControl.CurrentAmmo--;
        NextFire = Time.time + Delay;
    }
Example #3
0
 void PlayMuzzleFlash()
 {
     if (muzzleFlash != null)
     {
         muzzleFlash.gameObject.SetActive(true);
         muzzleFlash.Play();
     }
 }
Example #4
0
        public override void Use()
        {
            MuzzleFlash.Play();

            if (Physics.Raycast(MuzzleTransform.position, MuzzleTransform.forward, out var hit))
            {
                BulletTrail.gameObject.SetActive(true);
                BulletTrail.SetPosition(0, MuzzleTransform.position);
                BulletTrail.SetPosition(1, hit.point);
            }
        }
Example #5
0
    public void Shoot()
    {
        MuzzleFlash.Play();
        GameObject missile = Instantiate(missilePrefab, transform.Find("Spawnpoint").position, transform.rotation);

        missile.tag = "Missile";
        Missile msl = missile.GetComponent <Missile>();

        msl.MotorForce = 500;
        msl.Guided     = false;
        MissileLauncherAmmoControl.CurrentAmmo--;
        NextFire = Time.time + Delay;
    }