コード例 #1
0
        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);
        }
コード例 #2
0
 // Instantiate an explosion object where it died.
 public void Explode(Vector3 position, Quaternion rotation)
 {
     if (pooler != null)
     {
         pooler.UseObject(explodePrefab, position, rotation);
     }
 }
コード例 #3
0
ファイル: AmmoLoader.cs プロジェクト: Elam92/CannonGame
        // 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);
        }
コード例 #4
0
        // 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);
        }