Ejemplo n.º 1
0
        private Vector2 Arrive(Vector2 targetPos, Deacceleration deceleration)
        {
            Vector2 ToTarget = targetPos - _actor.Position;
            //calculate the distance to the target position
            float dist = ToTarget.Length();

            if (dist > 0)
            {
                //because Deceleration is enumerated as an int, this value is required
                //to provide fine tweaking of the deceleration.
                const float DecelerationTweaker = 0.3f;
                //calculate the speed required to reach the target given the desired
                //deceleration
                float speed = dist / ((float)deceleration * DecelerationTweaker);
                //make sure the velocity does not exceed the max
                speed = Math.Min(speed, _actor.MaxSpeed);
                //from here proceed just like Seek except we don't need to normalize
                //the ToTarget vector because we have already gone to the trouble
                //of calculating its length: dist.
                Vector2 DesiredVelocity = ToTarget * speed / dist;
                return(DesiredVelocity - _actor.Velocity);
            }

            return(Vector2.Zero);
        }
Ejemplo n.º 2
0
        public void WriteConfigFile(XmlTextWriter xmlWriter)
        {
            xmlWriter.WriteStartElement("CalibrationSettings");

            GTSettings.WriteElement(xmlWriter, "TrackingMonitor", Enum.GetName(typeof(Monitor), trackingMonitor));
            GTSettings.WriteElement(xmlWriter, "AreaWidth", AreaWidth.ToString());
            GTSettings.WriteElement(xmlWriter, "AreaHeight", AreaHeight.ToString());
            GTSettings.WriteElement(xmlWriter, "DistanceFromScreen", DistanceFromScreen.ToString());
            GTSettings.WriteElement(xmlWriter, "NumberOfPoints", NumberOfPoints.ToString());
            GTSettings.WriteElement(xmlWriter, "PointDuration", PointDuration.ToString());
            GTSettings.WriteElement(xmlWriter, "PointTransitionDuration", PointTransitionDuration.ToString());
            GTSettings.WriteElement(xmlWriter, "Acceleration", Acceleration.ToString());
            GTSettings.WriteElement(xmlWriter, "Deacceleration", Deacceleration.ToString());
            GTSettings.WriteElement(xmlWriter, "BackgroundColor", BackgroundColor.Color.R + " " + BackgroundColor.Color.G + " " + BackgroundColor.Color.B);
            GTSettings.WriteElement(xmlWriter, "PointColor", PointColor.Color.R + " " + PointColor.Color.G + " " + PointColor.Color.B);
            GTSettings.WriteElement(xmlWriter, "PointDiamter", PointDiameter.ToString());
            GTSettings.WriteElement(xmlWriter, "UseInfantGraphics", UseInfantGraphics.ToString());
            GTSettings.WriteElement(xmlWriter, "WaitForValidData", WaitForValidData.ToString());
            GTSettings.WriteElement(xmlWriter, "RandomizePointOrder", RandomizePointOrder.ToString());
            GTSettings.WriteElement(xmlWriter, "AutoAcceptPoints", AutoAcceptPoints.ToString());

            xmlWriter.WriteEndElement();
        }
Ejemplo n.º 3
0
 /// <summary>
 ///   Turns arrival behaviour on
 /// </summary>
 /// <param name = "arriveTarget">The destination of arrival</param>
 /// <param name = "deacceleration">The speed of arrival</param>
 public void ArriveOn(Vector2 arriveTarget, Deacceleration deacceleration)
 {
     _arriveTarget   = arriveTarget;
     _deacceleration = deacceleration;
     _arriveOn       = true;
 }
Ejemplo n.º 4
0
 public float GetDeacceleration(float speed, bool grounded)
 => grounded?
 Deacceleration.GetValue(speed / MaxSpeed) :
     AirDeacceleration.GetValue(speed / MaxSpeed);