Example #1
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++;
                    }
                }
            }
        }
Example #2
0
        //-----------------------------------------------------------------------------
        // Rolling
        //-----------------------------------------------------------------------------

        // Pushes the roller.
        public void PushRoller(int direction)
        {
            if (((IsVertical && Directions.IsVertical(direction)) || (!IsVertical && Directions.IsHorizontal(direction))) && nextRoller != null)
            {
                nextRoller.PushRoller(direction);
            }

            Graphics.PlayAnimation(TileData.SpriteList[1].Animation);
            Graphics.SubStripIndex = (direction <= 1 ? 0 : 1);

            // Only the main roller should start the pushback.
            if (firstRoller == this)
            {
                returnTimer = 60;
            }

            if (base.Move(direction, 1, GameSettings.TILE_ROLLER_MOVE_SPEED))
            {
                if (firstRoller == this)
                {
                    AudioSystem.PlaySound(GameData.SOUND_BLUE_ROLLER);
                }
            }
        }