diff --git a/Assets/Scripts/HexFiled/PaintedController.cs b/Assets/Scripts/HexFiled/PaintedController.cs index d4e64ad8..24a73fdc 100644 --- a/Assets/Scripts/HexFiled/PaintedController.cs +++ b/Assets/Scripts/HexFiled/PaintedController.cs @@ -37,7 +37,7 @@ namespace HexFiled } } } - else if (item.Key == UnitColor.GREY) + else if (item.Key != cell.Color) { } @@ -59,10 +59,56 @@ namespace HexFiled resultDict.Add(cell.Color, new List{cell}); } - } ); + } + ); return resultDict; } + + + private List FillRound(List cells) + { + List neighbourByColor = new List(); + for (int i = 0; i < 6; i++) + { + var neighbour = _cell.GetNeighbor((HexDirection)i); + if(neighbour.Color == _cell.Color) + { + neighbourByColor.Add(neighbour); + } + } + + if(neighbourByColor.Count > 1 && neighbourByColor.Count < 6) + { + + var start = neighbourByColor[Random.Range(0, neighbourByColor.Count - 1)]; + var end = neighbourByColor[Random.Range(0, neighbourByColor.Count - 1)]; + neighbourByColor.Remove(start); + + + var path = HasPath(start, end); + while(neighbourByColor.Count <= 0 && path.hasPath) + { + start = neighbourByColor[Random.Range(0, neighbourByColor.Count - 1)]; + end = neighbourByColor[Random.Range(0, neighbourByColor.Count - 1)]; + neighbourByColor.Remove(start); + path = HasPath(start, end); + } + + if(!path.hasPath) + { + + } + + foreach (var cell in cells) + { + + } + } + + + } + private ( bool hasPath , List field ) HasPath(HexCell start, HexCell end) { List closedList = new List(); @@ -73,6 +119,7 @@ namespace HexFiled closedList.Add(currentCell); + closedList.Add(_cell); while(stackIteators.Count >= 0 )