public static Coordinate getEmptyCellCoord(Ocean ocean) { Coordinate empty = new Coordinate(); do { empty._x = Randomaizer.nextIntBetween(0, Ocean.COL - 1); empty._y = Randomaizer.nextIntBetween(0, Ocean.ROW - 1); } while (ocean[empty._y, empty._x] != null); return(empty); }
/// <summary> /// этот понос нужно починить /// </summary> /// <param name="ocean"></param> /// <param name="coo"></param> /// <param name="image"></param> /// <returns></returns> public static Coordinate getNeighborWithImage(Ocean ocean, Coordinate coo, char image) // todo { Coordinate[] neighbors = new Coordinate[0x04]; int count = 0; Coordinate tmp = new Life_Game.Coordinate(); bool find = true; if (image == (char)ValueOcean.Sea) { find = false; } tmp = north(ocean, coo, image, find); if (tmp._x != coo._x || tmp._y != coo._y) { neighbors[count++] = north(ocean, coo, image, find); } tmp = south(ocean, coo, image, find); if (tmp._x != coo._x || tmp._y != coo._y) { neighbors[count++] = south(ocean, coo, image, find); } tmp = east(ocean, coo, image, find); if (tmp._x != coo._x || tmp._y != coo._y) { neighbors[count++] = east(ocean, coo, image, find); } tmp = west(ocean, coo, image, find); if (tmp._x != coo._x || tmp._y != coo._y) { neighbors[count++] = west(ocean, coo, image, find); } if (count == 0) { return(coo); } else { return(neighbors[Randomaizer.nextIntBetween(0, count - 1)]); } }