Example #1
0
        public static bool CanMoveInDirection(this IMovingItem gameObject, Direction direction)
        {
            IMovementChecker mc = gameObject.Properties.Get(GameObjectProperties.MovementChecker);
            var result          = mc.CanMoveForwards(gameObject, direction);

            return(result);
        }
Example #2
0
        public PushStatus CanBePushedOrBounced(IMovingItem toBeMoved, IMovingItem byWhom, Direction direction, bool isBounceBackPossible)
        {
            // if this object is not moveable then the answer's no
            if (toBeMoved.Properties.Get(GameObjectProperties.Solidity) != ObjectSolidity.Moveable)
            {
                return(PushStatus.No);
            }

            // if the moving object cannot move other objects then the answer's no
            // the moving object cannot be a moveable object - moveable objects can't push other moveable objects
            if (!byWhom.Properties.Get(GameObjectProperties.Capability).CanMoveAnother() || byWhom.Properties.Get(GameObjectProperties.Solidity) == ObjectSolidity.Moveable)
            {
                return(PushStatus.No);
            }

            // check if this object can move in the specified direction
            if (CanMove(toBeMoved, direction, isBounceBackPossible))
            {
                return(PushStatus.Yes);
            }

            // if bounceback is not a possibility then the answer's no
            if (byWhom.Properties.Get(GameObjectProperties.Capability) != ObjectCapability.CanPushOrCauseBounceBack || !isBounceBackPossible)
            {
                return(PushStatus.No);
            }

            // this object will be able to bounceback only if the object that is pushing it can move backwards
            IMovementChecker mc = byWhom.Properties.Get(GameObjectProperties.MovementChecker);
            var willBounceBack  = mc.CanBePushedBackDueToBounceBack(byWhom, direction.Reversed());
            var result          = willBounceBack ? PushStatus.Bounce : PushStatus.No;

            return(result);
        }