Maze 32x32

This commit is contained in:
2026-06-17 12:12:17 +02:00
parent a24f237bd5
commit 8684f1ecc7
12 changed files with 1747 additions and 1210 deletions

View File

@@ -203,6 +203,16 @@ namespace Marro.PacManUdon
Debug.LogError($"{gameObject} Just jumped by distance {distance}! position: {position}, nextPosition: {nextPosition}, direction: {direction}, offGrid: {offGrid}, ghostState: {ghostState}");
}
if (CrossesTileBorder(position, nextPosition, direction))
{
var inTunnel = pelletManager.IsInTunnel(nextPosition);
if (inTunnel != this.inTunnel)
{
this.inTunnel = inTunnel;
UpdateSpeed();
}
}
return nextPosition;
}
@@ -245,12 +255,18 @@ namespace Marro.PacManUdon
var gridPosition = PositionToGrid(position);
var availableDirections = pelletManager.GetAvailableDirections(position);
if (availableDirections == 0)
if ((availableDirections & (int)PacManCollisionInfoType.NoTurn) != 0 )
{
return;
}
availableDirections &= GetIllegalCardinalDirectionMask(direction); // Not allowed to turn around
availableDirections &= ~(int)GetInverseDirection(direction); // Not allowed to turn around
if (!isScared && (availableDirections & (int)PacManCollisionInfoType.HorizontalOnly) != 0)
{
Debug.Log($"{name} Horizontal only!");
availableDirections &= ~0b0011;
}
target = GetGridTarget(gridPosition);
var newDirection = GetGridDirectionToTargetGreedy(availableDirections, gridPosition, target);
@@ -264,23 +280,6 @@ namespace Marro.PacManUdon
SetDirection(newDirection);
}
private int GetIllegalCardinalDirectionMask(Direction direction)
{
switch (direction)
{
case Direction.Up:
return 0b1101;
case Direction.Down:
return 0b1110;
case Direction.Left:
return 0b0111;
case Direction.Right:
return 0b1011;
default:
return 0b1111;
}
}
private Vector2 ProcessPredefinedPath(Vector2 position, Vector2 nextPosition)
{
if (CrossesTileCenter(position, nextPosition, direction))
@@ -456,6 +455,7 @@ namespace Marro.PacManUdon
{
Direction bestDirection = Direction.Zero;
float bestDistance = float.MaxValue;
foreach (var direction in horizontalOnly ? horizontalDirections : cardinalDirections)
{
if (((int)direction & availableDirections) == 0)
@@ -860,26 +860,6 @@ namespace Marro.PacManUdon
ghostManager.CapturedPacMan();
}
}
else if (other.gameObject.GetComponent<GhostHorizontalOnlyIndicator>())
{
horizontalOnly = true;
}
else if (other.gameObject.GetComponent<GhostTunnelIndicator>())
{
SetInTunnel(true);
}
}
void OnTriggerExit(Collider other)
{
if (other.gameObject.GetComponent<GhostHorizontalOnlyIndicator>())
{
horizontalOnly = false;
}
else if (other.gameObject.GetComponent<GhostTunnelIndicator>())
{
SetInTunnel(false);
}
}
}
}