Esempio n. 1
0
        public DrawableTaikoHit(TaikoHitObject h)
        {
            this.h = h;

            Origin = Anchor.Centre;
            Scale  = new Vector2(0.2f);
            RelativePositionAxes = Axes.Both;
            Position             = new Vector2(1.1f, 0.5f);
        }
Esempio n. 2
0
        private void createAutoReplay()
        {
            bool hitButton = true;

            Frames.Add(new ReplayFrame(-100000, null, null, ReplayButtonState.None));
            Frames.Add(new ReplayFrame(beatmap.HitObjects[0].StartTime - 1000, null, null, ReplayButtonState.None));

            for (int i = 0; i < beatmap.HitObjects.Count; i++)
            {
                TaikoHitObject h = beatmap.HitObjects[i];

                ReplayButtonState button;

                IHasEndTime endTimeData = h as IHasEndTime;
                double      endTime     = endTimeData?.EndTime ?? h.StartTime;

                Swell    swell    = h as Swell;
                DrumRoll drumRoll = h as DrumRoll;
                Hit      hit      = h as Hit;

                if (swell != null)
                {
                    int    d       = 0;
                    int    count   = 0;
                    int    req     = swell.RequiredHits;
                    double hitRate = swell.Duration / req;
                    for (double j = h.StartTime; j < endTime; j += hitRate)
                    {
                        switch (d)
                        {
                        default:
                            button = ReplayButtonState.Left1;
                            break;

                        case 1:
                            button = ReplayButtonState.Right1;
                            break;

                        case 2:
                            button = ReplayButtonState.Left2;
                            break;

                        case 3:
                            button = ReplayButtonState.Right2;
                            break;
                        }

                        Frames.Add(new ReplayFrame(j, null, null, button));
                        d = (d + 1) % 4;
                        if (++count > req)
                        {
                            break;
                        }
                    }
                }
                else if (drumRoll != null)
                {
                    foreach (var tick in drumRoll.Ticks)
                    {
                        Frames.Add(new ReplayFrame(tick.StartTime, null, null, hitButton ? ReplayButtonState.Left1 : ReplayButtonState.Left2));
                        hitButton = !hitButton;
                    }
                }
                else if (hit != null)
                {
                    if (hit is CentreHit)
                    {
                        if (h.IsStrong)
                        {
                            button = ReplayButtonState.Right1 | ReplayButtonState.Right2;
                        }
                        else
                        {
                            button = hitButton ? ReplayButtonState.Right1 : ReplayButtonState.Right2;
                        }
                    }
                    else
                    {
                        if (h.IsStrong)
                        {
                            button = ReplayButtonState.Left1 | ReplayButtonState.Left2;
                        }
                        else
                        {
                            button = hitButton ? ReplayButtonState.Left1 : ReplayButtonState.Left2;
                        }
                    }

                    Frames.Add(new ReplayFrame(h.StartTime, null, null, button));
                }
                else
                {
                    throw new Exception("Unknown hit object type.");
                }

                Frames.Add(new ReplayFrame(endTime + KEY_UP_DELAY, null, null, ReplayButtonState.None));

                if (i < beatmap.HitObjects.Count - 1)
                {
                    double waitTime = beatmap.HitObjects[i + 1].StartTime - 1000;
                    if (waitTime > endTime)
                    {
                        Frames.Add(new ReplayFrame(waitTime, null, null, ReplayButtonState.None));
                    }
                }

                hitButton = !hitButton;
            }
        }
