public List<CCoord> GetEnemyVisibleArea(CCoord coord) { List<CCoord> result = new List<CCoord>(); //добавим саму точку запроса: result.Add(coord.Clone()); List<CCoord> list1 = GetAliedCells(coord, MaxVisibleDistance, false); List<CCoord> list2 = GetAliedCells(coord, MaxVisibleDistance, true); int[,] m = ListToArr(list1, Width, Height); foreach (CCoord t in list2) if (m[t.x, t.y] == t.d) result.Add(t); return result; }
private List<CCoord> GetTrackToPoint(CCoord coord) { if (st.Map[coord.x, coord.y] == TypesOfField.WALL) throw new Exception("Попытка посчитать расстояние до стены"); List<CCoord> result = new List<CCoord>(); int d = coord.d; if (d == 0) d = int.MaxValue; List<CCoord> list = st.Map.GetAliedCells(st.MyCoord, d, true); int[,] arr = ListToArr(list); CCoord c = coord.Clone(); //добавим самую последнюю точку маршрута result.Add(coord.Clone()); while (!c.EqualsXY(st.MyCoord)) { list = st.Map.GetAliedCells(c, 1, true); foreach (CCoord it in list) it.d = arr[it.x, it.y]; list.Sort(); c = list[0]; result.Add(c); } result.Reverse(); //удалим точку с которой начался маршрут result.RemoveAt(0); return result; }
//устанавливает конкретное местоположение плохого бота public void SetExactLoc(CCoord coord) { ClearLocation(); AddLocation(coord.Clone()); }
private CCoord GetNearestFreeCell(CCoord coord) { CCoord res = new CCoord(); if (st.Map[coord.x, coord.y] != TypesOfField.WALL) res = coord.Clone(); else { List<CCoord> list = st.Map.GetAliedCells(coord, 15, true); CCoord it = list[0]; int i = 1; while ((st.Map[it.x, it.y] == TypesOfField.WALL)&&(i<list.Count)) { it = list[i]; i++; } res = it; } return res; }