Ejemplo n.º 1
0
        // Destroy any locations outside of range
        private void CollectLocations(bool collectAll = false)
        {
            // Determine which terrains need to be destroyed
            int mapPixelX, mapPixelY;

            locationKeysToDestroy.Clear();
            foreach (var keyValuePair in locationDict)
            {
                TerrainHelper.ReverseTerrainKey(keyValuePair.Key, out mapPixelX, out mapPixelY);
                if (!IsInRange(mapPixelX, mapPixelY) || collectAll)
                {
                    locationKeysToDestroy.Add(keyValuePair.Key);
                }
            }

            // Destroy the terrains
            for (int i = 0; i < locationKeysToDestroy.Count; i++)
            {
                int        key            = locationKeysToDestroy[i];
                GameObject locationObject = locationDict[key];
                locationObject.SetActive(false);
                StartCoroutine(DestroyLocationIterative(locationObject));
                locationDict.Remove(key);
            }
        }