Esempio n. 3
0
        public override Replay Generate()
        {
            bool hitButton = true;

            Frames.Add(new TaikoReplayFrame(-100000));
            Frames.Add(new TaikoReplayFrame(Beatmap.HitObjects[0].StartTime - 1000));

            for (int i = 0; i < Beatmap.HitObjects.Count; i++)
            {
                TaikoHitObject h = Beatmap.HitObjects[i];

                IHasEndTime endTimeData = h as IHasEndTime;
                double      endTime     = endTimeData?.EndTime ?? h.StartTime;

                switch (h)
                {
                case Swell swell:
                {
                    int    d       = 0;
                    int    count   = 0;
                    int    req     = swell.RequiredHits;
                    double hitRate = Math.Min(swell_hit_speed, swell.Duration / req);

                    for (double j = h.StartTime; j < endTime; j += hitRate)
                    {
                        TaikoAction action;

                        switch (d)
                        {
                        default:
                        case 0:
                            action = TaikoAction.LeftCentre;
                            break;

                        case 1:
                            action = TaikoAction.LeftRim;
                            break;

                        case 2:
                            action = TaikoAction.RightCentre;
                            break;

                        case 3:
                            action = TaikoAction.RightRim;
                            break;
                        }

                        Frames.Add(new TaikoReplayFrame(j, action));
                        d = (d + 1) % 4;
                        if (++count == req)
                        {
                            break;
                        }
                    }

                    break;
                }

                case DrumRoll drumRoll:
                {
                    foreach (var tick in drumRoll.NestedHitObjects.OfType <DrumRollTick>())
                    {
                        Frames.Add(new TaikoReplayFrame(tick.StartTime, hitButton ? TaikoAction.LeftCentre : TaikoAction.RightCentre));
                        hitButton = !hitButton;
                    }

                    break;
                }

                case Hit hit:
                {
                    TaikoAction[] actions;

                    if (hit is CentreHit)
                    {
                        actions = h.IsStrong
                                ? new[] { TaikoAction.LeftCentre, TaikoAction.RightCentre }
                                : new[] { hitButton?TaikoAction.LeftCentre : TaikoAction.RightCentre };
                    }
                    else
                    {
                        actions = h.IsStrong
                                ? new[] { TaikoAction.LeftRim, TaikoAction.RightRim }
                                : new[] { hitButton?TaikoAction.LeftRim : TaikoAction.RightRim };
                    }

                    Frames.Add(new TaikoReplayFrame(h.StartTime, actions));
                    break;
                }

                default:
                    throw new InvalidOperationException("Unknown hit object type.");
                }

                var nextHitObject = GetNextObject(i); // Get the next object that requires pressing the same button

                bool canDelayKeyUp = nextHitObject == null || nextHitObject.StartTime > endTime + KEY_UP_DELAY;

                double calculatedDelay = canDelayKeyUp ? KEY_UP_DELAY : (nextHitObject.StartTime - endTime) * 0.9;

                Frames.Add(new TaikoReplayFrame(endTime + calculatedDelay));

                if (i < Beatmap.HitObjects.Count - 1)
                {
                    double waitTime = Beatmap.HitObjects[i + 1].StartTime - 1000;
                    if (waitTime > endTime)
                    {
                        Frames.Add(new TaikoReplayFrame(waitTime));
                    }
                }

                hitButton = !hitButton;
            }

            return(Replay);
        }
Esempio n. 4
0
        public override Replay Generate()
        {
            bool hitButton = true;

            Frames.Add(new TaikoReplayFrame(-100000));
            Frames.Add(new TaikoReplayFrame(Beatmap.HitObjects[0].StartTime - 1000));

            for (int i = 0; i < Beatmap.HitObjects.Count; i++)
            {
                TaikoHitObject h = Beatmap.HitObjects[i];

                IHasEndTime endTimeData = h as IHasEndTime;
                double      endTime     = endTimeData?.EndTime ?? h.StartTime;

                Swell    swell    = h as Swell;
                DrumRoll drumRoll = h as DrumRoll;
                Hit      hit      = h as Hit;

                if (swell != null)
                {
                    int    d       = 0;
                    int    count   = 0;
                    int    req     = swell.RequiredHits;
                    double hitRate = Math.Min(swell_hit_speed, swell.Duration / req);

                    for (double j = h.StartTime; j < endTime; j += hitRate)
                    {
                        TaikoAction action;

                        switch (d)
                        {
                        default:
                        case 0:
                            action = TaikoAction.LeftCentre;
                            break;

                        case 1:
                            action = TaikoAction.LeftRim;
                            break;

                        case 2:
                            action = TaikoAction.RightCentre;
                            break;

                        case 3:
                            action = TaikoAction.RightRim;
                            break;
                        }

                        Frames.Add(new TaikoReplayFrame(j, action));
                        d = (d + 1) % 4;
                        if (++count == req)
                        {
                            break;
                        }
                    }
                }
                else if (drumRoll != null)
                {
                    foreach (var tick in drumRoll.NestedHitObjects.OfType <DrumRollTick>())
                    {
                        Frames.Add(new TaikoReplayFrame(tick.StartTime, hitButton ? TaikoAction.LeftCentre : TaikoAction.RightCentre));
                        hitButton = !hitButton;
                    }
                }
                else if (hit != null)
                {
                    TaikoAction[] actions;

                    if (hit is CentreHit)
                    {
                        actions = h.IsStrong
                            ? new[] { TaikoAction.LeftCentre, TaikoAction.RightCentre }
                            : new[] { hitButton?TaikoAction.LeftCentre : TaikoAction.RightCentre };
                    }
                    else
                    {
                        actions = h.IsStrong
                            ? new[] { TaikoAction.LeftRim, TaikoAction.RightRim }
                            : new[] { hitButton?TaikoAction.LeftRim : TaikoAction.RightRim };
                    }

                    Frames.Add(new TaikoReplayFrame(h.StartTime, actions));
                }
                else
                {
                    throw new InvalidOperationException("Unknown hit object type.");
                }

                Frames.Add(new TaikoReplayFrame(endTime + KEY_UP_DELAY));

                if (i < Beatmap.HitObjects.Count - 1)
                {
                    double waitTime = Beatmap.HitObjects[i + 1].StartTime - 1000;
                    if (waitTime > endTime)
                    {
                        Frames.Add(new TaikoReplayFrame(waitTime));
                    }
                }

                hitButton = !hitButton;
            }

            return(Replay);
        }
Esempio n. 5
0
 public DrawableSwellTick(TaikoHitObject hitObject)
     : base(hitObject)
 {
 }