コード例 #1
0
        private void DrawNoteImage(RenderContext context, Note note, float x, float y, float r)
        {
            var w = r * 2 * Definitions.NoteImageAspectRatio;
            var h = r * 2;

            x -= w / 2;
            y -= h / 2;

            var loc = NotesLayerUtils.GetIconLocation(DefaultSongColor, note);

            context.DrawImage(NotesImage, x, y, w, h, loc.x, loc.y, Definitions.NoteImageCellWidth, Definitions.NoteImageCellHeight);
        }
コード例 #2
0
        private void DrawTapNote(RenderContext context, double now, Note note)
        {
            if (!NotesLayerUtils.IsNoteOnStage(note, now))
            {
                return;
            }
            float x = NotesLayerUtils.GetNoteXPosition(context, now, note),
                  y = NotesLayerUtils.GetNoteYPosition(context, now, note),
                  r = NotesLayerUtils.GetNoteRadius(now, note);

            DrawNoteImage(context, note, x, y, r);
        }
コード例 #3
0
        private void DrawHoldRibbon(RenderContext context, double now, Note startNote, Note endNote)
        {
            OnStageStatus s1 = NotesLayerUtils.GetNoteOnStageStatus(startNote, now), s2 = NotesLayerUtils.GetNoteOnStageStatus(endNote, now);

            if (s1 == s2 && s1 != OnStageStatus.OnStage)
            {
                return;
            }

            var mesh = new RibbonMesh(context, startNote, endNote, now, ConnectionType.Hold);

            mesh.Fill(RibbonBrush.Brush);
        }
コード例 #4
0
        private static void DrawSyncLine(RenderContext context, double now, Note note1, Note note2)
        {
            if (!NotesLayerUtils.IsNoteOnStage(note1, now) || !NotesLayerUtils.IsNoteOnStage(note2, now))
            {
                return;
            }
            float x1 = NotesLayerUtils.GetNoteXPosition(context, now, note1),
                  y = NotesLayerUtils.GetNoteYPosition(context, now, note2),
                  x2 = NotesLayerUtils.GetNoteXPosition(context, now, note2);
            float r = NotesLayerUtils.GetNoteRadius(now, note2);
            float xLeft = Math.Min(x1, x2), xRight = Math.Max(x1, x2);

            context.DrawLine(SyncLinePen, xLeft + r, y, xRight - r, y);
        }
コード例 #5
0
        private void DrawFlickNote(RenderContext context, double now, Note note)
        {
            if (!NotesLayerUtils.IsNoteOnStage(note, now))
            {
                return;
            }
            if (note.FlickType == NoteFlickType.None)
            {
                Debug.Print("WARNING: Tap/hold/slide note requested in DrawFlickNote.");
                return;
            }
            float x = NotesLayerUtils.GetNoteXPosition(context, now, note),
                  y = NotesLayerUtils.GetNoteYPosition(context, now, note),
                  r = NotesLayerUtils.GetNoteRadius(now, note);

            DrawNoteImage(context, note, x, y, r);
        }
コード例 #6
0
        private void DrawSlideNote(RenderContext context, double now, Note note)
        {
            if (note.FlickType != NoteFlickType.None)
            {
                DrawFlickNote(context, now, note);
                return;
            }

            float x, y, r;

            if (note.IsSlideEnd || NotesLayerUtils.IsNoteOnStage(note, now))
            {
                x = NotesLayerUtils.GetNoteXPosition(context, now, note);
                y = NotesLayerUtils.GetNoteYPosition(context, now, note);
                r = NotesLayerUtils.GetNoteRadius(now, note);
            }
            else if (NotesLayerUtils.IsNotePassed(note, now))
            {
                if (!note.HasNextFlickOrSlide || NotesLayerUtils.IsNotePassed(note.NextFlickOrSlide, now))
                {
                    return;
                }
                var nextSlideNote = note.NextFlickOrSlide;
                if (nextSlideNote == null)
                {
                    // Actually, here is an example of invalid format. :)
                    DrawTapNote(context, now, note);
                    return;
                }
                else
                {
                    var startX = NotesLayerUtils.GetEndXByNotePosition(context.ClientSize, note.FinishPosition);
                    var endX   = NotesLayerUtils.GetEndXByNotePosition(context.ClientSize, nextSlideNote.FinishPosition);
                    y = NotesLayerUtils.GetAvatarYPosition(context.ClientSize);
                    x = (float)((now - note.HitTiming) / (nextSlideNote.HitTiming - note.HitTiming)) * (endX - startX) + startX;
                    r = Definitions.AvatarCircleRadius;
                }
            }
            else
            {
                return;
            }

            DrawNoteImage(context, note, x, y, r);
        }
