示例#1
0
        public int[] GetAllUseableLevelIndices()
        {
            var allLevelFileNames = Persist.GetAllLevelFileNames();
            var levelIndices      = new int[allLevelFileNames.Count];

            for (var index = 0; index < allLevelFileNames.Count; index++)
            {
                var fileName     = allLevelFileNames[index];
                var indexOfLevel = -1;
                if (!int.TryParse(fileName[fileName.Length - 1].ToString(), out indexOfLevel))
                {
                    Debug.LogError("Gelesene Level: " + fileName + "\nIntepretierter Index = " + indexOfLevel);
                    throw new Exception("Parsen oder sonstwas schief gelaufen :o");
                }
                levelIndices[index] = indexOfLevel;
            }

            return(levelIndices);

            //Linq Version
            //return Persist.GetAllLevelFileNames().Select(
            //    x => {
            //        var fileName = Path.GetFileNameWithoutExtension(x);
            //        return Int32.Parse(fileName[fileName.Length - 1].ToString());
            //    }).ToArray();
        }