Example #1
0
    public void Execute(ref Navigation nav, Ship current_ship)
    {
        switch (command_type)
        {
        case CommandType.turn:
            nav.AddRotation(new FuzzyVector(current_ship.low_ai.CalculateTurn(desired_state.Orientation * Vector3.forward), .5f));
            return;

        case CommandType.main_dv:
            nav.SetThrottle(1);
            return;

        case CommandType.rcs_dv:
            nav.AddTranslation(new FuzzyVector((desired_state.Velocity - current_ship.Velocity).normalized, .5f));
            return;

        case CommandType.hold_orientation:
            if (first)
            {
                desired_state.Orientation = current_ship.Orientation;
                first = false;
            }
            nav.AddRotation(new FuzzyVector(current_ship.low_ai.CalculateTurn(desired_state.Orientation * Vector3.forward), .5f));
            return;

        case CommandType.stay_locked:
            nav.AddRotation(new FuzzyVector(current_ship.low_ai.CalculateTurn(desired_state.Target.Position - current_ship.Position), .5f));
            return;

        case CommandType.wait:
        default: return;
        }
    }
Example #2
0
 /// <summary>
 ///		Dodges bullets and missiles
 /// </summary>
 public void Dodge()
 {
     foreach (Bullet bullet in bullets)
     {
         if (IsDanger(bullet))
         {
             Vector3 vec = Vector3.ProjectOnPlane(bullet.Position - own_ship.Position, bullet.Velocity);
             navigator.AddTranslation(-vec.normalized, 1f);
         }
     }
     foreach (Missile miss in missiles)
     {
         if (IsDanger(miss))
         {
             Vector3 vec = Vector3.ProjectOnPlane(miss.Position - own_ship.Position, miss.Velocity);
             navigator.AddTranslation(-vec.normalized, 1f);
         }
     }
 }