Exemple #1
0
    /// <summary>
    /// Mark intercepts with the designated symbols and return a list of intercepts found
    /// for the predicted path of ship intersecting with the path of the target.
    /// </summary>
    ///
    /// <param name="ship">The ship</param>
    /// <param name="target">The target</param>
    ///
    /// <returns>The intercepts.</returns>
    private List <TrajectoryData.Intercept> MarkIntercepts(SpaceshipRV ship, NBody target)
    {
        // delta distance is scale dependent. For now use an ugly *if*
        float deltaDistance = 1f;

        if (GravityEngine.Instance().units == GravityScaler.Units.ORBITAL)
        {
            deltaDistance = 20f;
        }
        const float deltaTime    = 2f;
        const float rendezvousDT = 1f;

        trajIntercepts.spaceship = ship.GetTrajectory();
        Trajectory trajectory = target.GetComponentInChildren <Trajectory>();

        if (trajectory == null)
        {
            Debug.LogError("Target requires a child with a trajectory component");
            return(new List <TrajectoryData.Intercept>());
        }
        trajIntercepts.target = trajectory;
        trajIntercepts.ComputeAndMarkIntercepts(deltaDistance, deltaTime, rendezvousDT);
        intercepts = trajIntercepts.GetIntercepts();
        return(intercepts);
    }