Пример #1
0
    // Called when the node enters the scene tree for the first time.
    public override void _Ready()
    {
        RequestPathEvent.RegisterListener(GetPath);

        nav2D = GetNode <Navigation2D>("../Nav2D");
        //Get the ti;e map and the naviation map here
    }
Пример #2
0
    private void AIGetPath()
    //private void GetPath(SendPathEvent spei)
    {
        RequestPathEvent rpei = new RequestPathEvent();

        rpei.requester = (Node2D)GetParent();
        rpei.target    = target;
        rpei.FireEvent();
        path = rpei.path;
    }
Пример #3
0
 public override void _ExitTree()
 {
     RequestPathEvent.UnregisterListener(GetPath);
 }
Пример #4
0
 private void GetPath(RequestPathEvent rpei)
 {
     //Get the generated path
     Vector2[] path = nav2D.GetSimplePath(rpei.requester.GlobalPosition, rpei.target.GlobalPosition);
     rpei.path = path;
 }