Exemple #1
0
    public float GetNoteChartY(ChartModel.Note note)
    {
        var page = Model.page_list[note.page_index];

        return((float)(page.scan_line_direction * ((note.tick - page.start_tick) * 1.0f /
                                                   (page.end_tick - page.start_tick))));
    }
Exemple #2
0
 public Color GetRingColorOverride(ChartModel.Note note)
 {
     if (note.Override.RingColor != null)
     {
         return(note.Override.RingColor.Value);
     }
     return(GlobalRingColorOverride);
 }
Exemple #3
0
 public Color GetFillColor(ChartModel.Note note)
 {
     if (!Context.Player.Settings.UseFillColorForDragChildNodes &&
         ((NoteType)note.type == NoteType.DragChild || (NoteType)note.type == NoteType.CDragChild))
     {
         return(GetRingColor(note));
     }
     return(note.UseAlternativeColor() ? NoteFillColors[(NoteType)note.type][0] : NoteFillColors[(NoteType)note.type][1]);
 }
Exemple #4
0
 public Color GetFillColorOverride(ChartModel.Note note)
 {
     if (note.Override.FillColor != null)
     {
         return(note.Override.FillColor.Value);
     }
     return(note.UseAlternativeColor()
         ? GlobalFillColorsOverride[(NoteType)note.type][0]
         : GlobalFillColorsOverride[(NoteType)note.type][1]);
 }
Exemple #5
0
 public DragLineElement SpawnDragLine(ChartModel.Note from, ChartModel.Note to)
 {
     if (SpawnedDragLines.ContainsKey(from.id))
     {
         return(SpawnedDragLines[from.id]);
     }
     return(SpawnedDragLines[from.id] = Spawn(dragLinePoolItem, new PoolItemInstantiateProvider(),
                                              new DragLineSpawnProvider {
         From = from, To = to
     }));
 }
Exemple #6
0
    public float GetNoteScreenY(ChartModel.Note note)
    {
        var page = Model.page_list[note.page_index];

        return((float)(
                   verticalRatio * page.scan_line_direction *
                   (-baseSize + 2.0f *
                    baseSize *
                    (note.tick - page.start_tick) * 1.0f /
                    (page.end_tick - page.start_tick))
                   + verticalOffset));
    }
Exemple #7
0
    public void SetData(ChartModel.Note fromNoteModel, ChartModel.Note toNoteModel)
    {
        IsCollected = false;

        FromNoteModel = fromNoteModel;
        ToNoteModel   = toNoteModel;
        spriteRenderer.material.SetFloat(MaterialEnd, 0.0f);
        spriteRenderer.material.SetFloat(MaterialStart, 0.0f);
        UpdateTransform();
        spriteRenderer.sortingOrder = fromNoteModel.id;
        Game.onGameUpdate.AddListener(OnGameUpdate);
    }
Exemple #8
0
    public Note SpawnNote(ChartModel.Note model)
    {
        if (SpawnedNotes.ContainsKey(model.id))
        {
            return(SpawnedNotes[model.id]);
        }
        var note = Spawn(notePoolItems[(NoteType)model.type], new NoteInstantiateProvider {
            Type = (NoteType)model.type
        }, new NoteSpawnProvider {
            Model = model
        });

        SpawnedNotes[model.id] = note;
        return(note);
    }
Exemple #9
0
    public float CalculateNoteSpeed(ChartModel.Note note)
    {
        var page         = Model.page_list[note.page_index];
        var previousPage = Model.page_list[note.page_index - 1];
        var pageRatio    = (float)(
            1.0f * (note.tick - page.actual_start_tick) /
            (page.end_tick -
             page.actual_start_tick));
        var tempo =
            (page.end_time -
             page.actual_start_time) * pageRatio +
            (previousPage.end_time -
             previousPage.actual_start_time) * (1.367f - pageRatio);

        return(tempo >= 1.367f ? 1.0f : 1.367f / tempo);
    }
Exemple #10
0
    public void Collect()
    {
        if (IsCollected)
        {
            return;
        }
        IsCollected = true;

        Game.ObjectPool.CollectDragLine(this);
        Game.onGameUpdate.RemoveListener(OnGameUpdate);
        FromNoteModel = default;
        ToNoteModel   = default;
        hasFromNote   = default;
        fromNote      = default;
        hasToNote     = default;
        toNote        = default;
        introRatio    = default;
        outroRatio    = default;
        length        = default;
    }
Exemple #11
0
        public override async UniTask Initialize()
        {
            if (Component.ParentId != null)
            {
                throw new InvalidOperationException($"Storyboard: NoteController {Component.Id} cannot have a parent");
            }

            var note = Component.States[0].Note;

            if (note == null)
            {
                throw new ArgumentNullException();
            }
            if (!MainRenderer.Game.Chart.Model.note_map.ContainsKey(note.Value))
            {
                throw new ArgumentException($"Storyboard: Note {note.Value} does not exist");
            }

            Note = MainRenderer.Game.Chart.Model.note_map[note.Value];

            // TODO: Optimize this? Don't generate transforms if not in use
            notePlaceholderTransform = new GameObject("NoteControllerPlaceholder_" + Note.id).transform;
            Clear();
        }
