Renamed CollisionManager

This commit is contained in:
2026-06-18 11:03:56 +02:00
parent a7d1adf175
commit 64e445e8a6
21 changed files with 156 additions and 767 deletions

View File

@@ -9,7 +9,7 @@ namespace Marro.PacManUdon
{
private GameManager gameManager;
private PlayerInput input;
private PelletManager pelletManager;
private CollisionManager collisionManager;
private float defaultSpeed;
private float powerPelletSpeed;
private float speed;
@@ -41,10 +41,10 @@ namespace Marro.PacManUdon
#endregion
public void Initialize(PlayerInput input, Transform startTransform, GameManager gameManager, PelletManager pelletManager)
public void Initialize(PlayerInput input, Transform startTransform, GameManager gameManager, CollisionManager collisionManager)
{
this.gameManager = gameManager;
this.pelletManager = pelletManager;
this.collisionManager = collisionManager;
this.input = input;
animator = GetComponent<Animator>();
renderer = GetComponent<Renderer>();
@@ -131,7 +131,7 @@ namespace Marro.PacManUdon
private Vector2 ProcessNextPosition(Vector2 position, Vector2 nextPosition)
{
if (CrossesTileCenter(position, nextPosition, Direction.Left) // If pacman is moving horizontally, check if he may cross the center of a tile in that axis
&& (!IsHorizontal(targetDirection) || pelletManager.IsWallUpcoming(nextPosition, directionVectors[(int)HorizontalComponent(direction)])))
&& (!IsHorizontal(targetDirection) || collisionManager.IsWallUpcoming(nextPosition, directionVectors[(int)HorizontalComponent(direction)])))
{ // If the target direction is in the other axis or if we're about to run into a wall
nextPosition.x = PositionToGrid(nextPosition).x; // Snap pacman to the center of his current tile in this axis
SetDirection(VerticalComponent(direction));
@@ -139,7 +139,7 @@ namespace Marro.PacManUdon
}
if (CrossesTileCenter(position, nextPosition, Direction.Down) // See comments above but now vertical
&& (!IsVertical(targetDirection) || pelletManager.IsWallUpcoming(nextPosition, directionVectors[(int)VerticalComponent(direction)])))
&& (!IsVertical(targetDirection) || collisionManager.IsWallUpcoming(nextPosition, directionVectors[(int)VerticalComponent(direction)])))
{
nextPosition.y = PositionToGrid(nextPosition).y;
SetDirection(HorizontalComponent(direction));
@@ -148,7 +148,7 @@ namespace Marro.PacManUdon
var inputDirection = input.GetDirection();
if (!inputDirection.Equals(Direction.Zero) && !inputDirection.Equals(targetDirection) // Ignore neutral input or input in our current direction
&& !pelletManager.IsWallUpcoming(nextPosition, directionVectors[(int)inputDirection])) // Check if the requested direction does not have a wall
&& !collisionManager.IsWallUpcoming(nextPosition, directionVectors[(int)inputDirection])) // Check if the requested direction does not have a wall
{
// Move in the requested direction, as well as perpundicular to it to get to the center of the tunnel
if (IsHorizontal(inputDirection))
@@ -182,7 +182,7 @@ namespace Marro.PacManUdon
{
nextValidDirectionIndex += 1;
}
if (!pelletManager.IsWallUpcoming(nextPosition, directionVectors[(int)predefinedPath[nextValidDirectionIndex]]))
if (!collisionManager.IsWallUpcoming(nextPosition, directionVectors[(int)predefinedPath[nextValidDirectionIndex]]))
{
// If we're at a Vector2.zero, we skip applying the direction and only increment.
if (nextValidDirectionIndex == predefinedPathIndex)
@@ -213,7 +213,7 @@ namespace Marro.PacManUdon
private void CheckNewTile(Vector2 position, Vector2 nextPosition)
{
var eatResult = pelletManager.PacManMoveToTile(position, nextPosition);
var eatResult = collisionManager.PacManMoveToTile(position, nextPosition);
if (eatResult == EatResult.Pellet)
{