void GenerateResources() { Resources = new List <ResourceGenerator>(); LandHex parent_hex = transform.parent.GetComponent <LandHex>(); if (!parent_hex) { return; } foreach (HexCoordinate hc in parent_hex.Directions) { HexTile neighbor = parent_hex.GetNeighbor(hc); if (neighbor && !neighbor.IsWater) { if (neighbor.transform.childCount < 1) { ResourceGenerator new_resource = Instantiate(ResourceGeneratorPrefab).GetComponent <ResourceGenerator>(); new_resource.transform.SetParent(neighbor.transform); new_resource.transform.position = neighbor.transform.position + new Vector3(0.0f, 2.0f); new_resource.transform.localScale = new Vector3(0.01f, 0.1f, 0.01f); Resources.Add(new_resource); } } } }
public void CopyHexGridToMap() { LoadingScreenManager.Instance.SetMessage("Creating minimap..."); LoadingScreenManager.Instance.SetProgress(40.0f); float camera_height = (HexGrid.Instance.GridHeight * HexGrid.Instance.HexWidth) * 0.5f / Mathf.Tan(Mathf.Deg2Rad * (GetComponent <Camera>().fieldOfView / 2.0f)); GetComponent <Camera>().farClipPlane = camera_height + 100.0f; float swap; foreach (LandHex lh in HexGrid.Instance.LandTiles) { Vector3 current_local_pos = lh.transform.localPosition; swap = current_local_pos.y; current_local_pos = new Vector3(current_local_pos.x, current_local_pos.z, swap); LandHex new_hex = Instantiate(lh); new_hex.name = lh.name; new_hex.transform.SetParent(transform); new_hex.transform.localPosition = new Vector3(current_local_pos.x, current_local_pos.y, camera_height); } foreach (WaterHex wh in HexGrid.Instance.WaterTiles) { Vector3 current_local_pos = wh.transform.localPosition; swap = current_local_pos.y; current_local_pos = new Vector3(current_local_pos.x, current_local_pos.z, swap); WaterHex new_hex = Instantiate(wh); new_hex.name = wh.name; new_hex.transform.SetParent(transform); new_hex.transform.localPosition = new Vector3(current_local_pos.x, current_local_pos.y, camera_height); } }
void OnTriggerStay(Collider other) { WaterHex water_hex = other.GetComponent <WaterHex>(); LandHex land_hex = other.GetComponent <LandHex>(); if (water_hex && water_hex.Fog) { water_hex.RevealTile(); } if (land_hex && !land_hex.Discovered) { land_hex.DiscoverTile(); } }