/// <summary>
        /// Renders body path.
        /// </summary>
        public void RenderPath()
        {
            // Property value caching for performance.
            float distPerTime = PlayArea.DistancePerTime;
            float interval    = PlayArea.DraggerBodyInterval;
            float startTime   = dragger.StartTime;
            float endTime     = dragger.EndTime;
            float duration    = dragger.Duration;

            // Start building line.
            float   lastTimeSpent = 0f;
            Vector2 lastPathPos   = dragger.GetPosition(lastTimeSpent);
            float   nextTimeSpent = lastTimeSpent;
            Vector2 nextPathPos   = lastPathPos;

            for (float t = startTime; t < endTime; t += interval)
            {
                nextTimeSpent = Math.Min(lastTimeSpent + interval, duration);
                nextPathPos   = dragger.GetPosition(nextTimeSpent / duration);
                var line = new Line(
                    new Vector2(lastPathPos.x, lastTimeSpent * distPerTime),
                    new Vector2(nextPathPos.x, nextTimeSpent * distPerTime)
                    );
                lastTimeSpent = nextTimeSpent;
                lastPathPos   = nextPathPos;

                component.AddLine(line);
            }
        }
示例#2
0
        public void UpdatePosition()
        {
            if (draggerView == null)
            {
                return;
            }

            float progress = draggerView.GetHitProgress(GameSession.GameProcessor.CurrentTime);

            if (progress < 0f)
            {
                return;
            }
            else if (progress > 1f)
            {
                progress = 1f;
            }
            myPosition.x  = dragger.GetPosition(progress).x;
            myPosition.y  = draggerView.DistUnderHitPos;
            this.Position = myPosition;
        }