Ejemplo n.º 1
0
        private TaikoHitObject convertHitObject(HitObject original)
        {
            // Check if this HitObject is already a TaikoHitObject, and return it if so
            TaikoHitObject originalTaiko = original as TaikoHitObject;

            if (originalTaiko != null)
            {
                return(originalTaiko);
            }

            IHasDistance distanceData = original as IHasDistance;
            IHasRepeats  repeatsData  = original as IHasRepeats;
            IHasEndTime  endTimeData  = original as IHasEndTime;

            bool accented = ((original.Sample?.Type ?? SampleType.None) & SampleType.Finish) > 0;

            if (distanceData != null)
            {
                return(new DrumRoll
                {
                    StartTime = original.StartTime,
                    Sample = original.Sample,
                    Accented = accented,

                    Distance = distanceData.Distance * (repeatsData?.RepeatCount ?? 1)
                });
            }

            if (endTimeData != null)
            {
                // We compute the end time manually to add in the Bash convert factor
                return(new Bash
                {
                    StartTime = original.StartTime,
                    Sample = original.Sample,
                    Accented = accented,

                    EndTime = original.StartTime + endTimeData.Duration * bash_convert_factor
                });
            }

            return(new Hit
            {
                StartTime = original.StartTime,
                Sample = original.Sample,
                Accented = accented
            });
        }
Ejemplo n.º 2
0
        /// <summary>
        /// this method does not in use
        /// </summary>
        /// <param name="original"></param>
        /// <param name="beatmap"></param>
        /// <returns></returns>
        protected override IEnumerable <BaseRpObject> ConvertHitObject(HitObject original, Beatmap beatmap)
        {
            IHasCurve    curveData    = original as IHasCurve;
            IHasEndTime  endTimeData  = original as IHasEndTime;
            IHasPosition positionData = original as IHasPosition;
            IHasCombo    comboData    = original as IHasCombo;

            /*
             * if (curveData != null)
             * {
             *  yield return new RpSlider
             *  {
             *      StartTime = original.StartTime,
             *      Samples = original.Samples,
             *      CurveObject = curveData,
             *      Position = positionData?.Position ?? Vector2.Zero,
             *      NewCombo = comboData?.NewCombo ?? false
             *  };
             * }
             * else if (endTimeData != null)
             * {
             *  yield return new Spinner
             *  {
             *      StartTime = original.StartTime,
             *      Samples = original.Samples,
             *      EndTime = endTimeData.EndTime,
             *
             *      Position = positionData?.Position ?? OsuPlayfield.BASE_SIZE / 2,
             *  };
             * }
             * else
             * {
             *  yield return new HitCircle
             *  {
             *      StartTime = original.StartTime,
             *      Samples = original.Samples,
             *      Position = positionData?.Position ?? Vector2.Zero,
             *      NewCombo = comboData?.NewCombo ?? false
             *  };
             * }
             */

            yield return((BaseRpObject)original);
        }
Ejemplo n.º 3
0
        private OsuHitObject convertHitObject(HitObject original)
        {
            IHasCurve    curveData    = original as IHasCurve;
            IHasEndTime  endTimeData  = original as IHasEndTime;
            IHasPosition positionData = original as IHasPosition;
            IHasCombo    comboData    = original as IHasCombo;

            if (curveData != null)
            {
                return(new Slider
                {
                    StartTime = original.StartTime,
                    Sample = original.Sample,

                    CurveObject = curveData,

                    Position = positionData?.Position ?? Vector2.Zero,

                    NewCombo = comboData?.NewCombo ?? false
                });
            }

            if (endTimeData != null)
            {
                return(new Spinner
                {
                    StartTime = original.StartTime,
                    Sample = original.Sample,
                    Position = new Vector2(512, 384) / 2,

                    EndTime = endTimeData.EndTime
                });
            }

            return(new HitCircle
            {
                StartTime = original.StartTime,
                Sample = original.Sample,

                Position = positionData?.Position ?? Vector2.Zero,

                NewCombo = comboData?.NewCombo ?? false
            });
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Applies specified map properties to this and all nested hit object.
        /// </summary>
        public void ApplyMapProperties(ControlPointGroup controlPoints, MapDifficulty difficulty)
        {
            // Apply map properties to this object first.
            ApplyMapPropertiesSelf(controlPoints, difficulty);

            // Determine which sample point this object belongs to.
            IHasEndTime endTimeObject = this as IHasEndTime;

            SamplePoint = controlPoints.SamplePointAt(StartTime + ControlPointOffset);

            // Create nested objects if necessary
            NestedObjects.Clear();
            CreateNestedObjects();
            NestedObjects.Sort((x, y) => x.StartTime.CompareTo(y.StartTime));

            // Apply map properties to all nested objects
            foreach (var obj in NestedObjects)
            {
                obj.ApplyMapProperties(controlPoints, difficulty);
            }
        }
Ejemplo n.º 5
0
        public static List <TouhouHitObject> ConvertSpinner(HitObject obj, IHasEndTime endTime, bool isKiai, int index, int stageIndex)
        {
            List <TouhouHitObject> hitObjects = new List <TouhouHitObject>();

            var objPosition = (obj as IHasPosition)?.Position ?? Vector2.Zero;
            var comboData   = obj as IHasCombo;

            var spansPerSpinner = endTime.Duration / spinner_span_delay;

            for (int i = 0; i < spansPerSpinner; i++)
            {
                hitObjects.AddRange(generateExplosion(
                                        obj.StartTime + i * spinner_span_delay,
                                        bullets_per_spinner_span,
                                        objPosition * new Vector2(1, 0.5f),
                                        comboData,
                                        isKiai,
                                        index,
                                        i * spinner_angle_per_span));
            }

            return(hitObjects);
        }
Ejemplo n.º 6
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);
        }
