Exemplo n.º 1
0
        public MoveState(PlayerStateReferences references, Vector2 transitionToPoint,
                         Func <PlayerController, bool> moveCallback, TridentAnimation tridentAnimation) :
            base(references)
        {
            _startPoint        = references.Owner.transform.position;
            _transitionToPoint = transitionToPoint;
            _moveCallback      = moveCallback;
            _tridentAnimation  = tridentAnimation;

            _dist = (_startPoint - _transitionToPoint).magnitude;
            List <RaycastHit2D> results = new List <RaycastHit2D>();

            Physics2D.Raycast(_startPoint, (transitionToPoint - _startPoint).normalized, new ContactFilter2D
            {
                layerMask    = references.Owner.settings.bubbleMask,
                useLayerMask = true
            }, results, _dist);
            foreach (var hit in results)
            {
                var bubbleComponent = hit.collider.GetComponent <Bubble>();
                if (bubbleComponent != null)
                {
                    bubbleComponent.Collect();
                    Owner.AddKey();
                }
            }
        }