public void Show(int hatchId) { this.currentHatchId = hatchId; this.currentHatchBuilding = TerrainManager.instance.tileTerrain.GetHatchById(currentHatchId); root.SetActive(true); Refresh(); }
void EditBuilding() { if (!CheckEditBuilding()) { return; } RaycastHit hit; Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition); Vector3 pos; int x, y; if (Physics.Raycast(ray, out hit, Mathf.Infinity, editCrystalLayerMask)) { PATileTerrain tt = tileTerrain.IsTerrain(hit.transform); NestBuilding hitNest = hit.transform.GetComponent <NestBuilding>(); HatchBuilding hitHatch = hit.transform.GetComponent <HatchBuilding>(); if (tt != null) { pos = tileTerrain.transform.InverseTransformPoint(hit.point); x = (int)Mathf.Abs(pos.x / tileTerrain.tileSize); y = (int)Mathf.Abs(pos.z / tileTerrain.tileSize); PATileTerrain.PATile tile = tileTerrain.GetTile(x, y); PATileTerrain.PABuildingTile buildingTile = PATileTerrain.PABuildingTile.GetByTile(tileTerrain, tile); if (toPlaceBuilding is NestBuilding && buildingTile.keyTile.affectShuijing != null) { NestBuilding nest = toPlaceBuilding as NestBuilding; PlaceNest(nest, buildingTile); toPlaceBuilding = null; //Messenger.Broadcast(TerrainManagerEvent_PlaceBuilding); } } else if (hitNest != null && toPlaceBuilding == null) { Messenger.Broadcast(UIEvent.UIEvent_ShowSelectNest); } else if (hitHatch != null && toPlaceBuilding == null) { Messenger <int> .Broadcast(UIEvent.UIEvent_ShowHatch, hitHatch.hatchId); } } }
public void CreateBuildings(PATileTerrain tileTerrain) { return; RandomManager.instance.SetSeed(tileTerrain.settings.GetCrystalBuilding(tile.id).randomSeed); PATileTerrainChunk chunk = tileTerrain.GetChunk(tile.chunkId); foreach (var point in vPoints) { if (point.closeTile == null) { point.closeTile = GetTileByPoint(tileTerrain, point.transform); } if (point.closeTile == null) { continue; } //Debug.Log("pointTile.x " + pointTile.x + " pointTile.y " + pointTile.y + " point " + point.transform); if (point.virtualPointType != VirtualPoint.VirtualPointType.Building) { continue; } if (!point.CheckAreaType(tileTerrain)) { if (point.building != null) { buildings.Remove(point.building); point.RemoveBuilding(); } } else { if (point.building == null) { Transform building = point.CreateBuilding(chunk.settings.decoratesRoot); if (building != null) { HatchBuilding hatchBuilding = building.GetComponent <HatchBuilding>(); if (hatchBuilding != null) { hatchBuilding.hatchId = tile.id; this.hatch = hatchBuilding; } buildings.Add(building); } } } } if (Application.isPlaying) { LocalNavMeshBuilder.instance.UpdateNavMesh(); } //foreach (var point in vPoints) //{ // if (point.virtualPointType != VirtualPoint.VirtualPointType.Animals) // continue; // if(point.building == null) // { // Transform building = point.CreateBuilding(chunk.settings.decoratesRoot); // if (building != null) // buildings.Add(building); // } //} }