Exemplo n.º 1
0
        private void RightClickRaycast()
        {
            Ray ray = _mainCamera.ScreenPointToRay(Input.mousePosition);

            Physics.Raycast(ray, out var hit, 100f);
            if (hit.collider == null)
            {
                return;
            }

            GridObject gridObject = hit.collider.GetComponent <GridObject>();

            if (gridObject != null)
            {
                gridObject.OnBreak();
                AudioManager.Instance.PlayDeconstructSound();
            }
        }
Exemplo n.º 2
0
        private void LeftClickRaycast()
        {
            Ray ray = _mainCamera.ScreenPointToRay(Input.mousePosition);

            Physics.Raycast(ray, out var hit, 100f);
            if (hit.collider == null)
            {
                return;
            }

            GridChunk gridChunk = hit.collider.GetComponent <GridChunk>();

            if (gridChunk != null)
            {
                gridChunk.PlaceObject(_gridPlacement, hit.point);
                AudioManager.Instance.PlayBuildSound();
            }
            GridObject gridObject = hit.collider.GetComponent <GridObject>();

            if (gridObject != null)
            {
                gridObject.OnSelect();
            }
        }