void EditCrystal() { if (!CheckEditCrystal()) { 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); Shuijing hitShuijing = hit.transform.GetComponent <Shuijing>(); if (tt != null) { if (toPlaceBuilding == null) { SetSelectShuijing(null); Messenger <PATileTerrain.PATile> .Broadcast(UIEvent.UIEvent_ShowSelectCrystal, null); } else { 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); Shuijing shuijing = toPlaceBuilding as Shuijing; if (!CheckCrystalDistance(buildingTile.keyTile, shuijing)) { Messenger.Broadcast(UIEvent.UIEvent_CrystalDistanceTip); return; } PlaceCrystal(shuijing, buildingTile); shuijing.SetSelectTag(false); RepaintAllCrystals(); //PaintCrystal(shuijing); toPlaceBuilding = null; //SetSelectShuijing(shuijing); Messenger.Broadcast(TerrainManagerEvent_PlaceBuilding); } } else if (hitShuijing != null && toPlaceBuilding == null) { SetSelectShuijing(hitShuijing); MoveCameraToPos(hitShuijing.transform, MoveToCrystalCallBack); } else { SetSelectShuijing(null); } } }
public void SetSelectShuijing(Shuijing shuijing) { if (selectShuijing != null) { selectShuijing.SetSelectTag(false); } selectShuijing = shuijing; if (selectShuijing != null) { selectShuijing.SetSelectTag(true); } else { Messenger.Broadcast(UIEvent.UIEvent_ShowCrystalOption); } }