Ejemplo n.º 1
0
    public void Flee()
    {
        Quaternion turn = Quaternion.FromToRotation(Vector3.forward, own_ship.Position);

        movement_quack.PushFront(new AIMouvementCommand [] {
            AIMouvementCommand.Turn(turn, own_ship, true),
            AIMouvementCommand.EngineAccelerate(own_ship.Position * 100, own_ship)
        });
    }
Ejemplo n.º 2
0
 public void Thrust(Vector3 delta_v, bool prioritize = false)
 {
     if (prioritize)
     {
         movement_quack.PushFront(AIMouvementCommand.EngineAccelerate(delta_v, own_ship));
     }
     else
     {
         movement_quack.PushBack(AIMouvementCommand.EngineAccelerate(delta_v, own_ship));
     }
 }
Ejemplo n.º 3
0
    /// <summary> Matches Velocity with target </summary>
    /// <param name="tg"> The concerned target </param>
    public void MatchVelocity(Target tg)
    {
        Vector3 d_v = tg.Velocity - own_ship.Velocity;

        if (d_v.sqrMagnitude > 4)
        {
            Quaternion turn = Quaternion.Inverse(own_ship.Orientation) * Quaternion.FromToRotation(Vector3.forward, d_v);
            movement_quack.PushBack(AIMouvementCommand.Turn(turn, own_ship));
            movement_quack.PushBack(AIMouvementCommand.EngineAccelerate(d_v, own_ship));
        }
        else
        {
            movement_quack.PushBack(AIMouvementCommand.RCSAccelerate(d_v, own_ship));
        }
    }
Ejemplo n.º 4
0
    /// <summary> Matches velocities with target the closest to target as possible </summary>
    /// <param name="tg"> The concerned target </param>
    public void MatchVelocityNearTarget(Target tg)
    {
        Vector3 d_v = tg.Velocity - own_ship.Velocity;

        if (Vector3.Dot(own_ship.Position - tg.Position, d_v) < 0)
        {
            MatchVelocity(tg);  //				->	 ->
            return;             // has to be catching up -> Δx · Δv > 0
        }
        float relative_velocity = d_v.magnitude;
        float acceleration      = own_ship.MaxAcceleration;

        if (relative_velocity > 4)
        {
            float breaking_distance = .5f * d_v.sqrMagnitude / acceleration;
            float full_distance     = Vector3.Project(tg.Position - own_ship.Position, d_v).magnitude;

            float plus_dist = 0;
            if (!tg.virt_ship)
            {
                plus_dist = tg.Ship.radius;
            }

            Quaternion turn = Quaternion.FromToRotation(Vector3.forward, d_v);
            movement_quack.PushBack(AIMouvementCommand.Turn(turn, own_ship, true));
            movement_quack.PushBack(AIMouvementCommand.HoldOrientation((full_distance - breaking_distance - plus_dist) / relative_velocity, own_ship));
            movement_quack.PushBack(AIMouvementCommand.EngineAccelerate(d_v, own_ship));
        }
        else
        {
            float breaking_time     = relative_velocity / acceleration;
            float breaking_distance = .5f * d_v.sqrMagnitude / acceleration;
            float full_distance     = Vector3.Project(tg.Position - own_ship.Position, d_v).magnitude;

            movement_quack.PushBack(AIMouvementCommand.RCSAccelerate(d_v, own_ship));
        }
    }