예제 #1
0
        public DrawableSlider(Slider s) : base(s)
        {
            slider = s;

            Children = new Drawable[]
            {
                body = new SliderBody(s)
                {
                    Position  = s.StackedPosition,
                    PathWidth = s.Scale * 64,
                },
                ticks    = new Container <DrawableSliderTick>(),
                bouncer1 = new SliderBouncer(s, false)
                {
                    Position = s.Curve.PositionAt(1),
                    Scale    = new Vector2(s.Scale),
                },
                bouncer2 = new SliderBouncer(s, true)
                {
                    Position = s.StackedPosition,
                    Scale    = new Vector2(s.Scale),
                },
                ball = new SliderBall(s)
                {
                    Scale = new Vector2(s.Scale),
                },
                initialCircle = new DrawableHitCircle(new HitCircle
                {
                    //todo: avoid creating this temporary HitCircle.
                    StartTime  = s.StartTime,
                    Position   = s.StackedPosition,
                    ComboIndex = s.ComboIndex,
                    Scale      = s.Scale,
                    Colour     = s.Colour,
                    Sample     = s.Sample,
                }),
            };

            components.Add(body);
            components.Add(ball);
            components.Add(bouncer1);
            components.Add(bouncer2);

            AddNested(initialCircle);

            var repeatDuration = s.Curve.Length / s.Velocity;

            foreach (var tick in s.Ticks)
            {
                var repeatStartTime = s.StartTime + tick.RepeatIndex * repeatDuration;
                var fadeInTime      = repeatStartTime + (tick.StartTime - repeatStartTime) / 2 - (tick.RepeatIndex == 0 ? TIME_FADEIN : TIME_FADEIN / 2);
                var fadeOutTime     = repeatStartTime + repeatDuration;

                var drawableTick = new DrawableSliderTick(tick)
                {
                    FadeInTime  = fadeInTime,
                    FadeOutTime = fadeOutTime,
                    Position    = tick.Position,
                };

                ticks.Add(drawableTick);
                AddNested(drawableTick);
            }
        }
예제 #2
0
파일: DrawableSlider.cs 프로젝트: ekisu/osu
        public DrawableSlider(Slider s) : base(s)
        {
            // Since the DrawableSlider itself is just a container without a size we need to
            // pass all input through.
            AlwaysReceiveInput = true;

            SliderBouncer bouncer1;

            slider = s;

            Children = new Drawable[]
            {
                body = new SliderBody(s)
                {
                    AccentColour = AccentColour,
                    Position     = s.StackedPosition,
                    PathWidth    = s.Scale * 64,
                },
                ticks    = new Container <DrawableSliderTick>(),
                bouncer1 = new SliderBouncer(s, false)
                {
                    Position = s.Curve.PositionAt(1),
                    Scale    = new Vector2(s.Scale),
                },
                bouncer2 = new SliderBouncer(s, true)
                {
                    Position = s.StackedPosition,
                    Scale    = new Vector2(s.Scale),
                },
                ball = new SliderBall(s)
                {
                    Scale        = new Vector2(s.Scale),
                    AccentColour = AccentColour
                },
                initialCircle = new DrawableHitCircle(new HitCircle
                {
                    //todo: avoid creating this temporary HitCircle.
                    StartTime   = s.StartTime,
                    Position    = s.StackedPosition,
                    ComboIndex  = s.ComboIndex,
                    Scale       = s.Scale,
                    ComboColour = s.ComboColour,
                    Sample      = s.Sample,
                }),
            };

            components.Add(body);
            components.Add(ball);
            components.Add(bouncer1);
            components.Add(bouncer2);

            AddNested(initialCircle);

            var repeatDuration = s.Curve.Distance / s.Velocity;

            foreach (var tick in s.Ticks)
            {
                var repeatStartTime = s.StartTime + tick.RepeatIndex * repeatDuration;
                var fadeInTime      = repeatStartTime + (tick.StartTime - repeatStartTime) / 2 - (tick.RepeatIndex == 0 ? TIME_FADEIN : TIME_FADEIN / 2);
                var fadeOutTime     = repeatStartTime + repeatDuration;

                var drawableTick = new DrawableSliderTick(tick)
                {
                    FadeInTime  = fadeInTime,
                    FadeOutTime = fadeOutTime,
                    Position    = tick.Position,
                };

                ticks.Add(drawableTick);
                AddNested(drawableTick);
            }
        }