예제 #1
0
    IEnumerator ShootingCheck()
    {
        while (true)
        {
            if (Input.GetKey(KeyCode.Space) == true || Input.GetKeyDown(KeyCode.Space) == true)
            {
                GameObject bullet = Instantiate(Bullet, bulletSpawn.position, bulletSpawn.rotation) as GameObject;

                Rigidbody2D bulletRb2d = bullet.GetComponent <Rigidbody2D> ();
                bulletRb2d.velocity = shipRb2d.velocity;
                bulletRb2d.AddForce(bulletSpawn.up * bulletSpeed);

                ProjectileExplosion explo = bullet.GetComponent <ProjectileExplosion> ();
                explo.Damage    = damage;
                explo.Knockback = knockBack;
                explo.Stun      = stun;
                explo.Invoke("Explode", lifespan);

                yield return(new WaitForSeconds(fireWait));

                continue;
            }

            yield return(null);
        }
    }
예제 #2
0
    IEnumerator Shoot()
    {
        while (true)
        {
            if (target != null)
            {
                if (LOS == true)
                {
                    bullet = (GameObject)Instantiate(Bullet, bulletSpawn.position, bulletSpawn.rotation);
                    bullet.transform.parent = transform;
                    bullet.GetComponent <Rigidbody2D>().AddForce(direction * bulletSpeed);

                    ProjectileExplosion explo = bullet.GetComponent <ProjectileExplosion>();
                    explo.Damage    = damage;
                    explo.Knockback = knockBack;
                    explo.Stun      = stun;
                    explo.Invoke("Explode", lifespan);

                    yield return(new WaitForSeconds(fireWait));
                }
                else
                {
                    yield return(null);
                }
            }
            else
            {
                GetComponent <LineRenderer>().enabled = false;
                yield return(null);
            }
        }
    }
예제 #3
0
    IEnumerator Shoot()
    {
        GameObject laser = Instantiate(Projectile, Shooter.position, transform.rotation) as GameObject;

        laser.transform.RotateAround(laser.transform.position, laser.transform.forward, -90f);
        laser.transform.Translate(Vector3.forward);

        ProjectileExplosion explo = laser.GetComponent <ProjectileExplosion> ();

        explo.Damage    = Damage;
        explo.Knockback = Knockback;
        explo.Stun      = Stun;
        explo.Invoke("Explode", Lifespan);

        Rigidbody2D laserRb2d = laser.GetComponent <Rigidbody2D> ();

        laserRb2d.velocity = rb2d.velocity;
        laserRb2d.AddForce(new Vector2(laser.transform.up.x, laser.transform.up.y) * ShotSpeed);

        ShootReady = false;

        yield return(new WaitForSeconds(ShootCooldown));

        ShootReady = true;
    }
 private Task ProjectileExplode()
 {
     if (debug)
     {
         Console.WriteLine($"OBSERVER: NetworkManagerClient ProjectileExpode");
     }
     ProjectileExplosion?.Invoke();
     return(Task.CompletedTask);
 }