void SpreadBlues(LocalPos pos, byte distance, LocalMap map) { short index = (short)RenderedBlues.FindIndex(x => x.Hex.GetComponent<HexInteraction>().Pos == pos); if (index == -1) HighlightHex(pos); else { if (RenderedBlues[index].InSign) return; else RenderedBlues[index].InSign = true; } if (distance != 0) { for (byte i = 0; i < 6; ++i) { GlobalPos buf = HexNavigHelper.GetNeighborMapCoords(pos, (TurnedHexDirection)i); if (buf.X >= 0 && buf.Y >= 0 && buf.X < map.Width && buf.Y < map.Height && !map.IsBlocked((LocalPos)buf)) BluesSignQueue.Enqueue(new QueueType { Pos = buf, Distance = (byte)(distance - 1) }); } } }
public void RenderBluesHexes(LocalPos pos, byte distance, LocalMap map) { Debug.Assert(distance != 0); RenderedBlues.ForEach(hex => hex.InSign = false); for (byte i = 0; i < 6; ++i) { GlobalPos buf = HexNavigHelper.GetNeighborMapCoords(pos, (TurnedHexDirection)i); if (buf.X >= 0 && buf.Y >= 0 && buf.X < map.Width && buf.Y < map.Height && !map.IsBlocked((LocalPos)buf)) BluesSignQueue.Enqueue(new QueueType { Pos = buf, Distance = (byte)(distance - 1) }); } while (BluesSignQueue.Count != 0) { QueueType buf = BluesSignQueue.Dequeue(); SpreadBlues((LocalPos)buf.Pos, buf.Distance, map); } for (ushort i = 0; i < RenderedBlues.Count; ++i) if (!RenderedBlues[i].InSign) { Destroy(RenderedBlues[i].Hex); RenderedBlues.RemoveAt(i); if (i != 0) i--; } }