Exemple #12
0
    public ChartModel FromLegacyChart(string text)
    {
        // Parse

        var pageDuration = 0f;
        var pageShift    = 0f;
        var tmpNotes     = new Dictionary <int, LegacyNote>();

        foreach (var line in text.Split('\n'))
        {
            var data = line.Split((char[])null, StringSplitOptions.RemoveEmptyEntries);
            if (data.Length == 0)
            {
                continue;
            }
            var type = data[0];
            switch (type)
            {
            case "PAGE_SIZE":
                pageDuration = float.Parse(data[1]);
                break;

            case "PAGE_SHIFT":
                pageShift = float.Parse(data[1]);
                break;

            case "NOTE":
                var note = new LegacyNote(int.Parse(data[1]), float.Parse(data[2]), float.Parse(data[3]),
                                          float.Parse(data[4]), false);
                tmpNotes.Add(int.Parse(data[1]), note);
                if (note.Duration > 0)
                {
                    note.Type = LegacyNoteType.Hold;
                }
                break;

            case "LINK":
                var notesInChain = new List <LegacyNote>();
                for (var i = 1; i < data.Length; i++)
                {
                    int id;
                    if (!int.TryParse(data[i], out id))
                    {
                        continue;
                    }
                    note      = tmpNotes[id];
                    note.Type = LegacyNoteType.Drag;

                    if (!notesInChain.Contains(note))
                    {
                        notesInChain.Add(note);
                    }
                }

                for (var i = 0; i < notesInChain.Count - 1; i++)
                {
                    notesInChain[i].ConnectedNote = notesInChain[i + 1];
                }

                notesInChain[0].IsChainHead = true;
                break;
            }
        }

        pageShift += pageDuration;

        // Calculate chronological note ids
        var sortedNotes = tmpNotes.Values.ToList();

        sortedNotes.Sort((a, b) => a.Time.CompareTo(b.Time));
        var chronologicalIds = sortedNotes.Select(note => note.OriginalId).ToList();

        var notes = new Dictionary <int, LegacyNote>();

        // Recalculate note ids from original ids
        var newId = 0;

        foreach (var noteId in chronologicalIds)
        {
            tmpNotes[noteId].Id = newId;
            notes[newId]        = tmpNotes[noteId];
            newId++;
        }

        // Reset chronological ids
        chronologicalIds.Clear();
        for (var i = 0; i < tmpNotes.Count; i++)
        {
            chronologicalIds.Add(i);
        }

        // Convert

        const int timeBase = 480;

        var root = new ChartModel();

        root.time_base = 480;

        var tempo = new ChartModel.Tempo();

        tempo.tick = 0;
        var tempoValue = (long)(pageDuration * 1000000f);

        tempo.value     = tempoValue;
        root.tempo_list = new List <ChartModel.Tempo> {
            tempo
        };

        if (pageShift < 0)
        {
            pageShift = pageShift + 2 * pageDuration;
        }

        var pageShiftTickOffset = pageShift / pageDuration * timeBase;

        var noteList = new List <ChartModel.Note>();
        var page     = 0;

        foreach (var note in notes.Values)
        {
            var obj = new ChartModel.Note();
            obj.id = note.Id;
            switch (note.Type)
            {
            case LegacyNoteType.Click:
                obj.type = (int)NoteType.Click;
                break;

            case LegacyNoteType.Drag:
                obj.type = note.IsChainHead ? (int)NoteType.DragHead : (int)NoteType.DragChild;
                break;

            case LegacyNoteType.Hold:
                obj.type = (int)NoteType.Hold;
                break;
            }

            obj.x = note.X;
            var ti = note.Time * timeBase * 1000000 / tempoValue + pageShiftTickOffset;
            obj.tick       = ti;
            obj.hold_tick  = note.Duration * timeBase * 1000000 / tempoValue;
            page           = Mathf.FloorToInt(ti / timeBase);
            obj.page_index = page;
            if (note.Type == LegacyNoteType.Drag)
            {
                obj.next_id = note.ConnectedNote != null ? note.ConnectedNote.Id : -1;
            }
            else
            {
                obj.next_id = 0;
            }

            noteList.Add(obj);
        }

        root.note_list = noteList;

        var pageList  = new List <ChartModel.Page>();
        var direction = false;
        var t         = 0;

        for (var i = 0; i <= page; i++)
        {
            var obj = new ChartModel.Page();
            obj.scan_line_direction = direction ? 1 : -1;
            direction      = !direction;
            obj.start_tick = t;
            t           += timeBase;
            obj.end_tick = t;
            pageList.Add(obj);
        }

        root.page_list = pageList;

        root.music_offset = pageShiftTickOffset / timeBase / 1000000 * tempoValue;
        return(root);
    }
Exemple #13
0
 public Color GetRingColor(ChartModel.Note note)
 {
     return(note.UseAlternativeColor() ? NoteRingColors[(NoteType)note.type][0] : NoteRingColors[(NoteType)note.type][1]);
 }