コード例 #1
0
        public void DeleteTargetFromAction(SNoteData noteData)
        {
            SNote note = FindNote(noteData);

            if (note == null)
            {
                return;
            }

            notes.Remove(note);
            orderedNotes.Remove(note);
            selectedNotes.Remove(note);

            note.Destroy(this);
            note = null;
        }
コード例 #2
0
        public SNote FindNote(SNoteData data)
        {
            int idx = BinarySearchOrderedNotes(data.beatTime);

            if (idx == -1)
            {
                Debug.LogWarning("Couldn't find note with time " + data.beatTime);
                return(null);
            }

            for (int i = idx; i < orderedNotes.Count; ++i)
            {
                SNote t = orderedNotes[i];
                if (t.data.ID == data.ID)
                {
                    return(t);
                }
            }

            Debug.LogWarning("Couldn't find note with time " + data.beatTime + " and index " + idx);
            return(null);
        }
コード例 #3
0
        //Use when adding a singular target to the project (from the user)
        public void AddNote(float x, float y)
        {
            SNoteData data = new SNoteData {
                x = x, y = y, noteType = SNoteType.LeftHanded, beatTime = GetClosestBeatSnapped(DurationToBeats(time))
            };
            //data.noteType = EditorInput.selectedHand;


            //float tempTime = GetClosestBeatSnapped(DurationToBeats(time));

            /*foreach (SNote target in orderedNotes) {
             *      if (Mathf.Approximately(target.data.beatTime, tempTime) &&
             *          (target.data.handType == EditorInput.selectedHand) &&
             *          (EditorInput.selectedTool != EditorTool.Melee)) return;
             * }*/


            var action = new NSActionAddNote {
                noteData = data
            };

            _actionManager.AddAction(action);
        }
コード例 #4
0
        //Adds a target directly to the timeline. targetData is kept as a reference NOT copied
        public SNote AddNoteFromAction(SNoteData data)
        {
            var timelineTargetIcon = Instantiate(_timelineNotePF, _timelineNotesTrans);
            //timelineTargetIcon.location = TargetIconLocation.Timeline;
            //var transform1 = timelineTargetIcon.transform;
            //transform1.localPosition = new Vector3(targetData.beatTime, 0, 0);

            //Vector3 noteScale = transform1.localScale;
            //noteScale.x = targetScale;
            //transform1.localScale = noteScale;

            //TODO: add timeline notes

            var gridNote = Instantiate(_gridNotePF, _gridNotesTrans);

            gridNote.transform.localPosition = new Vector3(data.x, data.y, data.beatTime);

            SNote note = new SNote(data, gridNote.GetComponent <SNoteBehavior>());

            notes.Add(note);
            orderedNotes = notes.OrderBy(v => v.data.beatTime).ToList();

            //TODO: MORE EVENTS
            //Subscribe to the delete note event so we can delete it if the user wants. And other events.
            //note.DeleteNoteEvent += DeleteTarget;

            //target.TargetSelectEvent += SelectTarget;
            //target.TargetDeselectEvent += DeselectTarget;


            //Trigger all callbacks on the note
            data.Copy(data);


            return(note);
        }
