// Use this for initialization void Start() { PlayerPrefs.SetInt("numberOfPlayers", 4); timer = GameObject.Find("TurnTimer").GetComponent <Timer>(); hexagonMapGenerator = GameObject.Find("HexagonMap").GetComponent <HexagonMapGenerator>(); SpawnPlayersOnMap(); }
public static Vector2[] GetAdjacentNodesByPos(float x, float y, float cellSize, float mapSize) { float nextTopY = (float)Math.Round(y + cellSize, 2); float nextBotY = (float)Math.Round(y - cellSize, 2); float nextLeftX = (float)Math.Round(x - 0.75f * cellSize, 2); float nextSideBotY = (float)Math.Round(y - (cellSize * 0.5f), 2); float nextRightX = (float)Math.Round(x + 0.75f * cellSize, 2); float nextSideTopY = (float)Math.Round(y + (cellSize * 0.5f), 2); List <Vector2> adjacentNodes = new List <Vector2>(); if (HexagonMapGenerator.CheckInsideHexagon(x, nextTopY, cellSize, mapSize)) { adjacentNodes.Add(new Vector2(x, nextTopY)); } if (HexagonMapGenerator.CheckInsideHexagon(x, nextBotY, cellSize, mapSize)) { adjacentNodes.Add(new Vector2(x, nextBotY)); } if (HexagonMapGenerator.CheckInsideHexagon(nextLeftX, nextSideTopY, cellSize, mapSize)) { adjacentNodes.Add(new Vector2(nextLeftX, nextSideTopY)); } if (HexagonMapGenerator.CheckInsideHexagon(nextLeftX, nextSideBotY, cellSize, mapSize)) { adjacentNodes.Add(new Vector2(nextLeftX, nextSideBotY)); } if (HexagonMapGenerator.CheckInsideHexagon(nextRightX, nextSideTopY, cellSize, mapSize)) { adjacentNodes.Add(new Vector2(nextRightX, nextSideTopY)); } if (HexagonMapGenerator.CheckInsideHexagon(nextRightX, nextSideBotY, cellSize, mapSize)) { adjacentNodes.Add(new Vector2(nextRightX, nextSideBotY)); } return(adjacentNodes.ToArray()); }