Esempio n. 1
0
    public void ProjectileSpawnPosition()
    {
        var spawn  = new GameObject("spawn");
        var target = new MockSheet();
        var cast   = new MockCastProjectile {
            projectileSpawn = spawn.transform
        };

        spawn.transform.position = Vector3.back;

        cast.Apply(target).MoveNext();

        Assert.AreEqual(Vector3.back, cast.magazine.Projectile.transform.position);
    }
Esempio n. 2
0
    public void DisposeProjectileWhenRoutineDone()
    {
        var disposed = null as GameObject;
        var spawn    = new GameObject("spawn");
        var target   = new MockSheet();
        var cast     = new MockCastProjectile {
            projectileSpawn = spawn.transform
        };

        cast.magazine.onDispose = o => disposed = o;

        cast.Apply(target).MoveNext();

        Assert.AreSame(cast.magazine.Projectile, disposed);
    }
Esempio n. 3
0
    public void DontDisposeProjectileWhenRoutineNotDone()
    {
        var disposed = false;
        var spawn    = new GameObject("spawn");
        var target   = new MockSheet();
        var cast     = new MockCastProjectile {
            projectileSpawn = spawn.transform
        };

        cast.magazine.onDispose = _ => disposed = true;

        IEnumerator <WaitForFixedUpdate> approach(Transform _, MockSheet __, float ___)
        {
            yield return(new WaitForFixedUpdate());
        }

        cast.approach.apply = approach;

        cast.Apply(target).MoveNext();

        Assert.False(disposed);
    }
Esempio n. 4
0
    public void ApproachArgs()
    {
        var called = default((Transform, MockSheet, float));
        var spawn  = new GameObject("spawn");
        var target = new MockSheet();
        var cast   = new MockCastProjectile {
            projectileSpawn = spawn.transform
        };

        cast.projectileSpeed = 1;

        IEnumerator <WaitForFixedUpdate> approach(Transform projectile, MockSheet target, float speed)
        {
            called = (projectile, target, speed);
            yield break;
        }

        cast.approach.apply = approach;

        cast.Apply(target).MoveNext();

        Assert.AreEqual((cast.magazine.Projectile.transform, target, 1f), called);
    }