示例#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();
                }
            }
        }
示例#2
0
        public BeginMoveState(PlayerStateReferences references, Vector2 transitionToPoint,
                              Func <PlayerController, bool> moveCallback, Vector2 dir) :
            base(references)
        {
            _startPoint        = references.Owner.transform.position;
            _transitionToPoint = transitionToPoint;
            _moveCallback      = moveCallback;

            _dist = (_startPoint - _transitionToPoint).magnitude;

            _tridentAnim = references.Owner.tridentAnimations.GetObject(dir);
            references.Owner.SetFlipX(dir.x > 0);
        }