} // end method LoadMapData public void LogMapData(HexDataScript pHexData) { string outputString; outputString = "Color: " + pHexData.hexDataColor.ToString() + " Name: " + pHexData.hexDataName.ToString() + " ID: " + pHexData.hexDataID.ToString() + " Grid Location: " + pHexData.hexDataGridLocation.ToString() + " Number: " + pHexData.hexDataNumber.ToString() + " Player: " + pHexData.hexDataPlayer.ToString() + " Resource: " + ((int)pHexData.hexDataResourceType).ToString() + " Position: " + pHexData.hexDataPosition.ToString() + " Neighbor 1: " + pHexData.hexDataNeighbors[0] + " Neighbor 5: " + pHexData.hexDataNeighbors[4]; Debug.Log(outputString); } // end method LogMapData
public bool HasANeighbor(HexDataScript pHexData) { const float MAX_VECTOR_DIFF = 0.01f; string outputString; foreach (HexDataScript hexData in hexList) { if (hexData.hexDataName != pHexData.hexDataName) { for (int i = 0; i < pHexData.hexDataNeighbors.Length; i++) { if ((hexData.hexDataGridLocation - pHexData.hexDataNeighbors[i]).magnitude < MAX_VECTOR_DIFF) { return true; } } } } outputString = "Hex name: " + pHexData.hexDataName.ToString() + " is not connected to any other Hex grids!"; Debug.Log(outputString); return false; }
} // end method CalcNeighbors public bool HasANeighbor(HexDataScript pHexData) { const float MAX_VECTOR_DIFF = 0.01f; string outputString; foreach (HexDataScript hexData in hexList) { if (hexData.hexDataName != pHexData.hexDataName) { for (int i = 0; i < pHexData.hexDataNeighbors.Length; i++) { if ((hexData.hexDataGridLocation - pHexData.hexDataNeighbors[i]).magnitude < MAX_VECTOR_DIFF) { return(true); } } } } outputString = "Hex name: " + pHexData.hexDataName.ToString() + " is not connected to any other Hex grids!"; Debug.Log(outputString); return(false); } // end method HasANeighbor
public List<HexDataScript> LoadMapData() { hexList = new List<HexDataScript>(); HexDataScript tempHexData; if (!MapFileExists()) { Debug.Log("The map file cannot be found!"); return null; } if (LoadMapFile()) { for (int i = 1; i <= dataNumbers.Length; i++) { tempHexData = new HexDataScript(); tempHexData.hexDataColor = Color.red; tempHexData.hexDataName = "HexNumber" + i.ToString(); tempHexData.hexDataID = i; tempHexData.hexDataGridLocation = gridLocations[i - 1]; tempHexData.hexDataNumber = dataNumbers[i - 1]; tempHexData.hexDataPlayer = "None"; tempHexData.hexDataPosition = new Vector3(tempHexData.hexDataGridLocation.x, tempHexData.hexDataGridLocation.y * VERTICAL_SEPARATION, 0f); tempHexData.hexDataResourceType = resourceTypes[i - 1]; tempHexData.hexDataNeighbors = CalcNeighbors(tempHexData.hexDataGridLocation); hexList.Add(tempHexData); LogMapData(tempHexData); } } else { Debug.Log("The map file did not load correctly!"); Debug.Log("Loading a default, internal map instead!"); for (int i = 1; i <= 19; i++) { tempHexData = new HexDataScript(); switch (i) { case 1: tempHexData.hexDataColor = Color.red; tempHexData.hexDataName = "HexNumber" + i.ToString(); tempHexData.hexDataID = i; tempHexData.hexDataGridLocation = new Vector2(-1f, 2f); tempHexData.hexDataNumber = 2; tempHexData.hexDataPlayer = "None"; tempHexData.hexDataPosition = new Vector3(tempHexData.hexDataGridLocation.x, tempHexData.hexDataGridLocation.y * VERTICAL_SEPARATION, 0f); tempHexData.hexDataResourceType = ResourceTypes.WOOD; tempHexData.hexDataNeighbors = CalcNeighbors(tempHexData.hexDataGridLocation); hexList.Add(tempHexData); break; case 2: tempHexData.hexDataColor = Color.red; tempHexData.hexDataName = "HexNumber" + i.ToString(); tempHexData.hexDataID = i; tempHexData.hexDataGridLocation = new Vector2(0f, 2f); tempHexData.hexDataNumber = 3; tempHexData.hexDataPlayer = "None"; tempHexData.hexDataPosition = new Vector3(tempHexData.hexDataGridLocation.x, tempHexData.hexDataGridLocation.y * VERTICAL_SEPARATION, 0f); tempHexData.hexDataResourceType = ResourceTypes.WOOL; tempHexData.hexDataNeighbors = CalcNeighbors(tempHexData.hexDataGridLocation); hexList.Add(tempHexData); break; case 3: tempHexData.hexDataColor = Color.red; tempHexData.hexDataName = "HexNumber" + i.ToString(); tempHexData.hexDataID = i; tempHexData.hexDataGridLocation = new Vector2(1f, 2f); tempHexData.hexDataNumber = 6; tempHexData.hexDataPlayer = "None"; tempHexData.hexDataPosition = new Vector3(tempHexData.hexDataGridLocation.x, tempHexData.hexDataGridLocation.y * VERTICAL_SEPARATION, 0f); tempHexData.hexDataResourceType = ResourceTypes.GRAIN; tempHexData.hexDataNeighbors = CalcNeighbors(tempHexData.hexDataGridLocation); hexList.Add(tempHexData); break; case 4: tempHexData.hexDataColor = Color.red; tempHexData.hexDataName = "HexNumber" + i.ToString(); tempHexData.hexDataID = i; tempHexData.hexDataGridLocation = new Vector2(-1.5f, 1f); tempHexData.hexDataNumber = 4; tempHexData.hexDataPlayer = "None"; tempHexData.hexDataPosition = new Vector3(tempHexData.hexDataGridLocation.x, tempHexData.hexDataGridLocation.y * VERTICAL_SEPARATION, 0f); tempHexData.hexDataResourceType = ResourceTypes.BRICK; tempHexData.hexDataNeighbors = CalcNeighbors(tempHexData.hexDataGridLocation); hexList.Add(tempHexData); break; case 5: tempHexData.hexDataColor = Color.red; tempHexData.hexDataName = "HexNumber" + i.ToString(); tempHexData.hexDataID = i; tempHexData.hexDataGridLocation = new Vector2(-0.5f, 1f); tempHexData.hexDataNumber = 6; tempHexData.hexDataPlayer = "None"; tempHexData.hexDataPosition = new Vector3(tempHexData.hexDataGridLocation.x, tempHexData.hexDataGridLocation.y * VERTICAL_SEPARATION, 0f); tempHexData.hexDataResourceType = ResourceTypes.GRAIN; tempHexData.hexDataNeighbors = CalcNeighbors(tempHexData.hexDataGridLocation); hexList.Add(tempHexData); break; case 6: tempHexData.hexDataColor = Color.red; tempHexData.hexDataName = "HexNumber" + i.ToString(); tempHexData.hexDataID = i; tempHexData.hexDataGridLocation = new Vector2(0.5f, 1f); tempHexData.hexDataNumber = 5; tempHexData.hexDataPlayer = "None"; tempHexData.hexDataPosition = new Vector3(tempHexData.hexDataGridLocation.x, tempHexData.hexDataGridLocation.y * VERTICAL_SEPARATION, 0f); tempHexData.hexDataResourceType = ResourceTypes.BRICK; tempHexData.hexDataNeighbors = CalcNeighbors(tempHexData.hexDataGridLocation); hexList.Add(tempHexData); break; case 7: tempHexData.hexDataColor = Color.red; tempHexData.hexDataName = "HexNumber" + i.ToString(); tempHexData.hexDataID = i; tempHexData.hexDataGridLocation = new Vector2(1.5f, 1f); tempHexData.hexDataNumber = 2; tempHexData.hexDataPlayer = "None"; tempHexData.hexDataPosition = new Vector3(tempHexData.hexDataGridLocation.x, tempHexData.hexDataGridLocation.y * VERTICAL_SEPARATION, 0f); tempHexData.hexDataResourceType = ResourceTypes.WOOL; tempHexData.hexDataNeighbors = CalcNeighbors(tempHexData.hexDataGridLocation); hexList.Add(tempHexData); break; case 8: tempHexData.hexDataColor = Color.red; tempHexData.hexDataName = "HexNumber" + i.ToString(); tempHexData.hexDataID = i; tempHexData.hexDataGridLocation = new Vector2(-2f, 0f); tempHexData.hexDataNumber = 2; tempHexData.hexDataPlayer = "None"; tempHexData.hexDataPosition = new Vector3(tempHexData.hexDataGridLocation.x, tempHexData.hexDataGridLocation.y * VERTICAL_SEPARATION, 0f); tempHexData.hexDataResourceType = ResourceTypes.WOOL; tempHexData.hexDataNeighbors = CalcNeighbors(tempHexData.hexDataGridLocation); hexList.Add(tempHexData); break; case 9: tempHexData.hexDataColor = Color.red; tempHexData.hexDataName = "HexNumber" + i.ToString(); tempHexData.hexDataID = i; tempHexData.hexDataGridLocation = new Vector2(-1f, 0f); tempHexData.hexDataNumber = 3; tempHexData.hexDataPlayer = "None"; tempHexData.hexDataPosition = new Vector3(tempHexData.hexDataGridLocation.x, tempHexData.hexDataGridLocation.y * VERTICAL_SEPARATION, 0f); tempHexData.hexDataResourceType = ResourceTypes.WOOD; tempHexData.hexDataNeighbors = CalcNeighbors(tempHexData.hexDataGridLocation); hexList.Add(tempHexData); break; case 10: tempHexData.hexDataColor = Color.red; tempHexData.hexDataName = "HexNumber" + i.ToString(); tempHexData.hexDataID = i; tempHexData.hexDataGridLocation = new Vector2(0f, 0f); tempHexData.hexDataNumber = 1; tempHexData.hexDataPlayer = "None"; tempHexData.hexDataPosition = new Vector3(tempHexData.hexDataGridLocation.x, tempHexData.hexDataGridLocation.y * VERTICAL_SEPARATION, 0f); tempHexData.hexDataResourceType = ResourceTypes.GRAIN; tempHexData.hexDataNeighbors = CalcNeighbors(tempHexData.hexDataGridLocation); hexList.Add(tempHexData); break; case 11: tempHexData.hexDataColor = Color.red; tempHexData.hexDataName = "HexNumber" + i.ToString(); tempHexData.hexDataID = i; tempHexData.hexDataGridLocation = new Vector2(1f, 0f); tempHexData.hexDataNumber = 4; tempHexData.hexDataPlayer = "None"; tempHexData.hexDataPosition = new Vector3(tempHexData.hexDataGridLocation.x, tempHexData.hexDataGridLocation.y * VERTICAL_SEPARATION, 0f); tempHexData.hexDataResourceType = ResourceTypes.WOOD; tempHexData.hexDataNeighbors = CalcNeighbors(tempHexData.hexDataGridLocation); hexList.Add(tempHexData); break; case 12: tempHexData.hexDataColor = Color.red; tempHexData.hexDataName = "HexNumber" + i.ToString(); tempHexData.hexDataID = i; tempHexData.hexDataGridLocation = new Vector2(2f, 0f); tempHexData.hexDataNumber = 1; tempHexData.hexDataPlayer = "None"; tempHexData.hexDataPosition = new Vector3(tempHexData.hexDataGridLocation.x, tempHexData.hexDataGridLocation.y * VERTICAL_SEPARATION, 0f); tempHexData.hexDataResourceType = ResourceTypes.GRAIN; tempHexData.hexDataNeighbors = CalcNeighbors(tempHexData.hexDataGridLocation); hexList.Add(tempHexData); break; case 13: tempHexData.hexDataColor = Color.red; tempHexData.hexDataName = "HexNumber" + i.ToString(); tempHexData.hexDataID = i; tempHexData.hexDataGridLocation = new Vector2(-1.5f, -1f); tempHexData.hexDataNumber = 1; tempHexData.hexDataPlayer = "None"; tempHexData.hexDataPosition = new Vector3(tempHexData.hexDataGridLocation.x, tempHexData.hexDataGridLocation.y * VERTICAL_SEPARATION, 0f); tempHexData.hexDataResourceType = ResourceTypes.BRICK; tempHexData.hexDataNeighbors = CalcNeighbors(tempHexData.hexDataGridLocation); hexList.Add(tempHexData); break; case 14: tempHexData.hexDataColor = Color.red; tempHexData.hexDataName = "HexNumber" + i.ToString(); tempHexData.hexDataID = i; tempHexData.hexDataGridLocation = new Vector2(-0.5f, -1f); tempHexData.hexDataNumber = 4; tempHexData.hexDataPlayer = "None"; tempHexData.hexDataPosition = new Vector3(tempHexData.hexDataGridLocation.x, tempHexData.hexDataGridLocation.y * VERTICAL_SEPARATION, 0f); tempHexData.hexDataResourceType = ResourceTypes.WOOL; tempHexData.hexDataNeighbors = CalcNeighbors(tempHexData.hexDataGridLocation); hexList.Add(tempHexData); break; case 15: tempHexData.hexDataColor = Color.red; tempHexData.hexDataName = "HexNumber" + i.ToString(); tempHexData.hexDataID = i; tempHexData.hexDataGridLocation = new Vector2(0.5f, -1f); tempHexData.hexDataNumber = 5; tempHexData.hexDataPlayer = "None"; tempHexData.hexDataPosition = new Vector3(tempHexData.hexDataGridLocation.x, tempHexData.hexDataGridLocation.y * VERTICAL_SEPARATION, 0f); tempHexData.hexDataResourceType = ResourceTypes.WOOL; tempHexData.hexDataNeighbors = CalcNeighbors(tempHexData.hexDataGridLocation); hexList.Add(tempHexData); break; case 16: tempHexData.hexDataColor = Color.red; tempHexData.hexDataName = "HexNumber" + i.ToString(); tempHexData.hexDataID = i; tempHexData.hexDataGridLocation = new Vector2(1.5f, -1f); tempHexData.hexDataNumber = 3; tempHexData.hexDataPlayer = "None"; tempHexData.hexDataPosition = new Vector3(tempHexData.hexDataGridLocation.x, tempHexData.hexDataGridLocation.y * VERTICAL_SEPARATION, 0f); tempHexData.hexDataResourceType = ResourceTypes.BRICK; tempHexData.hexDataNeighbors = CalcNeighbors(tempHexData.hexDataGridLocation); hexList.Add(tempHexData); break; case 17: tempHexData.hexDataColor = Color.red; tempHexData.hexDataName = "HexNumber" + i.ToString(); tempHexData.hexDataID = i; tempHexData.hexDataGridLocation = new Vector2(-1f, -2f); tempHexData.hexDataNumber = 5; tempHexData.hexDataPlayer = "None"; tempHexData.hexDataPosition = new Vector3(tempHexData.hexDataGridLocation.x, tempHexData.hexDataGridLocation.y * VERTICAL_SEPARATION, 0f); tempHexData.hexDataResourceType = ResourceTypes.WOOD; tempHexData.hexDataNeighbors = CalcNeighbors(tempHexData.hexDataGridLocation); hexList.Add(tempHexData); break; case 18: tempHexData.hexDataColor = Color.red; tempHexData.hexDataName = "HexNumber" + i.ToString(); tempHexData.hexDataID = i; tempHexData.hexDataGridLocation = new Vector2(0f, -2f); tempHexData.hexDataNumber = 2; tempHexData.hexDataPlayer = "None"; tempHexData.hexDataPosition = new Vector3(tempHexData.hexDataGridLocation.x, tempHexData.hexDataGridLocation.y * VERTICAL_SEPARATION, 0f); tempHexData.hexDataResourceType = ResourceTypes.GRAIN; tempHexData.hexDataNeighbors = CalcNeighbors(tempHexData.hexDataGridLocation); hexList.Add(tempHexData); break; case 19: tempHexData.hexDataColor = Color.red; tempHexData.hexDataName = "HexNumber" + i.ToString(); tempHexData.hexDataID = i; tempHexData.hexDataGridLocation = new Vector2(1f, -2f); tempHexData.hexDataNumber = 6; tempHexData.hexDataPlayer = "None"; tempHexData.hexDataPosition = new Vector3(tempHexData.hexDataGridLocation.x, tempHexData.hexDataGridLocation.y * VERTICAL_SEPARATION, 0f); tempHexData.hexDataResourceType = ResourceTypes.WOOD; tempHexData.hexDataNeighbors = CalcNeighbors(tempHexData.hexDataGridLocation); hexList.Add(tempHexData); break; } // end switch LogMapData(tempHexData); } // end for (int i = 1; i <= 19; i++)... } // end if (LoadMapFile())...else... if (MapIsValid()) return hexList; else return null; }
public void LogMapData(HexDataScript pHexData) { string outputString; outputString = "Color: " + pHexData.hexDataColor.ToString() + " Name: " + pHexData.hexDataName.ToString() + " ID: " + pHexData.hexDataID.ToString() + " Grid Location: " + pHexData.hexDataGridLocation.ToString() + " Number: " + pHexData.hexDataNumber.ToString() + " Player: " + pHexData.hexDataPlayer.ToString() + " Resource: " + ((int)pHexData.hexDataResourceType).ToString() + " Position: " + pHexData.hexDataPosition.ToString() + " Neighbor 1: " + pHexData.hexDataNeighbors[0] + " Neighbor 5: " + pHexData.hexDataNeighbors[4]; Debug.Log(outputString); }
public List <HexDataScript> LoadMapData() { hexList = new List <HexDataScript>(); HexDataScript tempHexData; if (!MapFileExists()) { Debug.Log("The map file cannot be found!"); return(null); } if (LoadMapFile()) { for (int i = 1; i <= dataNumbers.Length; i++) { tempHexData = new HexDataScript(); tempHexData.hexDataColor = Color.red; tempHexData.hexDataName = "HexNumber" + i.ToString(); tempHexData.hexDataID = i; tempHexData.hexDataGridLocation = gridLocations[i - 1]; tempHexData.hexDataNumber = dataNumbers[i - 1]; tempHexData.hexDataPlayer = "None"; tempHexData.hexDataPosition = new Vector3(tempHexData.hexDataGridLocation.x, tempHexData.hexDataGridLocation.y * VERTICAL_SEPARATION, 0f); tempHexData.hexDataResourceType = resourceTypes[i - 1]; tempHexData.hexDataNeighbors = CalcNeighbors(tempHexData.hexDataGridLocation); hexList.Add(tempHexData); LogMapData(tempHexData); } } else { Debug.Log("The map file did not load correctly!"); Debug.Log("Loading a default, internal map instead!"); for (int i = 1; i <= 19; i++) { tempHexData = new HexDataScript(); switch (i) { case 1: tempHexData.hexDataColor = Color.red; tempHexData.hexDataName = "HexNumber" + i.ToString(); tempHexData.hexDataID = i; tempHexData.hexDataGridLocation = new Vector2(-1f, 2f); tempHexData.hexDataNumber = 2; tempHexData.hexDataPlayer = "None"; tempHexData.hexDataPosition = new Vector3(tempHexData.hexDataGridLocation.x, tempHexData.hexDataGridLocation.y * VERTICAL_SEPARATION, 0f); tempHexData.hexDataResourceType = ResourceTypes.WOOD; tempHexData.hexDataNeighbors = CalcNeighbors(tempHexData.hexDataGridLocation); hexList.Add(tempHexData); break; case 2: tempHexData.hexDataColor = Color.red; tempHexData.hexDataName = "HexNumber" + i.ToString(); tempHexData.hexDataID = i; tempHexData.hexDataGridLocation = new Vector2(0f, 2f); tempHexData.hexDataNumber = 3; tempHexData.hexDataPlayer = "None"; tempHexData.hexDataPosition = new Vector3(tempHexData.hexDataGridLocation.x, tempHexData.hexDataGridLocation.y * VERTICAL_SEPARATION, 0f); tempHexData.hexDataResourceType = ResourceTypes.WOOL; tempHexData.hexDataNeighbors = CalcNeighbors(tempHexData.hexDataGridLocation); hexList.Add(tempHexData); break; case 3: tempHexData.hexDataColor = Color.red; tempHexData.hexDataName = "HexNumber" + i.ToString(); tempHexData.hexDataID = i; tempHexData.hexDataGridLocation = new Vector2(1f, 2f); tempHexData.hexDataNumber = 6; tempHexData.hexDataPlayer = "None"; tempHexData.hexDataPosition = new Vector3(tempHexData.hexDataGridLocation.x, tempHexData.hexDataGridLocation.y * VERTICAL_SEPARATION, 0f); tempHexData.hexDataResourceType = ResourceTypes.GRAIN; tempHexData.hexDataNeighbors = CalcNeighbors(tempHexData.hexDataGridLocation); hexList.Add(tempHexData); break; case 4: tempHexData.hexDataColor = Color.red; tempHexData.hexDataName = "HexNumber" + i.ToString(); tempHexData.hexDataID = i; tempHexData.hexDataGridLocation = new Vector2(-1.5f, 1f); tempHexData.hexDataNumber = 4; tempHexData.hexDataPlayer = "None"; tempHexData.hexDataPosition = new Vector3(tempHexData.hexDataGridLocation.x, tempHexData.hexDataGridLocation.y * VERTICAL_SEPARATION, 0f); tempHexData.hexDataResourceType = ResourceTypes.BRICK; tempHexData.hexDataNeighbors = CalcNeighbors(tempHexData.hexDataGridLocation); hexList.Add(tempHexData); break; case 5: tempHexData.hexDataColor = Color.red; tempHexData.hexDataName = "HexNumber" + i.ToString(); tempHexData.hexDataID = i; tempHexData.hexDataGridLocation = new Vector2(-0.5f, 1f); tempHexData.hexDataNumber = 6; tempHexData.hexDataPlayer = "None"; tempHexData.hexDataPosition = new Vector3(tempHexData.hexDataGridLocation.x, tempHexData.hexDataGridLocation.y * VERTICAL_SEPARATION, 0f); tempHexData.hexDataResourceType = ResourceTypes.GRAIN; tempHexData.hexDataNeighbors = CalcNeighbors(tempHexData.hexDataGridLocation); hexList.Add(tempHexData); break; case 6: tempHexData.hexDataColor = Color.red; tempHexData.hexDataName = "HexNumber" + i.ToString(); tempHexData.hexDataID = i; tempHexData.hexDataGridLocation = new Vector2(0.5f, 1f); tempHexData.hexDataNumber = 5; tempHexData.hexDataPlayer = "None"; tempHexData.hexDataPosition = new Vector3(tempHexData.hexDataGridLocation.x, tempHexData.hexDataGridLocation.y * VERTICAL_SEPARATION, 0f); tempHexData.hexDataResourceType = ResourceTypes.BRICK; tempHexData.hexDataNeighbors = CalcNeighbors(tempHexData.hexDataGridLocation); hexList.Add(tempHexData); break; case 7: tempHexData.hexDataColor = Color.red; tempHexData.hexDataName = "HexNumber" + i.ToString(); tempHexData.hexDataID = i; tempHexData.hexDataGridLocation = new Vector2(1.5f, 1f); tempHexData.hexDataNumber = 2; tempHexData.hexDataPlayer = "None"; tempHexData.hexDataPosition = new Vector3(tempHexData.hexDataGridLocation.x, tempHexData.hexDataGridLocation.y * VERTICAL_SEPARATION, 0f); tempHexData.hexDataResourceType = ResourceTypes.WOOL; tempHexData.hexDataNeighbors = CalcNeighbors(tempHexData.hexDataGridLocation); hexList.Add(tempHexData); break; case 8: tempHexData.hexDataColor = Color.red; tempHexData.hexDataName = "HexNumber" + i.ToString(); tempHexData.hexDataID = i; tempHexData.hexDataGridLocation = new Vector2(-2f, 0f); tempHexData.hexDataNumber = 2; tempHexData.hexDataPlayer = "None"; tempHexData.hexDataPosition = new Vector3(tempHexData.hexDataGridLocation.x, tempHexData.hexDataGridLocation.y * VERTICAL_SEPARATION, 0f); tempHexData.hexDataResourceType = ResourceTypes.WOOL; tempHexData.hexDataNeighbors = CalcNeighbors(tempHexData.hexDataGridLocation); hexList.Add(tempHexData); break; case 9: tempHexData.hexDataColor = Color.red; tempHexData.hexDataName = "HexNumber" + i.ToString(); tempHexData.hexDataID = i; tempHexData.hexDataGridLocation = new Vector2(-1f, 0f); tempHexData.hexDataNumber = 3; tempHexData.hexDataPlayer = "None"; tempHexData.hexDataPosition = new Vector3(tempHexData.hexDataGridLocation.x, tempHexData.hexDataGridLocation.y * VERTICAL_SEPARATION, 0f); tempHexData.hexDataResourceType = ResourceTypes.WOOD; tempHexData.hexDataNeighbors = CalcNeighbors(tempHexData.hexDataGridLocation); hexList.Add(tempHexData); break; case 10: tempHexData.hexDataColor = Color.red; tempHexData.hexDataName = "HexNumber" + i.ToString(); tempHexData.hexDataID = i; tempHexData.hexDataGridLocation = new Vector2(0f, 0f); tempHexData.hexDataNumber = 1; tempHexData.hexDataPlayer = "None"; tempHexData.hexDataPosition = new Vector3(tempHexData.hexDataGridLocation.x, tempHexData.hexDataGridLocation.y * VERTICAL_SEPARATION, 0f); tempHexData.hexDataResourceType = ResourceTypes.GRAIN; tempHexData.hexDataNeighbors = CalcNeighbors(tempHexData.hexDataGridLocation); hexList.Add(tempHexData); break; case 11: tempHexData.hexDataColor = Color.red; tempHexData.hexDataName = "HexNumber" + i.ToString(); tempHexData.hexDataID = i; tempHexData.hexDataGridLocation = new Vector2(1f, 0f); tempHexData.hexDataNumber = 4; tempHexData.hexDataPlayer = "None"; tempHexData.hexDataPosition = new Vector3(tempHexData.hexDataGridLocation.x, tempHexData.hexDataGridLocation.y * VERTICAL_SEPARATION, 0f); tempHexData.hexDataResourceType = ResourceTypes.WOOD; tempHexData.hexDataNeighbors = CalcNeighbors(tempHexData.hexDataGridLocation); hexList.Add(tempHexData); break; case 12: tempHexData.hexDataColor = Color.red; tempHexData.hexDataName = "HexNumber" + i.ToString(); tempHexData.hexDataID = i; tempHexData.hexDataGridLocation = new Vector2(2f, 0f); tempHexData.hexDataNumber = 1; tempHexData.hexDataPlayer = "None"; tempHexData.hexDataPosition = new Vector3(tempHexData.hexDataGridLocation.x, tempHexData.hexDataGridLocation.y * VERTICAL_SEPARATION, 0f); tempHexData.hexDataResourceType = ResourceTypes.GRAIN; tempHexData.hexDataNeighbors = CalcNeighbors(tempHexData.hexDataGridLocation); hexList.Add(tempHexData); break; case 13: tempHexData.hexDataColor = Color.red; tempHexData.hexDataName = "HexNumber" + i.ToString(); tempHexData.hexDataID = i; tempHexData.hexDataGridLocation = new Vector2(-1.5f, -1f); tempHexData.hexDataNumber = 1; tempHexData.hexDataPlayer = "None"; tempHexData.hexDataPosition = new Vector3(tempHexData.hexDataGridLocation.x, tempHexData.hexDataGridLocation.y * VERTICAL_SEPARATION, 0f); tempHexData.hexDataResourceType = ResourceTypes.BRICK; tempHexData.hexDataNeighbors = CalcNeighbors(tempHexData.hexDataGridLocation); hexList.Add(tempHexData); break; case 14: tempHexData.hexDataColor = Color.red; tempHexData.hexDataName = "HexNumber" + i.ToString(); tempHexData.hexDataID = i; tempHexData.hexDataGridLocation = new Vector2(-0.5f, -1f); tempHexData.hexDataNumber = 4; tempHexData.hexDataPlayer = "None"; tempHexData.hexDataPosition = new Vector3(tempHexData.hexDataGridLocation.x, tempHexData.hexDataGridLocation.y * VERTICAL_SEPARATION, 0f); tempHexData.hexDataResourceType = ResourceTypes.WOOL; tempHexData.hexDataNeighbors = CalcNeighbors(tempHexData.hexDataGridLocation); hexList.Add(tempHexData); break; case 15: tempHexData.hexDataColor = Color.red; tempHexData.hexDataName = "HexNumber" + i.ToString(); tempHexData.hexDataID = i; tempHexData.hexDataGridLocation = new Vector2(0.5f, -1f); tempHexData.hexDataNumber = 5; tempHexData.hexDataPlayer = "None"; tempHexData.hexDataPosition = new Vector3(tempHexData.hexDataGridLocation.x, tempHexData.hexDataGridLocation.y * VERTICAL_SEPARATION, 0f); tempHexData.hexDataResourceType = ResourceTypes.WOOL; tempHexData.hexDataNeighbors = CalcNeighbors(tempHexData.hexDataGridLocation); hexList.Add(tempHexData); break; case 16: tempHexData.hexDataColor = Color.red; tempHexData.hexDataName = "HexNumber" + i.ToString(); tempHexData.hexDataID = i; tempHexData.hexDataGridLocation = new Vector2(1.5f, -1f); tempHexData.hexDataNumber = 3; tempHexData.hexDataPlayer = "None"; tempHexData.hexDataPosition = new Vector3(tempHexData.hexDataGridLocation.x, tempHexData.hexDataGridLocation.y * VERTICAL_SEPARATION, 0f); tempHexData.hexDataResourceType = ResourceTypes.BRICK; tempHexData.hexDataNeighbors = CalcNeighbors(tempHexData.hexDataGridLocation); hexList.Add(tempHexData); break; case 17: tempHexData.hexDataColor = Color.red; tempHexData.hexDataName = "HexNumber" + i.ToString(); tempHexData.hexDataID = i; tempHexData.hexDataGridLocation = new Vector2(-1f, -2f); tempHexData.hexDataNumber = 5; tempHexData.hexDataPlayer = "None"; tempHexData.hexDataPosition = new Vector3(tempHexData.hexDataGridLocation.x, tempHexData.hexDataGridLocation.y * VERTICAL_SEPARATION, 0f); tempHexData.hexDataResourceType = ResourceTypes.WOOD; tempHexData.hexDataNeighbors = CalcNeighbors(tempHexData.hexDataGridLocation); hexList.Add(tempHexData); break; case 18: tempHexData.hexDataColor = Color.red; tempHexData.hexDataName = "HexNumber" + i.ToString(); tempHexData.hexDataID = i; tempHexData.hexDataGridLocation = new Vector2(0f, -2f); tempHexData.hexDataNumber = 2; tempHexData.hexDataPlayer = "None"; tempHexData.hexDataPosition = new Vector3(tempHexData.hexDataGridLocation.x, tempHexData.hexDataGridLocation.y * VERTICAL_SEPARATION, 0f); tempHexData.hexDataResourceType = ResourceTypes.GRAIN; tempHexData.hexDataNeighbors = CalcNeighbors(tempHexData.hexDataGridLocation); hexList.Add(tempHexData); break; case 19: tempHexData.hexDataColor = Color.red; tempHexData.hexDataName = "HexNumber" + i.ToString(); tempHexData.hexDataID = i; tempHexData.hexDataGridLocation = new Vector2(1f, -2f); tempHexData.hexDataNumber = 6; tempHexData.hexDataPlayer = "None"; tempHexData.hexDataPosition = new Vector3(tempHexData.hexDataGridLocation.x, tempHexData.hexDataGridLocation.y * VERTICAL_SEPARATION, 0f); tempHexData.hexDataResourceType = ResourceTypes.WOOD; tempHexData.hexDataNeighbors = CalcNeighbors(tempHexData.hexDataGridLocation); hexList.Add(tempHexData); break; } // end switch LogMapData(tempHexData); } // end for (int i = 1; i <= 19; i++)... } // end if (LoadMapFile())...else... if (MapIsValid()) { return(hexList); } else { return(null); } } // end method LoadMapData