Beispiel #1
0
        // Makes sure all rollers in the group can be pushed in the same direction.
        private bool CanPushRoller(int direction)
        {
            if (IsMoving)
            {
                return(false);
            }

            // Make sure were not pushing out of bounds.
            Point2I newLocation = Location + Directions.ToPoint(direction);

            if (!RoomControl.IsTileInBounds(newLocation))
            {
                return(false);
            }

            // Make sure there are no obstructions.
            int newLayer;

            if (IsMoveObstructed(direction, out newLayer))
            {
                return(false);
            }

            if ((IsVertical && Directions.IsVertical(direction)) || (!IsVertical && Directions.IsHorizontal(direction)))
            {
                return(nextRoller != null ? nextRoller.CanPushRoller(direction) : true);
            }
            return(false);
        }
Beispiel #2
0
        public override void OnPushing(int direction)
        {
            int currentPosition = (IsVertical ? Location.Y : Location.X);

            if (!IsMoving && RoomControl.GameControl.Inventory.IsWeaponButtonDown(RoomControl.GameControl.Inventory.GetItem("item_bracelet")))
            {
                bool pushableDirection = false;

                switch (direction)
                {
                case Directions.Right:  pushableDirection = !IsVertical && currentPosition >= startPosition; break;

                case Directions.Up:             pushableDirection = IsVertical && currentPosition <= startPosition; break;

                case Directions.Left:   pushableDirection = !IsVertical && currentPosition <= startPosition; break;

                case Directions.Down:   pushableDirection = IsVertical && currentPosition >= startPosition; break;
                }

                if (pushableDirection)
                {
                    firstRoller.returnTimer = 60;
                    pushed = true;
                    if (pushTimer == PushDelay)
                    {
                        if (firstRoller.CanPushRoller(direction))
                        {
                            firstRoller.PushRoller(direction);
                        }
                    }
                    else
                    {
                        pushTimer++;
                    }
                }
            }
        }