public void SetSystem(PlanetSystem sys, int row, int col) { //Debug.Log (row + " , " + col + " :::::: " + hexMap.Length + " ::::::::::: " + hexMap[row].Length); Vector2 arrayCoords = axialToArrayCoords(col, row); //Debug.Log (arrayCoords.x + " , " + arrayCoords.y); SystemHex hex = hexMap[(int)arrayCoords.x][(int)arrayCoords.y]; hex.System = sys; hex.SetSection(sectionNumber); hex.SetPosition(new Vector2(row, col)); fileManager = GameObject.Find("Manager").GetComponent<FileManager>(); Material topMaterial = hex.gameObject.transform.FindChild ("Top").renderer.material; topMaterial.mainTexture = fileManager.ReadSystemTexture(sys.Name, sys.Id, hex.gameObject); topMaterial.color = new Color(topMaterial.color.r, topMaterial.color.g, topMaterial.color.b, 1.0f); Material sideMaterial = hex.gameObject.renderer.material; sideMaterial.mainTexture = fileManager.ReadSystemTexture("Empty System 1", "Empty System 1", hex.gameObject); sideMaterial.color = new Color(0.035f, 0.075f, 0.212f, 1.0f); hex.gameObject.transform.FindChild("Top").gameObject.SetActive(true); hex.gameObject.name = hex.System.Name; if (sys.isSpecial()) { foreach (SystemHex iterHex in HexesInRadius(hex.GetPosition(), 1)) { iterHex.NextToSpecial = true; } } hex.IsValidPlacement = false; }
private SystemHex setEmptyHexSlot(GameObject hexPrefab, Vector3 hexLocation, float rotation, Color emptyColor) { GameObject hexObject = (GameObject)GameObject.Instantiate(hexPrefab, hexLocation, Quaternion.identity); SystemHex sysHex = hexObject.AddComponent<SystemHex>(); hexObject.transform.parent = GameObject.Find("Board").transform; hexObject.transform.Rotate(0.0f, -rotation, 0.0f); hexObject.transform.FindChild("Top").gameObject.SetActive(false); fileManager = GameObject.Find("Manager").GetComponent<FileManager>(); // Material topMaterial = hexObject.transform.FindChild ("Top").renderer.material; // topMaterial.mainTexture = fileManager.ReadSystemTexture("Regular System (Back)", "Regular System (Back)", hexObject); // topMaterial.color = new Color(topMaterial.color.r, topMaterial.color.g, topMaterial.color.b, .3f); Material sideMaterial = hexObject.renderer.material; sideMaterial.mainTexture = fileManager.ReadSystemTexture("System Placeholder", "System Placeholder", hexObject); emptyColor.a = 0.3f; sideMaterial.color = emptyColor; hexObject.name = "<Empty System Slot>"; sysHex.IsValidPlacement = false; return sysHex; }
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; } }