More use of Direction

This commit is contained in:
2026-06-15 10:58:16 +02:00
parent 73b3194c51
commit f1281280fa
6 changed files with 450 additions and 443 deletions

View File

@@ -1923,59 +1923,23 @@ MonoBehaviour:
Entry: 1 Entry: 1
Data: predefinedPath Data: predefinedPath
- Name: <UserType>k__BackingField - Name: <UserType>k__BackingField
Entry: 9
Data: 11
- Name: <SystemType>k__BackingField
Entry: 9
Data: 11
- Name: <SyncMode>k__BackingField
Entry: 7 Entry: 7
Data: System.Nullable`1[[UdonSharp.UdonSyncMode, UdonSharp.Runtime]], mscorlib Data: 98|System.RuntimeType, mscorlib
- Name: - Name:
Entry: 6
Data:
- Name:
Entry: 8
Data:
- Name: <IsSerialized>k__BackingField
Entry: 5
Data: false
- Name: _fieldAttributes
Entry: 7
Data: 98|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib
- Name:
Entry: 12
Data: 0
- Name:
Entry: 13
Data:
- Name:
Entry: 8
Data:
- Name:
Entry: 8
Data:
- Name:
Entry: 8
Data:
- Name:
Entry: 7
Data:
- Name: $k
Entry: 1 Entry: 1
Data: predefinedPathIndex Data: Marro.PacManUdon.Direction[], Assembly-CSharp
- Name: $v - Name:
Entry: 7 Entry: 8
Data: 99|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor Data:
- Name: <Name>k__BackingField
Entry: 1
Data: predefinedPathIndex
- Name: <UserType>k__BackingField
Entry: 9
Data: 8
- Name: <SystemType>k__BackingField - Name: <SystemType>k__BackingField
Entry: 9 Entry: 7
Data: 8 Data: 99|System.RuntimeType, mscorlib
- Name:
Entry: 1
Data: System.Int32[], mscorlib
- Name:
Entry: 8
Data:
- Name: <SyncMode>k__BackingField - Name: <SyncMode>k__BackingField
Entry: 7 Entry: 7
Data: System.Nullable`1[[UdonSharp.UdonSyncMode, UdonSharp.Runtime]], mscorlib Data: System.Nullable`1[[UdonSharp.UdonSyncMode, UdonSharp.Runtime]], mscorlib
@@ -2012,13 +1976,13 @@ MonoBehaviour:
Data: Data:
- Name: $k - Name: $k
Entry: 1 Entry: 1
Data: <Index>k__BackingField Data: predefinedPathIndex
- Name: $v - Name: $v
Entry: 7 Entry: 7
Data: 101|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor Data: 101|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
- Name: <Name>k__BackingField - Name: <Name>k__BackingField
Entry: 1 Entry: 1
Data: <Index>k__BackingField Data: predefinedPathIndex
- Name: <UserType>k__BackingField - Name: <UserType>k__BackingField
Entry: 9 Entry: 9
Data: 8 Data: 8
@@ -2061,31 +2025,68 @@ MonoBehaviour:
Data: Data:
- Name: $k - Name: $k
Entry: 1 Entry: 1
Data: cardinalDirections Data: <Index>k__BackingField
- Name: $v - Name: $v
Entry: 7 Entry: 7
Data: 103|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor Data: 103|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
- Name: <Name>k__BackingField
Entry: 1
Data: <Index>k__BackingField
- Name: <UserType>k__BackingField
Entry: 9
Data: 8
- Name: <SystemType>k__BackingField
Entry: 9
Data: 8
- Name: <SyncMode>k__BackingField
Entry: 7
Data: System.Nullable`1[[UdonSharp.UdonSyncMode, UdonSharp.Runtime]], mscorlib
- Name:
Entry: 6
Data:
- Name:
Entry: 8
Data:
- Name: <IsSerialized>k__BackingField
Entry: 5
Data: false
- Name: _fieldAttributes
Entry: 7
Data: 104|System.Collections.Generic.List`1[[System.Attribute, mscorlib]],
mscorlib
- Name:
Entry: 12
Data: 0
- Name:
Entry: 13
Data:
- Name:
Entry: 8
Data:
- Name:
Entry: 8
Data:
- Name:
Entry: 8
Data:
- Name:
Entry: 7
Data:
- Name: $k
Entry: 1
Data: cardinalDirections
- Name: $v
Entry: 7
Data: 105|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
- Name: <Name>k__BackingField - Name: <Name>k__BackingField
Entry: 1 Entry: 1
Data: cardinalDirections Data: cardinalDirections
- Name: <UserType>k__BackingField - Name: <UserType>k__BackingField
Entry: 7 Entry: 9
Data: 104|System.RuntimeType, mscorlib Data: 98
- Name:
Entry: 1
Data: Marro.PacManUdon.Direction[], Assembly-CSharp
- Name:
Entry: 8
Data:
- Name: <SystemType>k__BackingField - Name: <SystemType>k__BackingField
Entry: 7 Entry: 9
Data: 105|System.RuntimeType, mscorlib Data: 99
- Name:
Entry: 1
Data: System.Int32[], mscorlib
- Name:
Entry: 8
Data:
- Name: <SyncMode>k__BackingField - Name: <SyncMode>k__BackingField
Entry: 7 Entry: 7
Data: System.Nullable`1[[UdonSharp.UdonSyncMode, UdonSharp.Runtime]], mscorlib Data: System.Nullable`1[[UdonSharp.UdonSyncMode, UdonSharp.Runtime]], mscorlib

View File

@@ -83,7 +83,7 @@ namespace Marro.PacManUdon
private bool specialLook; private bool specialLook;
private bool followingPredefinedPath; private bool followingPredefinedPath;
private Vector2[] predefinedPath; private Direction[] predefinedPath;
private int predefinedPathIndex; private int predefinedPathIndex;
public bool IsScared => isScared; public bool IsScared => isScared;
@@ -170,7 +170,7 @@ namespace Marro.PacManUdon
private Vector2 ProcessNextPosition(Vector2 position, Vector2 nextPosition) private Vector2 ProcessNextPosition(Vector2 position, Vector2 nextPosition)
{ {
if (turnAroundSoon && ghostState == PacManGhostState.Normal if (turnAroundSoon && ghostState == PacManGhostState.Normal
&& CrossesTileBorder(position, nextPosition, direction)) && CrossesTileCenter(position, nextPosition, direction))
{ {
var newDirection = GetInverseDirection(direction); var newDirection = GetInverseDirection(direction);
Debug.Log($"{gameObject} turned around from direction {direction} to {newDirection}"); 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 // Find the next valid direction which isn't Vector2.zero
int nextValidDirectionIndex = predefinedPathIndex; int nextValidDirectionIndex = predefinedPathIndex;
while (predefinedPath[nextValidDirectionIndex] == Vector2.zero) while (predefinedPath[nextValidDirectionIndex] == Direction.Zero)
{ {
nextValidDirectionIndex += 1; 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 we're at a Vector2.zero, we skip applying the direction and only increment.
if (nextValidDirectionIndex == predefinedPathIndex) if (nextValidDirectionIndex == predefinedPathIndex)
@@ -289,7 +289,7 @@ namespace Marro.PacManUdon
followingPredefinedPath = false; followingPredefinedPath = false;
break; break;
} }
} while (predefinedPath[nextValidDirectionIndex] == Vector2.zero); } while (predefinedPath[nextValidDirectionIndex] == Direction.Zero);
} }
// ghostManager.gameStateManager.statusDisplay.SetDebugText(1, predefinedPathIndex.ToString()); // ghostManager.gameStateManager.statusDisplay.SetDebugText(1, predefinedPathIndex.ToString());
@@ -735,7 +735,7 @@ namespace Marro.PacManUdon
this.kinematic = kinematic; this.kinematic = kinematic;
} }
public void SetPredefinedPath(Vector2[] predefinedPath) public void SetPredefinedPath(Direction[] predefinedPath)
{ {
this.predefinedPath = predefinedPath; this.predefinedPath = predefinedPath;
followingPredefinedPath = true; followingPredefinedPath = true;

View File

@@ -957,59 +957,23 @@ MonoBehaviour:
Entry: 1 Entry: 1
Data: predefinedPath Data: predefinedPath
- Name: <UserType>k__BackingField - Name: <UserType>k__BackingField
Entry: 9
Data: 11
- Name: <SystemType>k__BackingField
Entry: 9
Data: 11
- Name: <SyncMode>k__BackingField
Entry: 7 Entry: 7
Data: System.Nullable`1[[UdonSharp.UdonSyncMode, UdonSharp.Runtime]], mscorlib Data: 51|System.RuntimeType, mscorlib
- Name: - Name:
Entry: 6
Data:
- Name:
Entry: 8
Data:
- Name: <IsSerialized>k__BackingField
Entry: 5
Data: false
- Name: _fieldAttributes
Entry: 7
Data: 51|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib
- Name:
Entry: 12
Data: 0
- Name:
Entry: 13
Data:
- Name:
Entry: 8
Data:
- Name:
Entry: 8
Data:
- Name:
Entry: 8
Data:
- Name:
Entry: 7
Data:
- Name: $k
Entry: 1 Entry: 1
Data: predefinedPathIndex Data: Marro.PacManUdon.Direction[], Assembly-CSharp
- Name: $v - Name:
Entry: 7 Entry: 8
Data: 52|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor Data:
- Name: <Name>k__BackingField
Entry: 1
Data: predefinedPathIndex
- Name: <UserType>k__BackingField
Entry: 9
Data: 8
- Name: <SystemType>k__BackingField - Name: <SystemType>k__BackingField
Entry: 9 Entry: 7
Data: 8 Data: 52|System.RuntimeType, mscorlib
- Name:
Entry: 1
Data: System.Int32[], mscorlib
- Name:
Entry: 8
Data:
- Name: <SyncMode>k__BackingField - Name: <SyncMode>k__BackingField
Entry: 7 Entry: 7
Data: System.Nullable`1[[UdonSharp.UdonSyncMode, UdonSharp.Runtime]], mscorlib Data: System.Nullable`1[[UdonSharp.UdonSyncMode, UdonSharp.Runtime]], mscorlib
@@ -1045,25 +1009,67 @@ MonoBehaviour:
Data: Data:
- Name: $k - Name: $k
Entry: 1 Entry: 1
Data: targetDirection Data: predefinedPathIndex
- Name: $v - Name: $v
Entry: 7 Entry: 7
Data: 54|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor Data: 54|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
- Name: <Name>k__BackingField
Entry: 1
Data: predefinedPathIndex
- Name: <UserType>k__BackingField
Entry: 9
Data: 8
- Name: <SystemType>k__BackingField
Entry: 9
Data: 8
- Name: <SyncMode>k__BackingField
Entry: 7
Data: System.Nullable`1[[UdonSharp.UdonSyncMode, UdonSharp.Runtime]], mscorlib
- Name:
Entry: 6
Data:
- Name:
Entry: 8
Data:
- Name: <IsSerialized>k__BackingField
Entry: 5
Data: false
- Name: _fieldAttributes
Entry: 7
Data: 55|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib
- Name:
Entry: 12
Data: 0
- Name:
Entry: 13
Data:
- Name:
Entry: 8
Data:
- Name:
Entry: 8
Data:
- Name:
Entry: 8
Data:
- Name:
Entry: 7
Data:
- Name: $k
Entry: 1
Data: targetDirection
- Name: $v
Entry: 7
Data: 56|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
- Name: <Name>k__BackingField - Name: <Name>k__BackingField
Entry: 1 Entry: 1
Data: targetDirection Data: targetDirection
- Name: <UserType>k__BackingField - Name: <UserType>k__BackingField
Entry: 7 Entry: 9
Data: 55|System.RuntimeType, mscorlib Data: 7
- Name:
Entry: 1
Data: UnityEngine.Vector2, UnityEngine.CoreModule
- Name:
Entry: 8
Data:
- Name: <SystemType>k__BackingField - Name: <SystemType>k__BackingField
Entry: 9 Entry: 9
Data: 55 Data: 8
- Name: <SyncMode>k__BackingField - Name: <SyncMode>k__BackingField
Entry: 7 Entry: 7
Data: System.Nullable`1[[UdonSharp.UdonSyncMode, UdonSharp.Runtime]], mscorlib Data: System.Nullable`1[[UdonSharp.UdonSyncMode, UdonSharp.Runtime]], mscorlib
@@ -1078,7 +1084,7 @@ MonoBehaviour:
Data: false Data: false
- Name: _fieldAttributes - Name: _fieldAttributes
Entry: 7 Entry: 7
Data: 56|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib Data: 57|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib
- Name: - Name:
Entry: 12 Entry: 12
Data: 0 Data: 0
@@ -1102,7 +1108,7 @@ MonoBehaviour:
Data: freezeSeconds Data: freezeSeconds
- Name: $v - Name: $v
Entry: 7 Entry: 7
Data: 57|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor Data: 58|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
- Name: <Name>k__BackingField - Name: <Name>k__BackingField
Entry: 1 Entry: 1
Data: freezeSeconds Data: freezeSeconds
@@ -1126,7 +1132,7 @@ MonoBehaviour:
Data: false Data: false
- Name: _fieldAttributes - Name: _fieldAttributes
Entry: 7 Entry: 7
Data: 58|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib Data: 59|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib
- Name: - Name:
Entry: 12 Entry: 12
Data: 0 Data: 0
@@ -1150,7 +1156,7 @@ MonoBehaviour:
Data: frozen Data: frozen
- Name: $v - Name: $v
Entry: 7 Entry: 7
Data: 59|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor Data: 60|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
- Name: <Name>k__BackingField - Name: <Name>k__BackingField
Entry: 1 Entry: 1
Data: frozen Data: frozen
@@ -1174,7 +1180,7 @@ MonoBehaviour:
Data: false Data: false
- Name: _fieldAttributes - Name: _fieldAttributes
Entry: 7 Entry: 7
Data: 60|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib Data: 61|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib
- Name: - Name:
Entry: 12 Entry: 12
Data: 0 Data: 0

View File

@@ -22,10 +22,10 @@ namespace Marro.PacManUdon
private bool kinematic; private bool kinematic;
private bool followingPredefinedPath; private bool followingPredefinedPath;
private Vector2[] predefinedPath; private Direction[] predefinedPath;
private int predefinedPathIndex; private int predefinedPathIndex;
private Vector2 targetDirection; private Direction targetDirection;
private float freezeSeconds; private float freezeSeconds;
private bool frozen; private bool frozen;
@@ -35,8 +35,8 @@ namespace Marro.PacManUdon
private const float AnimatorDirectionNone = 0f; private const float AnimatorDirectionNone = 0f;
private const float AnimatorDirectionRight = 0.25f; private const float AnimatorDirectionRight = 0.25f;
private const float AnimatorDirectionLeft = 0.50f; private const float AnimatorDirectionLeft = 0.50f;
private const float AnimatorDirectionUp = 0.75f; private const float AnimatorDirectionDown = 0.75f;
private const float AnimatorDirectionDown = 1f; private const float AnimatorDirectionUp = 1f;
private const float AnimatorDirectionRightBig = 1.25f; private const float AnimatorDirectionRightBig = 1.25f;
#endregion #endregion
@@ -60,7 +60,7 @@ namespace Marro.PacManUdon
{ {
transform.SetLocalPositionAndRotation(startPosition, startRotation); transform.SetLocalPositionAndRotation(startPosition, startRotation);
direction = Direction.Left; direction = Direction.Left;
targetDirection = Vector2.left; targetDirection = Direction.Left;
speed = defaultSpeed; speed = defaultSpeed;
kinematic = false; kinematic = false;
followingPredefinedPath = false; followingPredefinedPath = false;
@@ -126,7 +126,7 @@ namespace Marro.PacManUdon
private Vector2 ProcessNextPosition(Vector2 position, Vector2 nextPosition) 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 if (CrossesTileCenter(position, nextPosition, Direction.Left) // If pacman is moving horizontally, check if he may cross the center of a tile in that axis
&& (targetDirection.x == 0 || pelletManager.IsWallUpcoming(nextPosition, directionVectors[(int)HorizontalComponent(direction)]))) && (!IsHorizontal(targetDirection) || pelletManager.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 { // 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 nextPosition.x = PositionToGrid(nextPosition).x; // Snap pacman to the center of his current tile in this axis
SetDirection(VerticalComponent(direction)); SetDirection(VerticalComponent(direction));
@@ -134,7 +134,7 @@ namespace Marro.PacManUdon
} }
if (CrossesTileCenter(position, nextPosition, Direction.Down) // See comments above but now vertical if (CrossesTileCenter(position, nextPosition, Direction.Down) // See comments above but now vertical
&& (targetDirection.y == 0 || pelletManager.IsWallUpcoming(nextPosition, directionVectors[(int)VerticalComponent(direction)]))) && (!IsVertical(targetDirection) || pelletManager.IsWallUpcoming(nextPosition, directionVectors[(int)VerticalComponent(direction)])))
{ {
nextPosition.y = PositionToGrid(nextPosition).y; nextPosition.y = PositionToGrid(nextPosition).y;
SetDirection(HorizontalComponent(direction)); SetDirection(HorizontalComponent(direction));
@@ -155,7 +155,7 @@ namespace Marro.PacManUdon
{ {
SetDirection(inputDirection + new Vector2(PositionToGrid(nextPosition).x - nextPosition.x, 0).normalized); SetDirection(inputDirection + new Vector2(PositionToGrid(nextPosition).x - nextPosition.x, 0).normalized);
} }
SetTargetDirection(inputDirection); // This is the direction most logic should assume pacman is moving, the actual direction may be different due to cornering SetTargetDirection(VectorToDirection(inputDirection)); // This is the direction most logic should assume pacman is moving, the actual direction may be different due to cornering
if (!followingPredefinedPath) if (!followingPredefinedPath)
{ {
@@ -172,11 +172,11 @@ namespace Marro.PacManUdon
{ {
// Find the next valid direction which isn't Vector2.zero // Find the next valid direction which isn't Vector2.zero
int nextValidDirectionIndex = predefinedPathIndex; int nextValidDirectionIndex = predefinedPathIndex;
while (predefinedPath[nextValidDirectionIndex] == Vector2.zero) while (predefinedPath[nextValidDirectionIndex] == Direction.Zero)
{ {
nextValidDirectionIndex += 1; nextValidDirectionIndex += 1;
} }
if (!CheckCollisionInDirection(transform, nextPosition, predefinedPath[nextValidDirectionIndex])) if (!CheckCollisionInDirection(transform, nextPosition, directionVectors[(int)predefinedPath[nextValidDirectionIndex]]))
{ {
// If we're at a Vector2.zero, we skip applying the direction and only increment. // If we're at a Vector2.zero, we skip applying the direction and only increment.
if (nextValidDirectionIndex == predefinedPathIndex) if (nextValidDirectionIndex == predefinedPathIndex)
@@ -194,7 +194,7 @@ namespace Marro.PacManUdon
followingPredefinedPath = false; followingPredefinedPath = false;
break; break;
} }
} while (predefinedPath[nextValidDirectionIndex] == Vector2.zero); } while (predefinedPath[nextValidDirectionIndex] == Direction.Zero);
} }
// gameStateManager.statusDisplay.SetDebugText(1, predefinedPathIndex.ToString()); // gameStateManager.statusDisplay.SetDebugText(1, predefinedPathIndex.ToString());
@@ -226,22 +226,22 @@ namespace Marro.PacManUdon
else else
{ {
animator.speed = 1; animator.speed = 1;
if (targetDirection.Equals(Vector2.right)) if (targetDirection.Equals(Direction.Right))
{ {
animator.SetFloat(AnimatorKeyDirection, AnimatorDirectionRight); animator.SetFloat(AnimatorKeyDirection, AnimatorDirectionRight);
} }
else if (targetDirection.Equals(Vector2.left)) else if (targetDirection.Equals(Direction.Left))
{ {
animator.SetFloat(AnimatorKeyDirection, AnimatorDirectionLeft); animator.SetFloat(AnimatorKeyDirection, AnimatorDirectionLeft);
} }
else if (targetDirection.Equals(Vector2.up)) else if (targetDirection.Equals(Direction.Down))
{
animator.SetFloat(AnimatorKeyDirection, AnimatorDirectionUp);
}
else if (targetDirection.Equals(Vector2.down))
{ {
animator.SetFloat(AnimatorKeyDirection, AnimatorDirectionDown); animator.SetFloat(AnimatorKeyDirection, AnimatorDirectionDown);
} }
else if (targetDirection.Equals(Direction.Up))
{
animator.SetFloat(AnimatorKeyDirection, AnimatorDirectionUp);
}
} }
} }
@@ -297,7 +297,7 @@ namespace Marro.PacManUdon
this.kinematic = kinematic; this.kinematic = kinematic;
} }
public void SetPredefinedPath(Vector2[] predefinedPath) public void SetPredefinedPath(Direction[] predefinedPath)
{ {
this.predefinedPath = predefinedPath; this.predefinedPath = predefinedPath;
followingPredefinedPath = true; followingPredefinedPath = true;
@@ -314,7 +314,7 @@ namespace Marro.PacManUdon
renderer.enabled = visible; renderer.enabled = visible;
} }
public void SetTargetDirection(Vector2 targetDirection) public void SetTargetDirection(Direction targetDirection)
{ {
this.targetDirection = targetDirection; this.targetDirection = targetDirection;
UpdateAnimator(); UpdateAnimator();
@@ -352,12 +352,12 @@ namespace Marro.PacManUdon
if (kinematic || frozen || !enabled) if (kinematic || frozen || !enabled)
{ {
index += 8; index += 1;
base.PadSyncedData(data, ref index, eventType); base.PadSyncedData(data, ref index, eventType);
return; return;
} }
data.Append(targetDirection, ref index); data.AppendAsByte((int)targetDirection, ref index);
base.CollectSyncedData(data, ref index, eventType); base.CollectSyncedData(data, ref index, eventType);
} }
@@ -371,12 +371,12 @@ namespace Marro.PacManUdon
if (kinematic || frozen || !enabled) if (kinematic || frozen || !enabled)
{ {
index += 8; index += 1;
base.ConsumeSyncedData(data, ref index, eventType); base.ConsumeSyncedData(data, ref index, eventType);
return true; return true;
} }
SetTargetDirection(data.ReadVector2(ref index)); SetTargetDirection((Direction)data.ReadByte(ref index));
return base.WriteSyncedData(data, ref index, eventType); return base.WriteSyncedData(data, ref index, eventType);
} }

View File

@@ -20,304 +20,304 @@ namespace Marro.PacManUdon
break; break;
case 2: case 2:
// Setup ghosts // Setup ghosts
ghostManager.Ghosts[0].SetPredefinedPath(new Vector2[]{ // Blinky ghostManager.Ghosts[0].SetPredefinedPath(new Direction[]{ // Blinky
Vector2.down, Direction.Up,
Vector2.left, Direction.Left,
Vector2.up, Direction.Down,
Vector2.right, Direction.Right,
Vector2.zero, Direction.Zero,
Vector2.zero, Direction.Zero,
Vector2.up, Direction.Down,
Vector2.right, Direction.Right,
Vector2.down, Direction.Up,
Vector2.zero, Direction.Zero,
Vector2.right, Direction.Right,
Vector2.up, Direction.Down,
Vector2.left, Direction.Left,
Vector2.down, Direction.Up,
Vector2.right, Direction.Right,
Vector2.up, Direction.Down,
Vector2.zero, Direction.Zero,
Vector2.left, Direction.Left,
Vector2.down, Direction.Up,
Vector2.zero, Direction.Zero,
Vector2.left, Direction.Left,
Vector2.down, Direction.Up,
Vector2.right, Direction.Right,
// Goes through tunnel // Goes through tunnel
Vector2.zero, Direction.Zero,
Vector2.up, Direction.Down,
Vector2.left, Direction.Left,
Vector2.down, Direction.Up,
Vector2.right, Direction.Right,
Vector2.down, Direction.Up,
Vector2.right, Direction.Right,
Vector2.down, Direction.Up,
Vector2.right, Direction.Right,
Vector2.up, Direction.Down,
Vector2.right, Direction.Right,
Vector2.up, Direction.Down,
Vector2.left, Direction.Left,
Vector2.zero, Direction.Zero,
Vector2.down, Direction.Up,
Vector2.left, Direction.Left,
Vector2.zero, Direction.Zero,
Vector2.up, Direction.Down,
Vector2.left, Direction.Left,
// Gets eaten // Gets eaten
Vector2.zero, Direction.Zero,
Vector2.up, Direction.Down,
Vector2.right, Direction.Right,
Vector2.up, Direction.Down,
Vector2.right, Direction.Right,
Vector2.down, Direction.Up,
Vector2.right, Direction.Right,
Vector2.down, Direction.Up,
Vector2.left, Direction.Left,
Vector2.down, Direction.Up,
Vector2.left, Direction.Left,
Vector2.down, Direction.Up,
Vector2.right, Direction.Right,
Vector2.down, Direction.Up,
Vector2.left, Direction.Left,
}); });
ghostManager.Ghosts[1].SetPredefinedPath(new Vector2[]{ // Pinky ghostManager.Ghosts[1].SetPredefinedPath(new Direction[]{ // Pinky
Vector2.down, Direction.Up,
Vector2.left, Direction.Left,
Vector2.up, Direction.Down,
Vector2.zero, Direction.Zero,
Vector2.zero, Direction.Zero,
Vector2.left, Direction.Left,
Vector2.down, Direction.Up,
Vector2.right, Direction.Right,
// Pellet starts // Pellet starts
Vector2.up, Direction.Down,
Vector2.right, Direction.Right,
Vector2.down, Direction.Up,
Vector2.left, Direction.Left,
Vector2.up, Direction.Down,
Vector2.right, Direction.Right,
// Pellet ends // Pellet ends
Vector2.zero, Direction.Zero,
Vector2.down, Direction.Up,
// Pellet starts // Pellet starts
Vector2.left, Direction.Left,
Vector2.down, Direction.Up,
Vector2.zero, Direction.Zero,
Vector2.left, Direction.Left,
// Caught // Caught
Vector2.up, Direction.Down,
Vector2.right, Direction.Right,
Vector2.zero, Direction.Zero,
Vector2.down, Direction.Up,
Vector2.right, Direction.Right,
Vector2.down, Direction.Up,
Vector2.right, Direction.Right,
// Home // Home
Vector2.down, Direction.Up,
Vector2.left, Direction.Left,
Vector2.up, Direction.Down,
Vector2.right, Direction.Right,
Vector2.down, Direction.Up,
Vector2.zero, Direction.Zero,
Vector2.right, Direction.Right,
Vector2.down, Direction.Up,
Vector2.right, Direction.Right,
Vector2.up, Direction.Down,
Vector2.right, Direction.Right,
Vector2.up, Direction.Down,
Vector2.left, Direction.Left,
Vector2.zero, Direction.Zero,
Vector2.down, Direction.Up,
Vector2.left, Direction.Left,
// Power pellet active // Power pellet active
Vector2.up, Direction.Down,
Vector2.right, Direction.Right,
Vector2.up, Direction.Down,
Vector2.left, Direction.Left,
Vector2.up, Direction.Down,
Vector2.left, Direction.Left,
Vector2.down, Direction.Up,
Vector2.right, Direction.Right,
Vector2.down, Direction.Up,
Vector2.left, Direction.Left,
Vector2.down, Direction.Up,
Vector2.right, Direction.Right,
Vector2.down, Direction.Up,
Vector2.left, Direction.Left,
Vector2.up Direction.Down
}); });
ghostManager.Ghosts[2].SetPredefinedPath(new Vector2[]{ // Inky ghostManager.Ghosts[2].SetPredefinedPath(new Direction[]{ // Inky
Vector2.up, Direction.Down,
Vector2.right, Direction.Right,
Vector2.up, Direction.Down,
Vector2.left, Direction.Left,
Vector2.zero, Direction.Zero,
Vector2.zero, Direction.Zero,
Vector2.down, Direction.Up,
Vector2.right, Direction.Right,
// Pellet starts // Pellet starts
Vector2.up, Direction.Down,
Vector2.right, Direction.Right,
Vector2.up, Direction.Down,
// Caught // Caught
Vector2.right, Direction.Right,
Vector2.down, Direction.Up,
Vector2.right, Direction.Right,
Vector2.down, Direction.Up,
Vector2.left, Direction.Left,
Vector2.down, Direction.Up,
Vector2.left, Direction.Left,
Vector2.down, Direction.Up,
Vector2.left, Direction.Left,
Vector2.up, Direction.Down,
Vector2.left, Direction.Left,
Vector2.down, Direction.Up,
Vector2.right, Direction.Right,
Vector2.down, Direction.Up,
Vector2.right, Direction.Right,
Vector2.zero, Direction.Zero,
Vector2.down, Direction.Up,
Vector2.right, Direction.Right,
Vector2.down, Direction.Up,
Vector2.left, Direction.Left,
Vector2.zero, Direction.Zero,
Vector2.zero, Direction.Zero,
Vector2.up, Direction.Down,
Vector2.right, Direction.Right,
Vector2.up, Direction.Down,
Vector2.left, Direction.Left,
Vector2.up, Direction.Down,
Vector2.right, Direction.Right,
Vector2.up, Direction.Down,
Vector2.left, Direction.Left,
Vector2.up, Direction.Down,
Vector2.right, Direction.Right,
Vector2.down, Direction.Up,
Vector2.left, Direction.Left,
Vector2.down, Direction.Up,
Vector2.left, Direction.Left,
Vector2.zero, Direction.Zero,
Vector2.up, Direction.Down,
Vector2.left Direction.Left
}); });
ghostManager.Ghosts[3].SetPredefinedPath(new Vector2[]{ // Clyde ghostManager.Ghosts[3].SetPredefinedPath(new Direction[]{ // Clyde
Vector2.down, Direction.Up,
Vector2.right, Direction.Right,
Vector2.up, Direction.Down,
Vector2.left, Direction.Left,
Vector2.down, Direction.Up,
Vector2.zero, Direction.Zero,
Vector2.left, Direction.Left,
Vector2.zero, Direction.Zero,
Vector2.down, Direction.Up,
Vector2.right, Direction.Right,
Vector2.down, Direction.Up,
Vector2.right, Direction.Right,
Vector2.up, Direction.Down,
Vector2.right, Direction.Right,
Vector2.zero, Direction.Zero,
Vector2.down, Direction.Up,
Vector2.left, Direction.Left,
Vector2.down, Direction.Up,
Vector2.left, Direction.Left,
Vector2.zero, Direction.Zero,
Vector2.up, Direction.Down,
Vector2.right, Direction.Right,
Vector2.zero, Direction.Zero,
Vector2.up, Direction.Down,
Vector2.left, Direction.Left,
Vector2.down, Direction.Up,
Vector2.right, Direction.Right,
Vector2.up, Direction.Down,
Vector2.left, Direction.Left,
Vector2.up, Direction.Down,
Vector2.right, Direction.Right,
Vector2.down, Direction.Up,
Vector2.left, Direction.Left,
Vector2.down, Direction.Up,
Vector2.left, Direction.Left,
Vector2.zero, Direction.Zero,
Vector2.up, Direction.Down,
Vector2.right Direction.Right
}); });
pacMan.SetPredefinedPath(new Vector2[]{ pacMan.SetPredefinedPath(new Direction[]{
Vector2.down, Direction.Up,
Vector2.right, Direction.Right,
Vector2.down, Direction.Up,
Vector2.right, Direction.Right,
Vector2.zero, Direction.Zero,
Vector2.up, Direction.Down,
Vector2.left, Direction.Left,
Vector2.up, Direction.Down,
Vector2.right, Direction.Right,
Vector2.up, Direction.Down,
Vector2.left, Direction.Left,
Vector2.zero, Direction.Zero,
Vector2.up, Direction.Down,
Vector2.zero, Direction.Zero,
Vector2.left, Direction.Left,
Vector2.down, Direction.Up,
Vector2.left, Direction.Left,
Vector2.up, Direction.Down,
Vector2.zero, Direction.Zero,
Vector2.zero, Direction.Zero,
Vector2.left, Direction.Left,
Vector2.down, Direction.Up,
Vector2.right, Direction.Right,
Vector2.zero, Direction.Zero,
Vector2.up, Direction.Down,
Vector2.left, Direction.Left,
Vector2.down, Direction.Up,
Vector2.zero, Direction.Zero,
Vector2.left, Direction.Left,
Vector2.up, Direction.Down,
Vector2.right, Direction.Right,
Vector2.zero, Direction.Zero,
Vector2.down, Direction.Up,
Vector2.right, Direction.Right,
Vector2.down, Direction.Up,
Vector2.left, Direction.Left,
Vector2.down, Direction.Up,
Vector2.left, Direction.Left,
Vector2.zero, Direction.Zero,
Vector2.down, Direction.Up,
Vector2.zero, Direction.Zero,
Vector2.right, Direction.Right,
Vector2.down, Direction.Up,
Vector2.left, Direction.Left,
Vector2.zero, Direction.Zero,
Vector2.zero, Direction.Zero,
Vector2.up, Direction.Down,
Vector2.right, Direction.Right,
Vector2.up, Direction.Down,
Vector2.left, Direction.Left,
Vector2.up, Direction.Down,
Vector2.right, Direction.Right,
Vector2.zero, Direction.Zero,
Vector2.down, Direction.Up,
Vector2.right, Direction.Right,
Vector2.up, Direction.Down,
Vector2.right, Direction.Right,
Vector2.zero, Direction.Zero,
Vector2.down, Direction.Up,
Vector2.left, Direction.Left,
Vector2.down, Direction.Up,
Vector2.right, Direction.Right,
Vector2.down, Direction.Up,
Vector2.left, Direction.Left,
Vector2.zero, Direction.Zero,
Vector2.zero, Direction.Zero,
Vector2.up, Direction.Down,
Vector2.right, Direction.Right,
Vector2.up, Direction.Down,
Vector2.left, Direction.Left,
Vector2.up, Direction.Down,
Vector2.right, Direction.Right,
}); });
break; break;

View File

@@ -120,7 +120,7 @@ namespace Marro.PacManUdon
case 18: case 18:
// Turn PacMan around after eating power pellet // Turn PacMan around after eating power pellet
pacMan.SetDirection(Direction.Right); pacMan.SetDirection(Direction.Right);
pacMan.SetTargetDirection(Vector2.right); pacMan.SetTargetDirection(Direction.Right);
break; break;
case 19: case 19: