Example #1
0
    public IEnumerator CapsuleDestroyedByBullet()
    {
        var capsule = BulletCapsule.Create(0, Player.Create());
        var bullet  = Bullet.Create(0);

        capsule.gameObject.SetActive(true);
        bullet.gameObject.SetActive(true);

        yield return(new WaitUntil(
                         () => Spawnable.Pool <BulletCapsule> .Instance.Count > 0
                         ));

        Assert.AreSame(capsule, Spawnable.Pool <BulletCapsule> .Instance.RequestObject());
    }
Example #2
0
    public IEnumerator CapsuleGivesBullets()
    {
        //Set up Test
        Player        player  = Player.Create();
        BulletCapsule capsule =
            BulletCapsule.Create(0, player);

        yield return(new WaitForSecondsRealtime(5f));

        //Perform Test
        capsule.Destroy();

        //Assert
        Assert.Greater(player.Ammo, 0);
    }
Example #3
0
    public IEnumerator SpawnerFetchesFromPool()
    {
        Spawner spawner = Spawner.Create(
            objectToSpawn: typeof(BulletCapsule),
            spawnLimit: 1,
            initialDelay: 0,
            spawnRate: 1,
            maxDistanceToSpawn: 50,
            minDistanceToSpawn: 20
            );

        Spawnable.Pool <BulletCapsule> .Instance.Populate(
            BulletCapsule.Create(0, Player.Create())
            );

        spawner.StartSpawning();
        yield return(new WaitWhile(() => spawner.IsSpawning));

        Assert.Less(Spawnable.Pool <BulletCapsule> .Instance.Count, Spawnable.GLOBAL_SPAWN_LIMIT,
                    "Pool population is not diminishing.");
    }