void HandleOn_AnimatorEvent(UnityEngine.Object value) { float screenX = _playerController.playerInputState.X; float screenY = _playerController.playerInputState.Y; RaycastHit hit; if (Terrain.RayToWorld(screenX, screenY, _playerController.transform.position, distance, out hit, oppoMaskLayer)) { WorldPos pos = Terrain.GetWorldPos(hit, false); if (hit.collider.GetComponentInParent <ChunkObj>() == null) { return; } Block hitBlock = World.world.GetBlock(pos.x, pos.y, pos.z); if (hitBlock.BlockType == BlockType.Air) { return; } int handMaterialId = _playerController.playerAttribute.handMaterialId; if (MineController.Instance.Mine(handMaterialId, pos, hitBlock)) { BlockExplodeController.Instance.Explode(pos, hitBlock, hit.normal); Terrain.SetBlock(pos, air); DropController.Instance.Drop(handMaterialId, pos, hitBlock); } } }
public void Do(float screenX, float screenY, Vector3 position, float distance) { RaycastHit hit; int mask = LayerMask.GetMask(new string[] { "TerrainMesh", "SupportColliderMesh" }); if (Terrain.RayToWorld(screenX, screenY, position, distance, out hit, mask)) { WorldPos pos = Terrain.GetWorldPos(hit, false); if (hit.collider.GetComponentInParent <ChunkObj>() == null) { return; } ShowMaskObj(pos); } else { HideMaskObj(); } }
public override bool MeetCondition() { float screenX = _playerController.playerInputState.X; float screenY = _playerController.playerInputState.Y; RaycastHit hit; if (Terrain.RayToWorld(screenX, screenY, _playerController.transform.position, distance, out hit, oppoMaskLayer)) { if ((resultLayer & (1 << hit.collider.gameObject.layer)) == 0) { return(false); } else { return(HitDetailCondition(hit)); } } return(false); }
public override void ActionIn() { float screenX = _playerController.playerInputState.X; float screenY = _playerController.playerInputState.Y; BlockMaskController.Instance.Do(screenX, screenY, _playerController.transform.position, distance); RaycastHit hit; int handMaterialId = _playerController.playerAttribute.handMaterialId; if (handMaterialId <= 0) { return; } Item item = ItemManager.Instance.GetItem(handMaterialId); if (item.itemType != (int)ItemType.Block) { return; } if (Terrain.RayToWorld(screenX, screenY, _playerController.transform.position, distance, out hit, oppoMaskLayer)) { WorldPos pos = Terrain.GetWorldPos(hit, true); if (hit.collider.GetComponentInParent <ChunkObj>() == null) { return; } if (!Terrain.CheckPosCanPlaced(_playerController.transform, pos)) { return; } Block handBlock = new Block((BlockType)item.sceneBlockType, item.sceneBlockExtendId); BlockAttributeCalculator calculator = BlockAttributeCalculatorFactory.GetCalculator(handBlock.BlockType); if (calculator is BAC_ModelBlock) { Vector3 forward = _gameObjectController.transform.forward; float degree = Vector2.Angle(Vector2.right, new Vector2(forward.x, forward.z)); byte extendId = 8; if (degree < 45) { extendId |= 3; } else if (degree > 135) { extendId |= 1; } else if (forward.z > 0) { extendId |= 2; } handBlock = new Block(BlockType.Block_100, extendId); } int decType = HasActionObjectManager.Instance.plantManager.checkIsPlantSeedling(handMaterialId); if (decType != -1) { HasActionObjectManager.Instance.plantManager.buildPlant(new Vector3(pos.x, pos.y, pos.z), (DecorationType)decType); return; } Terrain.SetBlock(pos, handBlock); } }