private void GenerateObstacles() { // Create randomly sized and located attachables for (int i = 0; i < attachableCount; ++i) { Vector3 randomPosition = Vector3.zero; Vector2 location = Random.insideUnitCircle * spanRadius; randomPosition.x = location.x; randomPosition.z = location.y; randomPosition.y = 10f; float size = Random.Range(1, 4); GameObject attachableObject = ObjectPoolController.Instance.Retrieve(ResourceConstant.Collectable, randomPosition); attachableObject.transform.localScale = new Vector3(size, size, size); } // Create randomly sized and located destructables for (int i = 0; i < destructableCount; ++i) { Vector3 randomPosition = Vector3.zero; Vector2 location = Random.insideUnitCircle * spanRadius; randomPosition.x = location.x; randomPosition.z = location.y; randomPosition.y = 10f; float size = Random.Range(1, 4); GameObject destructableObject = ObjectPoolController.Instance.Retrieve(ResourceConstant.Destructable, randomPosition); destructableObject.transform.localScale = new Vector3(size, size, size); DestructableController controller = destructableObject.GetComponent <DestructableController>(); controller.damage = size * 5; controller.explosionForce = size * 10; controller.explosionRadius = size * 10; } }
public virtual void OnDestructableCollision(Collision collision, DestructableController destructableController) { destructableController.Collide(collision, controller); controller.ExplodeAttached(); }