コード例 #5
0
        /*public void Export() {
         *      Debug.Log("Saving: " + activeChart.Name);
         *
         *
         *
         *      //Export map
         *      string dirpath = Application.persistentDataPath;
         *
         *      CueFile export = new CueFile();
         *      export.cues = new List<Cue>();
         *      export.NRCueData = new NRCueData();
         *
         *      foreach (SNote target in orderedNotes) {
         *              if (target.data.beatLength == 0) target.data.beatLength = 120;
         *
         *              if (target.data.behavior == TargetBehavior.Metronome) continue;
         *
         *
         *              float zOffset = NotePosCalc.GetZOffsetForX(target.data.x);
         *
         *              Vector2 fixedPos = NotePosCalc.GetPosForOffGridNote(target.data.position);
         *
         *              var cue = NotePosCalc.ToCue(target, offset, zOffset, fixedPos);
         *
         *              if (target.data.behavior == TargetBehavior.NR_Pathbuilder) {
         *                      export.NRCueData.pathBuilderNoteCues.Add(cue);
         *                      export.NRCueData.pathBuilderNoteData.Add(target.data.pathBuilderData);
         *                      continue;
         *              }
         *
         *              export.cues.Add(cue);
         *      }
         *
         *      switch (difficultyManager.loadedIndex) {
         *              case 0:
         *                      audicaFile.diffs.expert = export;
         *                      break;
         *              case 1:
         *                      audicaFile.diffs.advanced = export;
         *                      break;
         *              case 2:
         *                      audicaFile.diffs.moderate = export;
         *                      break;
         *              case 3:
         *                      audicaFile.diffs.beginner = export;
         *                      break;
         *      }
         *
         *      audicaFile.desc = desc;
         *
         *
         *      AudicaExporter.ExportToAudicaFile(audicaFile);
         *
         *      NotificationShower.AddNotifToQueue(new NRNotification("Map saved successfully!"));
         * }
         *
         */


        public bool LoadSRFile(bool loadRecent = false, string filePath = null)
        {
            //if (mapLoaded && NSSettings.config.saveOnLoadNew) {
            //	Export();
            //}

            if (loadRecent)
            {
                activeChart = null;
                activeChart = SRHandler.Load(PlayerPrefs.GetString("recentFile", null));
                if (activeChart == null)
                {
                    return(false);
                }
            }
            else if (filePath != null)
            {
                activeChart = null;
                activeChart = SRHandler.Load(filePath);
                PlayerPrefs.SetString("recentFile", activeChart.FilePath);
            }
            else
            {
                string[] paths = StandaloneFileBrowser.OpenFilePanel("Synth File",
                                                                     Path.Combine(Application.persistentDataPath), "synth", false);

                if (paths.Length == 0)
                {
                    return(false);
                }

                activeChart = null;

                activeChart = SRHandler.Load(paths[0]);
                PlayerPrefs.SetString("recentFile", paths[0]);
            }

            ResetTimeline();


            // Get song BPM

            /*
             * if (audicaFile.song_mid != null) {
             *      float oneMinuteInMicroseconds = 60000000f;
             *      foreach (var tempo in audicaFile.song_mid.GetTempoMap().Tempo) {
             *              float time = 0.0f;
             *              if (tempo.Time != 0.0f) {
             *                      time = BeatsToDuration(0.0f, tempo.Time / 480.0f, BeatDurationDirection.Forward);
             *              }
             *
             *              SetBPM(time, oneMinuteInMicroseconds / tempo.Value.MicrosecondsPerQuarterNote);
             *      }
             * }
             *
             */

            SetBPM(0, activeChart.BPM);


            //Loads all the sounds.
            StartCoroutine(GetAudioClip($"file://{Application.dataPath}/.cache/{activeChart.AudioName}"));


            //Dictionary<float, List<SR_Note>>.ValueCollection valueColl = activeChart.Track.Expert.Values;

            List <float> keys_sorted = activeChart.Track.Expert.Keys.ToList();

            keys_sorted.Sort();



            foreach (float key in keys_sorted)
            {
                List <SR_Note> srNotes = activeChart.Track.Expert[key];

                foreach (SR_Note srNote in srNotes)
                {
                    SNoteData data = GetNoteDataForSRNote(srNote);
                    AddNoteFromAction(data);
                }

                AddTimeToSFXList(GetTimeByMeasure(key, activeChart.BPM));
            }

            GenerateSFXQueue();

            //Difficulty manager loads stuff now
            mapLoaded = true;

            //difficultyManager.LoadHighestDifficulty();


            //Loaded successfully

            return(true);
        }
コード例 #6
0
        //When loading from cues, use this.
        public SNoteData GetNoteDataForSRNote(SR_Note srNote)
        {
            SNoteData data = new SNoteData(srNote);

            return(data);
        }