コード例 #1
0
        public void TestAngleFromPlayer()
        {
            Vehicule FirstVehicule  = Vehicule3D.GetUnitTestVehicule(new Vector3(0f, 0f, 0f));
            Vehicule SecondVehicule = Vehicule3D.GetUnitTestVehicule(new Vector3(0f, 0f, -50f));

            float AngleBetweenVehiculeFront = FirstVehicule.GetAngleBetweenTarget(SecondVehicule);

            SecondVehicule = Vehicule3D.GetUnitTestVehicule(new Vector3(50f, 0f, 0f));

            float AngleBetweenVehiculeRight = FirstVehicule.GetAngleBetweenTarget(SecondVehicule);

            Assert.AreEqual(0, MathHelper.ToDegrees(AngleBetweenVehiculeFront));
            Assert.AreEqual(-90, MathHelper.ToDegrees(AngleBetweenVehiculeRight));
        }
コード例 #2
0
        public void TestTunnelChangePrediction()
        {//Only change direction if the vehicule will exit the next tunnel by going straight
            AITunnel NextTunnel = new AITunnel();

            NextTunnel.Rotate((float)-1.3258176636680326f, 0, 0);
            NextTunnel.Position += new Vector3(0, 0, -210);
            NextTunnel.Scale(new Vector3(10, 1f, 1f));

            Vehicule ActiveVehicule = Vehicule3D.GetUnitTestVehicule(new Vector3(0f, 0f, 0f));

            bool NeedToTurnRight;
            TunnelChangePredictionResults Prediction = ActiveVehicule.GetTunnelChangePrediction(NextTunnel, out NeedToTurnRight);

            if (Prediction == TunnelChangePredictionResults.Overshoot)//Check if you would be braking too soon and end up undershooting instead.
            {
                float ExpectedTimeToStop;
            }
            else if (Prediction == TunnelChangePredictionResults.Undershoot || Prediction == TunnelChangePredictionResults.Aligned)//Keep going
            {
            }
        }