Beispiel #1
0
        public Square(Vector2 startPos, int time, HitObjectSoundType hitSound, Vector2 prevPoint, float mpb, Difficulty difficulty)
        {
            numObjects = 4;

            totalLength  = difficulty.baseCircleTimestamp * numObjects + 1;
            subsetLength = difficulty.baseCircleTimestamp;

            hitCircles.Add(new HitCircle(startPos, (int)(time + (subsetLength * mpb)), (HitObjectType)HitType, (HitObjectSoundType)HitSound, prevPoint, 10f, false));
            hitCircles.Add(new HitCircle(new Vector2(startPos.X + noteDistance, startPos.Y), (int)(time + (subsetLength * 2 * mpb)), (HitObjectType)HitType, (HitObjectSoundType)HitSound, prevPoint, 10f, true));
            hitCircles.Add(new HitCircle(new Vector2(startPos.X + noteDistance, startPos.Y + noteDistance), (int)(time + (subsetLength * 3 * mpb)), (HitObjectType)HitType, (HitObjectSoundType)HitSound, prevPoint, 10f, true));
            hitCircles.Add(new HitCircle(new Vector2(startPos.X - noteDistance, startPos.Y + noteDistance), (int)(time + (subsetLength * 4 * mpb)), (HitObjectType)HitType, (HitObjectSoundType)HitSound, prevPoint, 10f, true));
        }
Beispiel #2
0
        /// <summary>
        /// Parse .osu Beatmap file.
        /// </summary>
        public void LoadBeatmapFromFile()
        {
            for (int i = 0; i < fileData.Length; i++)
            {
                // Get the init timing points and the milleseconds per beat.
                switch (fileData[i])
                {
                case "[TimingPoints]":

                    string[] initTimingPonits = fileData[i + 1].Split(',');
                    mpb    = float.Parse(initTimingPonits[1]);
                    offset = int.Parse(initTimingPonits[0]);

                    // Collect all Timing Points
                    int    timingPointIndex = i + 2;
                    int    timingNumber     = 0;
                    string timingPointText  = fileData[timingPointIndex];

                    while (!String.IsNullOrWhiteSpace(timingPointText))
                    {
                        Console.WriteLine("Add Timing Point");
                        string[] timingPointSplit = timingPointText.Split(',');
                        timingPoints.Add(new TimingPoint(int.Parse(timingPointSplit[0]), true, float.Parse(timingPointSplit[1]), timingNumber));
                        timingPointIndex++;
                        timingNumber++;
                        timingPointText = fileData[timingPointIndex];
                    }
                    break;

                case "[General]":
                    string     mp3FilePath = GetPath(fileData[i + 1], Path.GetDirectoryName(filePath));
                    WaveStream pcm         = WaveFormatConversionStream.CreatePcmStream(new Mp3FileReader(mp3FilePath));
                    TimeSpan   ts          = pcm.TotalTime;
                    songLength = ((ts.Minutes * 60) + ts.Seconds) * 1000 + ts.Milliseconds;
                    Console.WriteLine("Total Song Length is: " + songLength);
                    break;

                case "[Difficulty]":
                    string[] approachRateText = fileData[i + 4].Split(':');
                    ar = int.Parse(approachRateText[1]);
                    Console.WriteLine("Approach Rate is " + ar);
                    approachRate = Difficulty.Calculate(ar);
                    difficulty   = new Difficulty(approachRate);

                    string[] sliderVelText = fileData[i + 5].Split(':');
                    sliderVelocity = float.Parse(sliderVelText[1]);
                    Console.WriteLine("Slider Velocity is: " + sliderVelocity);
                    break;

                case "[HitObjects]":
                    if (!String.IsNullOrWhiteSpace(fileData[i + 1]))
                    {
                        Console.WriteLine("Beatmap already contains HitObjects " + fileData[i + 1]);
                        beatmapOccupied = true;
                    }
                    break;

                default:
                    break;
                }
            }
        }