Esempio n. 1
0
 public override void _Process(float delta)
 {
     if (shouldCalcNew && ((int)walkedDistance < (int)(walkedDistance + delta * MovementSpeed) || path == null))
     {
         shouldCalcNew = false;
         float  gridSize = this.grid3d.GetGridSize();
         PointI nextGrid = new PointI((int)(Translation.x / gridSize), (int)(Translation.z / gridSize));
         if (pathFinder.FindPath(out points, nextGrid))
         {
             if (points.Length > 1)
             {
                 path = new SplinePath(points, grid3d.GetGridSize(), InterpolationType.Qubic);
             }
             Blocked = false;
             exclamationInst.Visible = false;
         }
         else
         {
             Blocked                 = true;
             path                    = null;
             walkedDistance          = 0;
             exclamationInst.Visible = true;
         }
         walkedDistance = 0;
     }
     if (path != null)
     {
         Vector2 pos = path.GetPoint(walkedDistance);
         walkedDistance  += delta * MovementSpeed;
         this.Translation = new Vector3(pos.x, 0, pos.y);
     }
 }