示例#1
0
        public void OnUpdate(float deltaTime)
        {
            if (!_enabled)
            {
                return;
            }

            if (!_started && Input.GetMouseButtonDown(0))
            {
                if (TryGetPoint(out _startPoint))
                {
                    _started = true;
                }
            }

            else if (_started && Input.GetMouseButtonUp(0))
            {
                if (TryGetPoint(out _endPoint))
                {
                    _started = false;
                    var direction = _startPoint - _endPoint;
                    _arrow.SetParams(Quaternion.FromToRotation(Vector3.left, direction), _player.transform.position, (_endPoint - _startPoint).magnitude);
                    _arrow.gameObject.SetActive(false);
                    CompleteAction(_startPoint, _endPoint);
                }
            }

            else if (_started)
            {
                if (TryGetPoint(out _endPoint))
                {
                    var direction = _startPoint - _endPoint;
                    if (direction.magnitude != 0)
                    {
                        _arrow.gameObject.SetActive(true);
                        _arrow.SetParams(Quaternion.FromToRotation(Vector3.left, direction), _player.transform.position, (_endPoint - _startPoint).magnitude);
                    }
                }
            }
        }