コード例 #1
0
ファイル: GenericHitObject.cs プロジェクト: CelegaS/ctb_calc
        //Get the correct type of hitobject to put into the hitobject variable
        public GenericHitObject(string id, Beatmap map)
        {
            HitObjectType objecttype = HitObjectParser.GetHitObjectType(id);

            if (objecttype == HitObjectType.Circle)
            {
                hitobject = new Circle(id);
            }
            else if (objecttype == HitObjectType.Slider)
            {
                string slidertype = HitObjectParser.GetProperty(id, "slidertype");
                if (slidertype == "L")
                {
                    hitobject = new LinearSlider(id, map);
                }
                //Special behavior is needed for passthrough sliders
                else if (slidertype == "P")
                {
                    //Treat the slider differently depending on the number of control points
                    string[] sliderpoints = HitObjectParser.GetProperty(id, "controlpoints").Split('|');
                    if (sliderpoints.Length == 1)
                    {
                        hitobject = new LinearSlider(id, map);
                    }
                    else if (sliderpoints.Length == 2)
                    {
                        hitobject = new PassthroughSlider(id, map);
                    }
                    else
                    {
                        hitobject = new BezierSlider(id, map);
                    }
                }
                else if (slidertype == "B")
                {
                    hitobject = new BezierSlider(id, map);
                }
                else if (slidertype == "C")
                {
                    hitobject = new CatmullSlider(id, map);
                }
            }
            else if (objecttype == HitObjectType.Spinner)
            {
                hitobject = new Spinner();
            }
            else
            {
                throw new ArgumentException("Error: id is invalid");
            }
        }
コード例 #2
0
ファイル: Slider.cs プロジェクト: NotMichaelChen/osu_lib
        //Constructs a slider given an id
        //The beatmap given is the beatmap that the slider resides in
        //Used to make calculations related to timing
        protected GenericSlider(string tempid, Beatmap amap)
        {
            id  = tempid;
            map = amap;

            //Checks that the hitobject given is actually a slider
            if (HitObjectParser.GetHitObjectType(id) != HitObjectType.Slider)
            {
                throw new ArgumentException("Hitobject provided to slider class is not a slider");
            }

            //Gets the control points of the slider in a formatted array of Points
            controlpoints = FormatControlPoints();
        }