コード例 #1
0
    public override void _PhysicsProcess(float delta)
    {
        if (_ai != null)
        {
            _ai.Evaluate();
        }

        if (GlobalPosition.DistanceTo(GetGlobalMousePosition()) > 20f && _shouldMove)
        {
            _movement_axis = (GetGlobalMousePosition() - GlobalPosition).Normalized();
        }
        else
        {
            _movement_axis = Vector2.Zero;
        }

        if (_movement_axis == Vector2.Zero)
        {
            ApplyFriction(Acceleration * delta);
        }
        else
        {
            ApplyMovement(_movement_axis * Acceleration * delta, Speed);
        }
        _motion = MoveAndSlide(_motion);
    }
コード例 #2
0
 /* Run corresponding action based on evaluation delegate result */
 public override NodeStates Evaluate()
 {
     if (_eval() == true)
     {
         DebugPrint("Evauluating: '" + _name + "', Result: TRUE");
         return(_ifTrue.Evaluate());
     }
     else
     {
         DebugPrint("Evauluating: '" + _name + "', Result: FALSE");
         return(_ifFalse.Evaluate());
     }
 }
 /* Run action */
 public override NodeStates Evaluate()
 {
     _action(_param);
     return(_followUp.Evaluate());
 }