public void AmmoLoader_UseTypeWithCurrentType_ReturnCurrentType() { int index = 0; Projectile expectedResult = ammoLoader.projectileTypes[index]; poolManager.UseObject(expectedResult, Vector3.one, Quaternion.identity).Returns(expectedResult); ammoLoader.SetType(index); Projectile result = ammoLoader.UseType(Vector3.one, Quaternion.identity); Assert.AreEqual(expectedResult, result); }
// Instantiate an explosion object where it died. public void Explode(Vector3 position, Quaternion rotation) { if (pooler != null) { pooler.UseObject(explodePrefab, position, rotation); } }
// Instantiate a projectile to be launched. public Projectile UseType(Vector3 position, Quaternion rotation) { if (currentType == null) { return(null); } return(pooler.UseObject(currentType, position, rotation) as Projectile); }
// Spawn enemies at the location at ground level. private BaseEnemy SpawnOnGround(Vector3 spawnLocation) { // Raycast from above down towards the ground. spawnLocation.y = 100f; RaycastHit hit; if (Physics.Raycast(spawnLocation, Vector3.down, out hit, 1000f, layerMask)) { // Find the y-offset needed to adjust its position to be above the ground. BaseEnemy enemy = enemyPrefabs[Random.Range(0, enemyPrefabs.Length)]; float yOffset = enemy.GetComponent <MeshRenderer>().bounds.extents.y; // Instantiate the enemy and set its target. Vector3 spawnPosition = new Vector3(hit.point.x, hit.point.y + yOffset, hit.point.z); BaseEnemy obj = (BaseEnemy)pooler.UseObject(enemy, spawnPosition, Quaternion.identity); obj.SetTarget(target.transform); return(obj); } return(null); }