示例#1
0
        /// <summary>
        /// Creates a new chart object.
        /// </summary>
        /// <param name="song">The song to associate this chart with.</param>
        /// <param name="name">The name of the chart (easy single, expert double guitar, etc.</param>
        public Chart(Song song, GameMode gameMode, string name = "")
        {
            _song         = song;
            _chartObjects = new List <ChartObject>();
            chartObjects  = new ReadOnlyList <ChartObject>(_chartObjects);
            _gameMode     = gameMode;

            notes     = new SongObjectCache <Note>();       // new Note[0];
            starPower = new SongObjectCache <Starpower>();  // new Starpower[0];
            events    = new SongObjectCache <ChartEvent>(); // new ChartEvent[0];

            _note_count = 0;

            this.name = name;
        }
        public static void UpdateCacheList <T, U>(SongObjectCache <T> cache, List <U> objectsToCache)
            where U : SongObject
            where T : U
        {
            var cacheObjectList = cache.EditCache();

            cacheObjectList.Clear();

            foreach (U objectToCache in objectsToCache)
            {
                if (objectToCache.GetType() == typeof(T))
                {
                    cacheObjectList.Add(objectToCache as T);
                }
            }
        }
        /// <summary>
        /// Default constructor for a new chart. Initialises all lists and adds locked bpm and timesignature objects.
        /// </summary>
        public Song()
        {
            _events    = new List <Event>();
            _syncTrack = new List <SyncTrack>();

            eventsAndSections = new ReadOnlyList <Event>(_events);
            syncTrack         = new ReadOnlyList <SyncTrack>(_syncTrack);

            events         = new SongObjectCache <Event>();
            sections       = new SongObjectCache <Section>();
            bpms           = new SongObjectCache <BPM>();
            timeSignatures = new SongObjectCache <TimeSignature>();

            Add(new BPM());
            Add(new TimeSignature());

            // Chart initialisation
            int numberOfInstruments = EnumX <Instrument> .Count - 1;     // Don't count the "Unused" instrument

            charts = new Chart[numberOfInstruments * EnumX <Difficulty> .Count];

            for (int i = 0; i < charts.Length; ++i)
            {
                Instrument instrument = (Instrument)(i / EnumX <Difficulty> .Count);
                charts[i] = new Chart(this, instrument);
            }

            // Set the name of the chart
            foreach (Instrument instrument in EnumX <Instrument> .Values)
            {
                if (instrument == Instrument.Unrecognised)
                {
                    continue;
                }

                string instrumentName = string.Empty;
                switch (instrument)
                {
                case (Instrument.Guitar):
                    instrumentName += "Guitar - ";
                    break;

                case (Instrument.GuitarCoop):
                    instrumentName += "Guitar - Co-op - ";
                    break;

                case (Instrument.Bass):
                    instrumentName += "Bass - ";
                    break;

                case (Instrument.Rhythm):
                    instrumentName += "Rhythm - ";
                    break;

                case (Instrument.Keys):
                    instrumentName += "Keys - ";
                    break;

                case (Instrument.Drums):
                    instrumentName += "Drums - ";
                    break;

                case (Instrument.GHLiveGuitar):
                    instrumentName += "GHLive Guitar - ";
                    break;

                case (Instrument.GHLiveBass):
                    instrumentName += "GHLive Bass - ";
                    break;

                default:
                    continue;
                }

                foreach (Difficulty difficulty in EnumX <Difficulty> .Values)
                {
                    GetChart(instrument, difficulty).name = instrumentName + difficulty.ToString();
                }
            }

            for (int i = 0; i < audioLocations.Length; ++i)
            {
                audioLocations[i] = string.Empty;
            }

            UpdateCache();
        }