public BoardSection(int section, int ringCount, BoardType boardType, Vector3 sectionOrigin, int[] pCenter, GameObject pHexPrefab, float pHexSize, float rotation, Color emptyColor) { sectionNumber = section; origin = sectionOrigin; hexSize = pHexSize; center = pCenter; // Determine what column each row starts in, and how large the middle/max length row is if (boardType == BoardType.ThreePlayer) { firstColumns = new int[7] {3, 2, 2, 1, 1, 0, 0}; maxRowSize = firstColumns.Length-1; } else if (boardType == BoardType.Hexagon) { //Note: This assumes a maximum ring count of 4. firstColumns = new int[1 + (2 * ringCount)]; for (int i=ringCount; i >= 0; i--) { firstColumns[ringCount - i] = i; } //All remaining rows start all the way to the left for (int i=ringCount; i < firstColumns.Length; i++) { firstColumns[i] = 0; } maxRowSize = firstColumns.Length; } // Set up the map shape/size hexMap = new SystemHex[firstColumns.Length][]; int rowLength=0; SystemHex[] hexRow1; SystemHex[] hexRow2 = new SystemHex[1]; for (int i=0; i <= hexMap.Length / 2; i++) { if (boardType == BoardType.ThreePlayer) { if (i == 0) { rowLength = i + ringCount - 1; } else { rowLength = i + ringCount; } } else if (boardType == BoardType.Hexagon) { rowLength = i + ringCount + 1; } //Work in from both sides hexRow1 = new SystemHex[rowLength]; if (i != hexMap.Length / 2) { hexRow2 = new SystemHex[rowLength]; } for (int j=0; j < rowLength; j++) { //Create hex object and add systemHex script hexRow1[j] = setEmptyHexSlot(pHexPrefab, GetHexLocation (j,i), rotation, emptyColor); hexRow1[j].SetSection(sectionNumber); //Debug.Log("<><><><>: " + i + " , " + j); hexRow1[j].SetPosition(arrayCoordsToAxial(j, i)); if (i != hexMap.Length / 2) { hexRow2[j] = setEmptyHexSlot(pHexPrefab, GetHexLocation(j,hexMap.Length - i - 1), rotation, emptyColor); hexRow2[j].SetSection(sectionNumber); //Debug.Log("<><><><>: " + (hexMap.Length - i - 1) + " , " + j); hexRow2[j].SetPosition(arrayCoordsToAxial(j, hexMap.Length - i - 1)); } } hexMap[i] = hexRow1; if (i != hexMap.Length / 2) { hexMap[hexMap.Length - i - 1] = hexRow2; } } }
public BoardSection(int section, PlanetSystem[][] inMap, int[] inFirstColumns, Vector3 sectionOrigin, GameObject pHexPrefab, float pHexSize) { sectionNumber = section; origin = sectionOrigin; maxRowSize = inMap [inMap.Length / 2].Length/2; hexSize = pHexSize; firstColumns = inFirstColumns; hexMap = new SystemHex[inMap.Length][]; for(int i=0;i<inMap.Length;i++) { SystemHex[] hexRow = new SystemHex[inMap[i].Length]; for(int j=0;j<inMap[i].Length;j++) { //Create hex object and add systemHex script GameObject hexObject = (GameObject)GameObject.Instantiate(pHexPrefab, GetHexLocation (j,i), Quaternion.identity); SystemHex sysHex = hexObject.AddComponent<SystemHex>(); sysHex.System = inMap[i][j]; sysHex.SetSection(sectionNumber); sysHex.SetPosition(arrayCoordsToAxial(i, j)); hexObject.transform.parent = GameObject.Find("Board").transform; fileManager = GameObject.Find("Manager").GetComponent<FileManager>(); hexObject.transform.FindChild("Top").renderer.material.mainTexture = fileManager.ReadSystemTexture(inMap[i][j].Name, inMap[i][j].Id, hexObject); hexObject.name = inMap[i][j].Name; hexRow[j] = sysHex; } hexMap[i] = hexRow; } }