/* * Returns the first powerup in the list * */ public PowerupBase GetPowerUp(PowerUpsDirectoryType type) { // the Powerup we're potientially returning PowerupBase currPU = null; if (!_allowSpawn) { return(null); } // testing with custom memory manager /* * Using the passed in type, use type as index to the next available type */ PowerupMemoryList currList = null; currList = objectListMemTypes[(int)type]; if (currList != null) { currPU = objectListMemTypes[(int)type].GetNext(); if (currPU) { currPU.SetIsBackAtSpawner(false); poolUnavailablePowerUps.Add(currPU); } } return(currPU); }
/* * we want a list of lists. Each item in the list Indexed by the Powerup Directory * Each item contains a list of the available pool of powerups of that type * Allocate the amount of each type index * We can then retrieve a powerup by the index and returning the first object available * if none is available it will create one and return the new one. * */ //public PowerUpsDirectory puDirectory; // Use this for initialization void Start() { // set the instance PUF = this; poolUnavailablePowerUps = new List <PowerupBase>(); // poolHashTableAvailablePowerups = new Dictionary<int, PowerupRoot>(); objectListMemTypes = new List <PowerupMemoryList>(); Transform myTransform = transform; /* * Testing with custom 2d Table * For each type of powerup, we create a list that contains a list of powerup objects * */ for (int i = 0; i < powerUpRootTypes.Capacity; i++) { // the memory list PowerupMemoryList curr = new PowerupMemoryList(); // Instantiate(powerupMemoryListPrefabRef, Vector3.zero, Quaternion.identity) as PowerupMemoryList; // when creating // set the type of list is to carry curr.SetType((PowerUpsDirectoryType)i); // this creates all the default starting allocation and its prefab of that type index curr.CreateMemObjects(startPoolWithTypeCount[i], powerUpRootTypes[i], myTransform); //Parent? // add the new list to the list of lists. objectListMemTypes.Add(curr); } }