public void AddInfo(DataHex dataHex) { StarSystem system = dataHex.System; if (system == null) { return; } _aSysInfo[system.Index].AddResourceInfo(system); }
void MouseOver_Hex(GameObject ourHitObject) { if (Input.GetMouseButtonDown(0)) { //MeshRenderer mr = ourHitObject.GetComponentInChildren<MeshRenderer>(); DataHex data = ourHitObject.transform.GetComponent <DataHex>(); if (selectedUnit != null) { selectedUnit.goTo(ourHitObject.transform.position, data.getX(), data.getY()); gameController.checkSteps(); } } }
void CreateGrid(bool isLoaded) { for (int y = 0; y < MapInfo.current.gridHeigth; y++) { for (int x = 0; x < MapInfo.current.gridWidth; x++) { if (MapInfo.current.prefMap [x, y] == -10) { BuildTown(x, y, MapInfo.current.owners [x, y] / 100, MapInfo.current.owners [x, y] % 100); } else { hexPref = findPrefabHex.ChoosePrefHex(x, y); Transform hex = Instantiate(hexPref) as Transform; Vector2 gridPos = new Vector2(x, y); hex.position = CalcWorldPos(gridPos); hex.parent = this.transform; hex.name = "Hexagon " + x + "|" + y; DataHex data = hex.transform.GetChild(0).GetComponentInChildren <DataHex> (); if (data != null) { if (!isLoaded) { data.setData(hex.name, x, y, typeOfRelief [x, y]); } else { data.loadData(hex.name, x, y); if (MapInfo.current.unitMap [x, y] != 0) { LoadSpawn(x, y); } } } } } } }
public Town BuildTown(int x, int y, int country, int cityId) { MapInfo.current.prefMap [x, y] = -10; if (transform.Find("Hexagon " + x + "|" + y) != null) { Destroy(transform.Find("Hexagon " + x + "|" + y).gameObject); } hexPref = findPrefabHex.GetTownHex(); Transform hex = Instantiate(hexPref) as Transform; Vector2 gridPos = new Vector2(x, y); hex.position = CalcWorldPos(gridPos); hex.parent = this.transform; hex.name = "Hexagon " + x + "|" + y; Town town = hex.GetChild(0).GetComponentInChildren <Town> (); //Debug.Log (town.name); DataHex data = hex.transform.GetChild(0).GetComponentInChildren <DataHex> (); town.setTown("", country, cityId, x, y); data.setData(hex.name, x, y, -10); return(town); }