Ejemplo n.º 7
0
        protected override IEnumerable <HitObject> ConvertHitObjects(BaseHitObject hitObject)
        {
            IHasCurve     curve   = hitObject as IHasCurve;
            IHasPositionX posX    = hitObject as IHasPositionX;
            IHasEndTime   endTime = hitObject as IHasEndTime;
            IHasCombo     combo   = hitObject as IHasCombo;

            if (curve != null)
            {
                // Regenerate path using conversion method.
                SliderPath newPath = curve.Path;
                if (pixelDefinition.FromMode != GameModeType.BeatsStandard)
                {
                    Vector2[] origPoints = newPath.Points;
                    Vector2[] points     = new Vector2[origPoints.Length];
                    for (int i = 0; i < points.Length; i++)
                    {
                        points[i]   = origPoints[i];
                        points[i].x = points[i].x * pixelDefinition.Scale;
                    }
                    // Final path
                    newPath = new SliderPath(newPath.PathType, points, newPath.ExpectedDistance * pixelDefinition.Scale);
                }

                yield return(new Dragger()
                {
                    StartTime = hitObject.StartTime,
                    Samples = hitObject.Samples,
                    X = pixelDefinition.GetX(posX.X),
                    RepeatCount = curve.RepeatCount,
                    IsNewCombo = (combo == null ? false : combo.IsNewCombo),
                    ComboOffset = (combo == null ? 0 : combo.ComboOffset),
                    Path = newPath,
                    NodeSamples = curve.NodeSamples,
                    EndTime = curve.EndTime
                });
            }
            else if (endTime != null)
            {
                yield return(new Dragger()
                {
                    StartTime = hitObject.StartTime,
                    Samples = new List <SoundInfo>(),
                    X = pixelDefinition.GetX(posX.X),
                    RepeatCount = 0,
                    IsNewCombo = (combo == null ? false : combo.IsNewCombo),
                    ComboOffset = (combo == null ? 0 : combo.ComboOffset),
                    Path = new SliderPath(PathType.Linear, new Vector2[] {
                        new Vector2(0, 0),
                        new Vector2(0, 1)
                    }, null),
                    NodeSamples = new List <List <SoundInfo> >()
                    {
                        new List <SoundInfo>(),
                        hitObject.Samples
                    },
                    EndTime = endTime.EndTime
                });
            }
            else
            {
                yield return(new HitCircle()
                {
                    StartTime = hitObject.StartTime,
                    Samples = hitObject.Samples,
                    X = pixelDefinition.GetX(posX.X),
                    IsNewCombo = (combo == null ? false : combo.IsNewCombo),
                    ComboOffset = (combo == null ? 0 : combo.ComboOffset)
                });
            }
        }
Ejemplo n.º 8
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;
            }
        }
Ejemplo n.º 9
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);
        }
Ejemplo n.º 10
0
        private TaikoHitObject convertHitObject(HitObject original)
        {
            // Check if this HitObject is already a TaikoHitObject, and return it if so
            TaikoHitObject originalTaiko = original as TaikoHitObject;

            if (originalTaiko != null)
            {
                return(originalTaiko);
            }

            IHasDistance distanceData = original as IHasDistance;
            IHasRepeats  repeatsData  = original as IHasRepeats;
            IHasEndTime  endTimeData  = original as IHasEndTime;

            // Old osu! used hit sounding to determine various hit type information
            SampleType sample = original.Sample?.Type ?? SampleType.None;

            bool strong = (sample & SampleType.Finish) > 0;

            if (distanceData != null)
            {
                return(new DrumRoll
                {
                    StartTime = original.StartTime,
                    Sample = original.Sample,
                    IsStrong = strong,

                    Distance = distanceData.Distance * (repeatsData?.RepeatCount ?? 1) * legacy_velocity_scale
                });
            }

            if (endTimeData != null)
            {
                // We compute the end time manually to add in the Bash convert factor
                return(new Swell
                {
                    StartTime = original.StartTime,
                    Sample = original.Sample,
                    IsStrong = strong,

                    EndTime = original.StartTime + endTimeData.Duration,
                    HitRatio = bash_convert_factor
                });
            }

            bool isCentre = (sample & ~(SampleType.Finish | SampleType.Normal)) == 0;

            if (isCentre)
            {
                return(new CentreHit
                {
                    StartTime = original.StartTime,
                    Sample = original.Sample,
                    IsStrong = strong
                });
            }

            return(new RimHit
            {
                StartTime = original.StartTime,
                Sample = original.Sample,
                IsStrong = strong,
            });
        }
Ejemplo n.º 11
0
        public override Replay Generate()
        {
            bool hitButton = true;

            Frames.Add(new TaikoReplayFrame(-100000, ReplayButtonState.None));
            Frames.Add(new TaikoReplayFrame(Beatmap.HitObjects[0].StartTime - 1000, 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 = Math.Min(swell_hit_speed, swell.Duration / req);
                    for (double j = h.StartTime; j < endTime; j += hitRate)
                    {
                        switch (d)
                        {
                        default:
                        case 0:
                            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 TaikoReplayFrame(j, button));
                        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 ? ReplayButtonState.Right1 : ReplayButtonState.Right2));
                        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 TaikoReplayFrame(h.StartTime, button));
                }
                else
                {
                    throw new InvalidOperationException("Unknown hit object type.");
                }

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

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

                hitButton = !hitButton;
            }

            return(Replay);
        }