Beispiel #1
0
    private void CheckNeiboringTiles(HashSet <TileScript> tilesAlreadyEvaluated, TileScript currentTile, List <TileScript> testThingy)
    {
        foreach (TileScript neigbhourTile in map.GetNeighboringTiles(currentTile))
        {
            if (neigbhourTile.status == TileScript.tileStatus.Taken || tilesAlreadyEvaluated.Contains(neigbhourTile))
            {
                continue;
            }


            int newMovementCostToNeibor = currentTile.gCost + GetDistance(currentTile, neigbhourTile);
            if (newMovementCostToNeibor < neigbhourTile.gCost || !tilesToBeEvaluated.Contains(neigbhourTile))
            {
                neigbhourTile.gCost  = newMovementCostToNeibor;
                neigbhourTile.hCost  = GetDistance(neigbhourTile, targetTile);
                neigbhourTile.parent = currentTile;

                if (!tilesToBeEvaluated.Contains(neigbhourTile))
                {
                    tilesToBeEvaluated.Add(neigbhourTile);
                }
            }
        }
    }