コード例 #7
0
 private void DrawSlideRibbon(RenderContext context, double now, Note startNote, Note endNote)
 {
     if (endNote.IsFlick)
     {
         DrawFlickRibbon(context, now, startNote, endNote);
         return;
     }
     if (startNote.IsSlideEnd || NotesLayerUtils.IsNoteOnStage(startNote, now))
     {
         DrawHoldRibbon(context, now, startNote, endNote);
         return;
     }
     if (NotesLayerUtils.IsNotePassed(startNote, now))
     {
         var nextSlideNote = startNote.NextFlickOrSlide;
         if (nextSlideNote == null)
         {
             // Actually, here is an example of invalid format. :)
             DrawHoldRibbon(context, now, startNote, endNote);
             return;
         }
         if (NotesLayerUtils.IsNotePassed(nextSlideNote, now))
         {
             return;
         }
         var   startX = NotesLayerUtils.GetEndXByNotePosition(context.ClientSize, startNote.FinishPosition);
         var   endX   = NotesLayerUtils.GetEndXByNotePosition(context.ClientSize, nextSlideNote.FinishPosition);
         var   y1     = NotesLayerUtils.GetAvatarYPosition(context.ClientSize);
         var   x1     = (float)((now - startNote.HitTiming) / (nextSlideNote.HitTiming - startNote.HitTiming)) * (endX - startX) + startX;
         float t1     = NotesLayerUtils.GetNoteTransformedTime(now, startNote, clampComing: true, clampPassed: true);
         float t2     = NotesLayerUtils.GetNoteTransformedTime(now, endNote, clampComing: true, clampPassed: true);
         float tmid   = (t1 + t2) * 0.5f;
         float x2     = NotesLayerUtils.GetNoteXPosition(context, endNote.FinishPosition, t2);
         float xmid   = NotesLayerUtils.GetNoteXPosition(context, endNote.FinishPosition, tmid);
         float y2     = NotesLayerUtils.GetNoteYPosition(context, t2);
         float ymid   = NotesLayerUtils.GetNoteYPosition(context, tmid);
         NotesLayerUtils.GetBezierFromQuadratic(x1, xmid, x2, out float xcontrol1, out float xcontrol2);
         NotesLayerUtils.GetBezierFromQuadratic(y1, ymid, y2, out float ycontrol1, out float ycontrol2);
         // TODO:
         //context.DrawBezier(ConnectionPen, x1, y1, xcontrol1, ycontrol1, xcontrol2, ycontrol2, x2, y2);
     }
 }
コード例 #8
0
        protected override void UpdateInternal(GameTime gameTime)
        {
            base.UpdateInternal(gameTime);

            var dict = _statusList;
            var now  = gameTime.Total.TotalSeconds;

            foreach (var s in dict)
            {
                var oldState = s.Value;
                var newState = NotesLayerUtils.GetNoteOnStageStatus(s.Key, now);
                if (oldState == newState)
                {
                    continue;
                }
                if (newState == OnStageStatus.Passed && oldState == OnStageStatus.OnStage)
                {
                    // TODO: Play sound.
                }
                dict[s.Key] = newState;
            }
        }
コード例 #9
0
        private void DrawNotes(RenderContext context, double now, IReadOnlyList <Note> notes, int startIndex, int endIndex)
        {
            if (startIndex < 0)
            {
                return;
            }
            var selectedNotes = notes.Skip(startIndex).Take(endIndex - startIndex + 1);

            foreach (var note in selectedNotes)
            {
                switch (note.Type)
                {
                case NoteType.TapOrFlick:
                case NoteType.Hold:
                case NoteType.Slide:
                    if (note.IsSync)
                    {
                        DrawSyncLine(context, now, note, note.SyncPair);
                    }
                    break;
                }
                switch (note.Type)
                {
                case NoteType.TapOrFlick:
                    if (note.IsFlick)
                    {
                        if (note.HasNextFlickOrSlide)
                        {
                            DrawFlickRibbon(context, now, note, note.NextFlickOrSlide);
                        }
                    }
                    break;

                case NoteType.Hold:
                    if (note.IsHoldStart)
                    {
                        DrawHoldRibbon(context, now, note, note.HoldPair);
                    }
                    if (note.IsHoldEnd)
                    {
                        if (!NotesLayerUtils.IsNoteOnStage(note.HoldPair, now))
                        {
                            DrawHoldRibbon(context, now, note.HoldPair, note);
                        }
                    }
                    break;

                case NoteType.Slide:
                    if (note.HasNextFlickOrSlide)
                    {
                        DrawSlideRibbon(context, now, note, note.NextFlickOrSlide);
                    }
                    if (note.HasPrevFlickOrSlide)
                    {
                        if (!NotesLayerUtils.IsNoteOnStage(note.PrevFlickOrSlide, now))
                        {
                            DrawSlideRibbon(context, now, note.PrevFlickOrSlide, note);
                        }
                    }
                    break;
                }
                switch (note.Type)
                {
                case NoteType.TapOrFlick:
                    if (note.FlickType == NoteFlickType.None)
                    {
                        if (note.IsHoldEnd)
                        {
                            DrawHoldNote(context, now, note);
                        }
                        else
                        {
                            DrawTapNote(context, now, note);
                        }
                    }
                    else
                    {
                        DrawFlickNote(context, now, note);
                    }
                    break;

                case NoteType.Hold:
                    DrawHoldNote(context, now, note);
                    break;

                case NoteType.Slide:
                    DrawSlideNote(context, now, note);
                    break;
                }
            }
        }