Exemplo n.º 1
0
        public bool RunNote(SugaEngine.Note Note, TimeSpan Duration)
        {
            foreach (var note in RunnningNotes)
            {
                if (note.Note == Note)
                {
                    return(false);
                }
            }

            Rectangle     rect = InitRect(Note.Lane);
            NoteRectangle nr   = new NoteRectangle(Note, rect);

            double ybarpos = DropperParent.ActualHeight - (HitBarR.ActualHeight / 2) - HitBarR.Margin.Bottom;
            double ratio   = ybarpos / DropperParent.ActualHeight;

            Thickness?from = GetMarginForRect(0);
            Thickness?bar  = GetMarginForRect(ratio);
            Thickness?to   = GetMarginForRect(1);

            double actTime = Duration.TotalMilliseconds * ratio;

            if (from.HasValue && to.HasValue && bar.HasValue)
            {
                ThicknessAnimation ta = new ThicknessAnimation(rect, from.Value, to.Value, Duration.TotalMilliseconds);

                EventHandler <ThicknessEventArgs> changed = null;
                changed = (sender, e) =>
                {
                    nr.Position  = (e.Current.Top + (nr.Element.ActualHeight / 2)) / ybarpos;
                    nr.Judgement = Judge(nr.Position);
                };
                ta.Changed += changed;

                EventHandler ev = null;
                ev = (sender, e) =>
                {
                    if (!nr.IsJudged)
                    {
                        nr.Judgement = NoteJudgement.Failed;
                        RaiseJudgement(nr);
                    }
                    ta.Completed -= ev;
                    ta.Changed   -= changed;
                };
                ta.Completed += ev;

                RunnningNotes.Add(nr);
                ta.BeginAnimation();
                return(true);
            }
            else
            {
                return(false);
            }
        }
Exemplo n.º 2
0
 public JudgementEventArgs(NoteJudgement judgement, double difference, SugaEngine.Note note)
 {
     Judgement  = judgement;
     Difference = difference;
     Note       = note;
 }
Exemplo n.º 3
0
 public NoteRectangle(SugaEngine.Note Note, Rectangle Element)
 {
     this.Note    = Note;
     this.Element = Element;
 }