Ejemplo n.º 1
0
        public AllLevels GetLevels(ISaver saver, Preset[] levelPresets)
        {
            int lastID = -1;

            LevelParameters[]         param = new LevelParameters[levelPresets.Length];
            SavingParametersContainer spc;
            bool hasData = saver != null && saver.HasData();

            if (hasData)
            {
                spc = saver.Load();
            }
            else
            {
                spc = new SavingParametersContainer();
                spc.SavingParameters = new SavingParameters[0];
            }

            bool find = false;

            for (int i = 0; i < param.Length; ++i)
            {
                param[i]        = new LevelParameters();
                param[i].Preset = levelPresets[i];
                find            = false;
                for (int j = 0; j < spc.SavingParameters.Length; ++j)
                {
                    if (spc.SavingParameters[j].ID == param[i].Preset.ID)
                    {
                        param[i].SavedParameters = spc.SavingParameters[j];
                        find = true;
                        break;
                    }
                }
                if (!find)
                {
                    param[i].SavedParameters = GenerateLevel(param[i].Preset.ID);
                }
                if (lastID < param[i].Preset.ID)
                {
                    lastID = param[i].Preset.ID;
                }
            }
            if (!hasData)
            {
                SetFirstOpen(param);
            }
            return(new AllLevels(param, lastID));
        }
Ejemplo n.º 2
0
        public LevelParameters GetNextLevelByID(int id)
        {
            if (id == m_LastLevelID)
            {
                return(null);
            }
            int             next = m_LastLevelID;
            LevelParameters lvl  = null;

            for (int i = 0; i < Parameters.Length; ++i)
            {
                if (Parameters[i].Preset.ID > id && Parameters[i].Preset.ID <= next)
                {
                    lvl  = Parameters[i];
                    next = Parameters[i].Preset.ID;
                }
            }
            return(lvl);
        }