Пример #1
0
        /// <summary>
        /// tap cube
        /// </summary>
        private void OnTapCube()
        {
            Observable.EveryUpdate()
            .Where(_ => EnableRayCast)
            .Where(_ => Input.GetMouseButtonDown(0))
            .Subscribe(_ => {
                var distance = 100;
                var ray      = mainCamera.ScreenPointToRay(Input.mousePosition);
                var hit      = new RaycastHit();
                Debug.DrawRay(ray.origin, ray.direction * distance, Color.red, 2f, false);

                if (Physics.Raycast(ray, out hit, distance))
                {
                    _clickedCube = hit.collider.gameObject.GetComponent <RotateCube>();

                    if (_clickedCube != null)
                    {
                        InputUtil.GetDragAmount();
                        _totalDragAmount        = Vector3.zero;
                        stateAsObservable.Value = State.RotateTargets;
                        _messageSubject.OnNext(Message.CatchCube);
                    }
                    else
                    {
                        Debug.Log("could not catch cube");
                    }
                }
            })
            .AddTo(stateDisposable);
        }
Пример #2
0
        private void OnContinueRotate()
        {
            _rotateAxisScreenHorizontal = Vector3Int.zero;
            _rotateAxisScreenVertical   = Vector3Int.zero;
            _totalDragAmount            = Vector3.zero;

            _rotateCubes.Clear();
            _clickedCube = null;

            stateAsObservable.Value = State.TapCube;
        }