private int calcG(int x, int y, int pX, int pY) { int g = Gcost[pX, pY]; if (leaveBog) { if ((x >= bogStartX && x <= bogStartX + bogWidth) && (y >= bogStartY && y < bogStartY + bogWidth)) { g += 7; } } if (explorer) { g += 1; return(g); } if (map[x, y] == 0) { g += 2; } else if (map[x, y] == 1) { g += 3; } else if (map[x, y] == 2) { g += 4; } VG.Map.BloodStream bs = tissue.IsInStream(x, y); if (bs != null) { int dy = y - pY; int dx = x - pX; #region Directions bool plus = false; if (bs.Direction == VG.Map.BloodStreamDirection.NorthSouth) { if (dy >= 0) { plus = false; } else { plus = true; } } else if (bs.Direction == VG.Map.BloodStreamDirection.SouthNorth) { if (dy <= 0) { plus = false; } else { plus = true; } } else if (bs.Direction == VG.Map.BloodStreamDirection.EstWest) { if (dx <= 0) { plus = false; } else { plus = true; } } else if (bs.Direction == VG.Map.BloodStreamDirection.WestEst) { if (dx >= 0) { plus = false; } else { plus = true; } } if (tissue[x, y].AreaType == VG.Map.AreaEnum.LowDensity) { if (plus) { g += 2; } else { g -= 1; } } else { if (plus) { g += 2; } else { g -= 2; } } #endregion } return(g); }
private int calcG(Node node) { int g = current.G; if (current.P.X == node.P.X && current.P.Y != node.P.Y) { g += 1; } else if (current.P.X != node.P.X && current.P.Y == node.P.Y) { g += 1; } if (tissue[node.P.X, node.P.Y].AreaType == VG.Map.AreaEnum.LowDensity) { g += 1; } else if (tissue[node.P.X, node.P.Y].AreaType == VG.Map.AreaEnum.MediumDensity) { g += 2; } else if (tissue[node.P.X, node.P.Y].AreaType == VG.Map.AreaEnum.HighDensity) { g += 3; } VG.Map.BloodStream bs = tissue.IsInStream(node.P.X, node.P.Y); if (bs != null) { int dy = node.P.Y - current.P.Y; int dx = node.P.X - current.P.X; #region Direction bool plus = false; if (bs.Direction == VG.Map.BloodStreamDirection.NorthSouth) { if (dy >= 0) { plus = false; } else { plus = true; } } else if (bs.Direction == VG.Map.BloodStreamDirection.SouthNorth) { if (dy <= 0) { plus = false; } else { plus = true; } } else if (bs.Direction == VG.Map.BloodStreamDirection.EstWest) { if (dx <= 0) { plus = false; } else { plus = true; } } else if (bs.Direction == VG.Map.BloodStreamDirection.WestEst) { if (dx >= 0) { plus = false; } else { plus = true; } } if (tissue[node.P.X, node.P.Y].AreaType == VG.Map.AreaEnum.LowDensity) { if (plus) { g += 2; } else { g -= 1; } } else { if (plus) { g += 2; } else { g -= 2; } } #endregion } return(g); }