private void AddNodes(HexagonNode node) { if (node.X < 0) { if (node.Y < 0) { _botLeftNodes.Add(node); } else { _topLeftNodes.Add(node); } } else { if (node.Y < 0) { _botRightNodes.Add(node); } else { _topRightNodes.Add(node); } } }
private List <HexagonNode> GetNodesByPos(HexagonNode node) { if (node.X < 0) { if (node.Y < 0) { return(_botLeftNodes); } else { return(_topLeftNodes); } } else { if (node.Y < 0) { return(_botRightNodes); } else { return(_topRightNodes); } } }
private IEnumerator GenerateNodeRecursive(HexagonNode node) { yield return(new WaitForSeconds(0.075f)); GameObjectEntity nodeEntity = Instantiate(_tileEntityPrefab); nodeEntity.transform.position = new Vector2(node.X, node.Y); AddNodes(node); HexagonNode curNode; Vector2[] adjacentNodes = node.GetAdjacentNodes(CellSize, MapSize); for (int i = 0; i < adjacentNodes.Length; i++) { curNode = new HexagonNode(adjacentNodes[i].x, adjacentNodes[i].y); if (SearchNodeByPosition(curNode)) { continue; } yield return(StartCoroutine(GenerateNodeRecursive(curNode))); } }
private bool SearchNodeByPosition(HexagonNode cell) { return(GetNodesByPos(cell).Contains(cell)); }