Beispiel #1
0
        /// <summary> Gets a SoundyController from the Pool, or creates a new one if all the available controllers are in use </summary>
        public static SoundyController GetControllerFromPool()
        {
            RemoveNullControllersFromThePool();
            if (Pool.Count <= 0)
            {
                return(SoundyController.GetController()); //the pool does not have any controllers in it -> create and return a new controller
            }
            SoundyController controller = Pool[0];        //assign the first found controller

            Pool.Remove(controller);                      //remove the assigned controller from the pool
            controller.gameObject.SetActive(true);
            return(controller);                           //return a reference to the controller
        }
Beispiel #2
0
 /// <summary> Creates a set number of SoundyController and adds them to the Pool </summary>
 /// <param name="numberOfControllers"> How many controllers should be created </param>
 public static void PopulatePool(int numberOfControllers)
 {
     RemoveNullControllersFromThePool();
     if (numberOfControllers < 1)
     {
         return;                          //sanity check
     }
     for (int i = 0; i < numberOfControllers; i++)
     {
         PutControllerInPool(SoundyController.GetController());
     }
     if (Instance.DebugComponent)
     {
         DDebug.Log("Populate Pool - Added " + numberOfControllers + " Controllers to the Pool - " + Pool.Count + " Controllers Available", Instance);
     }
 }
 /// <summary> Create a new SoundyController in the current scene and get a reference to it </summary>
 public static SoundyController GetController()
 {
     return(SoundyController.GetController());
 }