Пример #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);
            }
        }
Пример #2
0
        void RaiseJudgement(NoteRectangle NoteRectangle)
        {
            Console.WriteLine(NoteRectangle.Judgement);
            DropperParent.Children.Remove(NoteRectangle.Element);
            RunnningNotes.Remove(NoteRectangle);
            NoteRectangle.IsJudged = true;
            StartJudgeAnim(NoteRectangle.Judgement, NoteRectangle.Note.Lane);

            if (NoteRectangle.Judgement != NoteJudgement.Failed)
            {
                SEPlayer.Play((int)NoteRectangle.Judgement);
            }

            Judged?.Invoke(this,
                           new JudgementEventArgs(NoteRectangle.Judgement, Math.Abs(1 - NoteRectangle.Position), NoteRectangle.Note));
        }