protected override void AddSlider(Slider s) { SliderTaiko st = (SliderTaiko)s; //The sprites get added in the update method - so we don't need to add them here. st.SpatialLength *= 1.4f; //See 1.4x multiplication of SliderMultiplier aboove. double l = st.SpatialLength; l *= st.SegmentCount; double v2 = SliderScoringPointDistance * Beatmap.DifficultySliderTickRate; double bl = Beatmap.BeatLengthAt(st.StartTime, true); // must be TRUE here so we get the correct duration st.EndTime = st.StartTime + (int)(l / v2 * bl); double v = SliderVelocityAt(st.StartTime); bl = Beatmap.BeatLengthAt(st.StartTime, Beatmap.BeatmapVersion < 8); double skipPeriod = Math.Min( bl / Beatmap.DifficultySliderTickRate, (double)(st.EndTime - st.StartTime) / st.SegmentCount); // Only do the conversion if skipPeriod is actually above 0. It can be 0 for sliders with a length of 0 (=> EndTime == StartTime). // This avoids an endless loop. if (skipPeriod > 0 && Beatmap.PlayMode != PlayModes.Taiko && l / v * 1000 < 2 * bl) { int i = 0; for (double j = st.StartTime; j <= st.EndTime + skipPeriod / 8; j += skipPeriod) { HitCircle h; if (st.unifiedSoundAddition) { h = hitFactory.CreateHitCircle(Vector2.Zero, (int)j, false, st.SoundType, 0, SampleSet.None, SampleSet.None, CustomSampleSet.Default, 0, ""); } else { h = hitFactory.CreateHitCircle(Vector2.Zero, (int)j, false, st.SoundTypeList[i], 0, SampleSet.None, SampleSet.None, CustomSampleSet.Default, 0, ""); i = (i + 1) % st.SoundTypeList.Count; } Add(h, false); } return; } base.AddSlider(st); }
public override void SetDefaultsFromBeatmap(Beatmap beatmap) { Velocity = 100 / beatmap.BeatLengthAt(StartTime, true) * beatmap.BeatmapInfo.BaseDifficulty.SliderMultiplier; }
public static int CalculateEndTime(Beatmap beatmap, int startTime, int repeats, double pixelLength) { int duration = (int)(pixelLength / (100d * beatmap.DifficultySection.SliderMultiplier) * repeats * beatmap.BeatLengthAt(startTime)); return(startTime + duration); }
void RandomizeBeatmap() { if (Directory.Exists("RandomizedMap")) { Directory.Delete("RandomizedMap", true); } if (File.Exists("RandomizedMap.osz")) { File.Delete("RandomizedMap.osz"); } Random r = new Random(); var kmap = LoadedMaps.ElementAt(r.Next(0, LoadedMaps.Count)); var ksong = LoadedMaps.ElementAt(r.Next(0, LoadedMaps.Count)); Beatmap map = BeatmapDecoder.Decode(kmap.FullName); Beatmap song = BeatmapDecoder.Decode(kmap.FullName); while (map.GeneralSection.Mode != song.GeneralSection.Mode && (!checkedListBox1.GetItemChecked(0) && (int)map.BeatLengthAt(0) == (int)song.BeatLengthAt(0))) { kmap = LoadedMaps.ElementAt(r.Next(0, LoadedMaps.Count)); ksong = LoadedMaps.ElementAt(r.Next(0, LoadedMaps.Count)); map = BeatmapDecoder.Decode(kmap.FullName); song = BeatmapDecoder.Decode(kmap.FullName); } while (map.GeneralSection.Mode != song.GeneralSection.Mode && checkedListBox1.GetItemChecked(0)) { kmap = LoadedMaps.ElementAt(r.Next(0, LoadedMaps.Count)); ksong = LoadedMaps.ElementAt(r.Next(0, LoadedMaps.Count)); map = BeatmapDecoder.Decode(kmap.FullName); song = BeatmapDecoder.Decode(kmap.FullName); } //create map directory Directory.CreateDirectory("RandomizedMap"); map.TimingPoints = song.TimingPoints; map.GeneralSection.AudioFilename = song.GeneralSection.AudioFilename; map.GeneralSection.Length = song.GeneralSection.Length; map.EventsSection.Breaks = song.EventsSection.Breaks; //copy audio file File.Copy(Path.Combine(Path.GetDirectoryName(ksong.FullName), song.GeneralSection.AudioFilename), Path.Combine("RandomizedMap", song.GeneralSection.AudioFilename)); //video randomizer if (checkedListBox1.GetItemChecked(2)) { var kvid = LoadedMaps.ElementAt(r.Next(0, LoadedMaps.Count)); Beatmap vid = BeatmapDecoder.Decode(kvid.FullName); while (string.IsNullOrEmpty(map.EventsSection.Video)) { kvid = LoadedMaps.ElementAt(r.Next(0, LoadedMaps.Count)); vid = BeatmapDecoder.Decode(kvid.FullName); } map.EventsSection.Video = vid.EventsSection.Video; map.EventsSection.VideoOffset = vid.EventsSection.VideoOffset; //copy video File.Copy(Path.Combine(Path.GetDirectoryName(kvid.FullName), vid.EventsSection.Video), Path.Combine("RandomizedMap", vid.EventsSection.Video)); } //storyboard randomizer /* * if (checkedListBox1.GetItemChecked(3)) * { * var ksb = LoadedMaps.ElementAt(r.Next(0, LoadedMaps.Count)); * Beatmap sb = BeatmapDecoder.Decode(ksb.FullName); * while (!sb.EventsSection.Storyboard.) * { * ksb = LoadedMaps.ElementAt(r.Next(0, LoadedMaps.Count)); * sb = BeatmapDecoder.Decode(ksb.FullName); * } * map.EventsSection.Video = sb.EventsSection.Video; * map.EventsSection.VideoOffset = sb.EventsSection.VideoOffset; * //copy video * File.Copy(Path.Combine(Path.GetDirectoryName(ksb.FullName), sb.EventsSection.Video), Path.Combine("RandomizedMap", sb.EventsSection.Video)); * } */ if (checkedListBox1.GetItemChecked(4)) { map.DifficultySection.CircleSize = r.Next(0, 100) / 10f; } if (checkedListBox1.GetItemChecked(5)) { map.DifficultySection.ApproachRate = r.Next(0, 100) / 10f; } if (checkedListBox1.GetItemChecked(6)) { map.DifficultySection.OverallDifficulty = r.Next(0, 100) / 10f; } if (checkedListBox1.GetItemChecked(7)) { map.DifficultySection.HPDrainRate = r.Next(0, 100) / 10f; } map.MetadataSection.Artist = "osu!map randomizer"; map.MetadataSection.Title = "Randomized map"; map.MetadataSection.Creator = "osu!map randomizer"; //copy background File.Copy(Path.Combine(Path.GetDirectoryName(kmap.FullName), song.EventsSection.BackgroundImage), Path.Combine("RandomizedMap", song.EventsSection.BackgroundImage)); map.Save(Path.Combine("RandomizedMap", "map.osu")); ZipFile.CreateFromDirectory(Path.GetFullPath("RandomizedMap"), "RandomizedMap.osz"); Process.Start(Path.GetFullPath("RandomizedMap.osz")); }
protected override void PostProcessing() { isPost = true; Beatmap.StackLeniency = 0; double t = firstObjectTime; int i = 0; Vector2 lastPosition = new Vector2(256, 197); double speed = 0; double angle = targetRandom.NextDouble() * Math.PI * 2; while (t < lastObjectTime) { double progress = (t - firstObjectTime) / (lastObjectTime - firstObjectTime); bool speedIncrease = i % 8 == 0; if (lastComboIndex < comboTimes.Count && t >= comboTimes[lastComboIndex]) { lastComboIndex++; } if (speedIncrease) { speed = HitObjectRadius + (int)(progress * 40) / 40d * 333; } Vector2 movement; ControlPoint cp = Beatmap.ControlPointAt(t); double multiplier = cp.KiaiMode ? 1.2 : 1; if (speedIncrease) { multiplier *= 1.5; } angle += (targetRandom.NextDouble() - 0.5) * 2; movement.X = lastPosition.X + (float)(speed * multiplier * Math.Cos(angle)); movement.Y = lastPosition.Y + (float)(speed * multiplier * Math.Sin(angle)); int tryCount = 0; while (movement.X < 0 || movement.Y < 0 || movement.X > 512 || movement.Y > 384 || (speed > HitObjectRadius && closeToRecent(movement, tryCount))) { angle = targetRandom.NextDouble() * Math.PI * 2; movement.X = lastPosition.X + (float)(speed * multiplier * Math.Cos(angle)); movement.Y = lastPosition.Y + (float)(speed * multiplier * Math.Sin(angle)); if (++tryCount > 10) { multiplier *= 0.9; } } lastPosition = movement; HitCircleOsuTarget h = new HitCircleOsuTarget(this, lastPosition + new Vector2(0, -10), (int)t, speedIncrease, HitObjectSoundType.Normal, 0); EventBreak b = eventManager.eventBreaks.Find(br => br.StartTime <= t && br.EndTime >= t); if (b == null) { int found = intendedObjects.BinarySearch(h); if (found < 0) { found = ~found - 1; } if (found >= 0 && found > lastUsedIntended && found < intendedObjects.Count) { lastUsedIntended = found; HitObject closest = intendedObjects[found]; h.SampleSet = closest.SampleSet; h.SampleSetAdditions = closest.SampleSetAdditions; h.SoundType = closest.SoundType; h.CustomSampleSet = closest.CustomSampleSet; } foreach (pSprite p in h.SpriteCollection) { //physics.Add(p, new Vector2((float)(progress * (GameBase.random.NextDouble() - 0.5)), 0), true).weight = -100; p.Transformations.Add(new Transformation(TransformationType.Scale, p.Scale * 0.5f, p.Scale, (int)t - PreEmpt, (int)t)); } AddCircle(h); } i++; t += Beatmap.BeatLengthAt(t, false); } Sort(false); base.PostProcessing(); }