예제 #1
0
        public IEnumerator ProjectileShoots()
        {
            GameObject g = Object.Instantiate(GameObject.CreatePrimitive(PrimitiveType.Cube), Vector3.zero, Quaternion.identity); // Creates a 'gun' to shoot the projectile from

            // Creates a GunGeneralStats class.
            GunGeneralStats gs = g.AddComponent <GunGeneralStats>();

            gs.projectilePrefab = Resources.Load("Prefabs/Projectiles/Bullet") as Projectile;
            gs.projectileCount  = 1;
            gs.projectileSpread = 0;
            gs.range            = 100;
            gs.muzzle           = g.transform;

            // Declares gs' Shoot function to launch its projectile, at the desired position and in the desired direction
            gs.Shoot(null, g.transform.position, g.transform.forward, g.transform.up);

            yield return(new WaitForEndOfFrame());                 // Waits until all previous functions have finished

            Projectile p = Object.FindObjectOfType <Projectile>(); // Searches for a projectile gameObject in the scene

            Assert.IsNotNull(p.gameObject);                        // Asserts if projectile was found
        }
 public override void SingleAttack()
 {
     base.SingleAttack();
     stats.Shoot(wielder.characterData, wielder.LookOrigin, wielder.LookDirection, wielder.LookUp);
 }