More use of Direction
This commit is contained in:
@@ -83,7 +83,7 @@ namespace Marro.PacManUdon
|
||||
private bool specialLook;
|
||||
|
||||
private bool followingPredefinedPath;
|
||||
private Vector2[] predefinedPath;
|
||||
private Direction[] predefinedPath;
|
||||
private int predefinedPathIndex;
|
||||
|
||||
public bool IsScared => isScared;
|
||||
@@ -170,7 +170,7 @@ namespace Marro.PacManUdon
|
||||
private Vector2 ProcessNextPosition(Vector2 position, Vector2 nextPosition)
|
||||
{
|
||||
if (turnAroundSoon && ghostState == PacManGhostState.Normal
|
||||
&& CrossesTileBorder(position, nextPosition, direction))
|
||||
&& CrossesTileCenter(position, nextPosition, direction))
|
||||
{
|
||||
var newDirection = GetInverseDirection(direction);
|
||||
Debug.Log($"{gameObject} turned around from direction {direction} to {newDirection}");
|
||||
@@ -268,11 +268,11 @@ namespace Marro.PacManUdon
|
||||
{
|
||||
// Find the next valid direction which isn't Vector2.zero
|
||||
int nextValidDirectionIndex = predefinedPathIndex;
|
||||
while (predefinedPath[nextValidDirectionIndex] == Vector2.zero)
|
||||
while (predefinedPath[nextValidDirectionIndex] == Direction.Zero)
|
||||
{
|
||||
nextValidDirectionIndex += 1;
|
||||
}
|
||||
if (!CheckCollisionInDirection(transform, nextPosition, predefinedPath[nextValidDirectionIndex]))
|
||||
if (!pelletManager.IsWallUpcoming(nextPosition, directionVectors[(int)predefinedPath[nextValidDirectionIndex]]))
|
||||
{
|
||||
// If we're at a Vector2.zero, we skip applying the direction and only increment.
|
||||
if (nextValidDirectionIndex == predefinedPathIndex)
|
||||
@@ -289,7 +289,7 @@ namespace Marro.PacManUdon
|
||||
followingPredefinedPath = false;
|
||||
break;
|
||||
}
|
||||
} while (predefinedPath[nextValidDirectionIndex] == Vector2.zero);
|
||||
} while (predefinedPath[nextValidDirectionIndex] == Direction.Zero);
|
||||
}
|
||||
|
||||
// ghostManager.gameStateManager.statusDisplay.SetDebugText(1, predefinedPathIndex.ToString());
|
||||
@@ -735,7 +735,7 @@ namespace Marro.PacManUdon
|
||||
this.kinematic = kinematic;
|
||||
}
|
||||
|
||||
public void SetPredefinedPath(Vector2[] predefinedPath)
|
||||
public void SetPredefinedPath(Direction[] predefinedPath)
|
||||
{
|
||||
this.predefinedPath = predefinedPath;
|
||||
followingPredefinedPath = true;
|
||||
|
||||
Reference in New Issue
Block a user