protected virtual void Finish(PositionComponent playerPos) { if (direction == Direction.Right) { playerPos.SetX(OffsetDist()); playerPos.Offset(0, NextScreenY); } else if (direction == Direction.Left) { playerPos.SetX(nextWidth - OffsetDist()); playerPos.Offset(0, NextScreenY); } else if (direction == Direction.Down) { playerPos.SetY(OffsetDist()); playerPos.Offset(NextScreenX, 0); } else if (direction == Direction.Up) { playerPos.SetY(nextHeight - OffsetDist()); playerPos.Offset(NextScreenX, 0); } if (ScrollDone != null) { ScrollDone(this); } }
private void EnforcePlayerBounds() { // if the player is not colliding, they'll be allowed to pass through the walls (e.g. teleporting) if ((player.GetComponent <CollisionComponent>()).Enabled) { float leftBound = (float)Const.PlayerScrollTrigger; float rightBound = Screen.PixelWidth - Const.PlayerScrollTrigger; if (isAutoscrolling) { leftBound += OffsetX; rightBound = OffsetX + Game.CurrentGame.PixelsAcross; } // now if we aren't scrolling, hold the player at the screen borders if (playerPos.X >= rightBound) { playerPos.SetX(rightBound); } else if (playerPos.X <= leftBound) { playerPos.SetX(leftBound); } if (playerPos.Y > Screen.PixelHeight - Const.PlayerScrollTrigger) { if (!container.IsGravityFlipped && playerPos.Y > Game.CurrentGame.PixelsDown + 32) { // bottomless pit death! playerPos.Parent.Die(); } } else if (playerPos.Y < Const.PlayerScrollTrigger) { if (container.IsGravityFlipped && playerPos.Y < -32) { playerPos.Parent.Die(); } } } }