Example #1
0
 public Dictionary<string, MapCell> GetNeighbours(MapCell selectedcell)
 {
     Dictionary<String, MapCell> neighbours = new Dictionary<string, MapCell>();
     Point cell = new Point(selectedcell.X, selectedcell.Y);
     int newX = cell.X;
     if (cell.Y % 2 == 1)
        newX += 1;
     if (cell.Y > 0 && newX > 0)
         neighbours.Add("N", Rows[cell.Y - 1].Columns[newX - 1]);
     if (cell.Y > 1 && cell.X < MapWidth)
         neighbours.Add("NE", Rows[cell.Y - 2].Columns[cell.X]);
     if (cell.Y > 0 && newX < MapWidth)
         neighbours.Add("E", Rows[cell.Y - 1].Columns[newX]);
     if (cell.Y < MapWidth && cell.X < (MapWidth - 1))
         neighbours.Add("SE", Rows[cell.Y].Columns[cell.X + 1]);
     if (cell.Y < (MapHeight-1) && newX < MapWidth)
         neighbours.Add("S", Rows[cell.Y + 1].Columns[newX]);
     if (cell.Y < (MapWidth - 2) && cell.X < MapWidth)
         neighbours.Add("SW", Rows[cell.Y + 2].Columns[cell.X]);
     if (cell.Y < (MapHeight - 1) && newX > 0)
         neighbours.Add("W", Rows[cell.Y + 1].Columns[newX - 1]);
     if (cell.Y < MapHeight && cell.X > 0)
         neighbours.Add("NW", Rows[cell.Y].Columns[cell.X - 1]);
     return neighbours;
 }
Example #2
0
 public Node(MapCell cell, Node parent, float cost, float heur)
 {
     Cell = cell;
     Heuristic = heur;
     Parent = parent;
     Cost = cost;
 }
Example #3
0
 public float distance(MapCell cell, MapCell target)
 {
     return (float)Math.Sqrt(Math.Pow(cell.X - target.X, 2) + Math.Pow(cell.Y - target.Y, 2));
 }
Example #4
0
 public int GetCellHeight(MapCell cell)
 {
     return Rows[cell.Y].Columns[cell.X].HeightTiles.Count * Tile.HeightOffset;
 }