Esempio n. 1
0
    private void GeneratePathPoint(AreaTile current, AreaTile end)
    {
        while (activeTiles.Any())
        {
            current = activeTiles.OrderBy(tile => tile.CostDistance).First();

            // Destination reached.
            if ((System.Math.Round(current.position.X, 0) == System.Math.Round(end.position.X, 0)) &&
                (System.Math.Round(current.position.Z, 0) == System.Math.Round(end.position.Z, 0)))
            {
                TracePath(current);
                return;
            }

            visitedTiles.Add(current);
            activeTiles.Remove(current);

            foreach (AreaTile tile in GetTileGrid(current, end))
            {
                double currentTileX = System.Math.Round(tile.position.X, 0);
                double currentTileZ = System.Math.Round(tile.position.Z, 0);
                if (visitedTiles.Any(cTile => (System.Math.Round(cTile.position.X, 0) == currentTileX) &&
                                     (System.Math.Round(cTile.position.Z, 0) == currentTileZ)))
                {
                    continue;
                }

                if (activeTiles.Any(cTile => (System.Math.Round(cTile.position.X, 0) == currentTileX) &&
                                    (System.Math.Round(cTile.position.Z, 0) == currentTileZ)))
                {
                    AreaTile scannedTile = activeTiles.First(cTile => (System.Math.Round(cTile.position.X, 0) == currentTileX) &&
                                                             (System.Math.Round(cTile.position.Z, 0) == currentTileZ));

                    if (scannedTile.CostDistance > tile.CostDistance)
                    {
                        activeTiles.Remove(scannedTile);
                        activeTiles.Add(tile);
                    }
                }
                else
                {
                    activeTiles.Add(tile);
                }
            }
        }
    }
Esempio n. 2
0
 public dfTouchEventArgs(dfControl source, System.Collections.Generic.List <UnityEngine.Touch> touches, Ray ray) : this(source, touches.First <UnityEngine.Touch>(), ray)
 {
     this.Touches = touches;
 }