Пример #1
0
        private void GrabActionOnstarted(InputAction.CallbackContext obj)
        {
            if (_puck != null)
            {
                return;
            }

            if (Physics.Raycast(camera.ScreenPointToRay(Mouse.current.position.ReadValue()), out var hit, Mathf.Infinity, LayerMask.GetMask("Puck")))
            {
                var puckGameObject = hit.collider.transform.parent.gameObject;
                _puck = puckGameObject.GetComponent <PuckBehaviour>();

                if (_puck.Side != side)
                {
                    return;
                }

                if (!_puck.Grab(transform))
                {
                    return;
                }

                _lastPositionY = puckGameObject.transform.position.y;
            }
        }
Пример #2
0
        private void GrabActionOncanceled(InputAction.CallbackContext obj)
        {
            if (_puck == null)
            {
                return;
            }

            _puck.Release();
            _puck = null;
        }
        private void OnTriggerEnter2D(Collider2D puckCollider)
        {
            if (_puck != null)
            {
                return;
            }
            if (puckCollider.gameObject.layer != _ignoreLayer)
            {
                return;
            }

            _puck            = puckCollider.gameObject.GetComponent <PuckBehaviour>();
            _puck.Releasing += PuckOnReleasing;
        }
        private void OnTriggerExit2D(Collider2D puckCollider)
        {
            if (_puck == null || _puck.GameObject != puckCollider.gameObject)
            {
                return;
            }

            _puck.Releasing -= PuckOnReleasing;
            _puck            = null;

            var points = polygonCollider.points;

            _launchPosition = _tangentA = _tangentB = points[0] = points[1] = _originalPolygonPoint;

            polygonCollider.SetPath(0, points);
        }