Compare commits

...

2 Commits

Author SHA1 Message Date
420bef5862 Flipped up and down in code 2026-06-19 13:35:09 +02:00
8d23d1812f Simplified ghost starting direction logic 2026-06-19 13:01:19 +02:00
8 changed files with 1080 additions and 1161 deletions

File diff suppressed because it is too large Load Diff

View File

@@ -43,7 +43,7 @@ MonoBehaviour:
Data:
- Name:
Entry: 12
Data: 44
Data: 43
- Name:
Entry: 7
Data:
@@ -1771,13 +1771,13 @@ MonoBehaviour:
Data:
- Name: $k
Entry: 1
Data: faceInStartingDirectionUntilUnfrozen
Data: kinematic
- Name: $v
Entry: 7
Data: 91|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
- Name: <Name>k__BackingField
Entry: 1
Data: faceInStartingDirectionUntilUnfrozen
Data: kinematic
- Name: <UserType>k__BackingField
Entry: 9
Data: 62
@@ -1819,13 +1819,13 @@ MonoBehaviour:
Data:
- Name: $k
Entry: 1
Data: kinematic
Data: specialLook
- Name: $v
Entry: 7
Data: 93|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
- Name: <Name>k__BackingField
Entry: 1
Data: kinematic
Data: specialLook
- Name: <UserType>k__BackingField
Entry: 9
Data: 62
@@ -1867,13 +1867,13 @@ MonoBehaviour:
Data:
- Name: $k
Entry: 1
Data: specialLook
Data: followingPredefinedPath
- Name: $v
Entry: 7
Data: 95|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
- Name: <Name>k__BackingField
Entry: 1
Data: specialLook
Data: followingPredefinedPath
- Name: <UserType>k__BackingField
Entry: 9
Data: 62
@@ -1915,19 +1915,31 @@ MonoBehaviour:
Data:
- Name: $k
Entry: 1
Data: followingPredefinedPath
Data: predefinedPath
- Name: $v
Entry: 7
Data: 97|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
- Name: <Name>k__BackingField
Entry: 1
Data: followingPredefinedPath
Data: predefinedPath
- Name: <UserType>k__BackingField
Entry: 9
Data: 62
Entry: 7
Data: 98|System.RuntimeType, mscorlib
- Name:
Entry: 1
Data: Marro.PacManUdon.Direction[], Assembly-CSharp
- Name:
Entry: 8
Data:
- Name: <SystemType>k__BackingField
Entry: 9
Data: 62
Entry: 7
Data: 99|System.RuntimeType, mscorlib
- Name:
Entry: 1
Data: System.Int32[], mscorlib
- Name:
Entry: 8
Data:
- Name: <SyncMode>k__BackingField
Entry: 7
Data: System.Nullable`1[[UdonSharp.UdonSyncMode, UdonSharp.Runtime]], mscorlib
@@ -1942,7 +1954,8 @@ MonoBehaviour:
Data: false
- Name: _fieldAttributes
Entry: 7
Data: 98|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib
Data: 100|System.Collections.Generic.List`1[[System.Attribute, mscorlib]],
mscorlib
- Name:
Entry: 12
Data: 0
@@ -1963,31 +1976,19 @@ MonoBehaviour:
Data:
- Name: $k
Entry: 1
Data: predefinedPath
Data: predefinedPathIndex
- Name: $v
Entry: 7
Data: 99|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
Data: 101|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
- Name: <Name>k__BackingField
Entry: 1
Data: predefinedPath
Data: predefinedPathIndex
- Name: <UserType>k__BackingField
Entry: 7
Data: 100|System.RuntimeType, mscorlib
- Name:
Entry: 1
Data: Marro.PacManUdon.Direction[], Assembly-CSharp
- Name:
Entry: 8
Data:
Entry: 9
Data: 8
- Name: <SystemType>k__BackingField
Entry: 7
Data: 101|System.RuntimeType, mscorlib
- Name:
Entry: 1
Data: System.Int32[], mscorlib
- Name:
Entry: 8
Data:
Entry: 9
Data: 8
- Name: <SyncMode>k__BackingField
Entry: 7
Data: System.Nullable`1[[UdonSharp.UdonSyncMode, UdonSharp.Runtime]], mscorlib
@@ -2024,13 +2025,13 @@ MonoBehaviour:
Data:
- Name: $k
Entry: 1
Data: predefinedPathIndex
Data: <Index>k__BackingField
- Name: $v
Entry: 7
Data: 103|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
- Name: <Name>k__BackingField
Entry: 1
Data: predefinedPathIndex
Data: <Index>k__BackingField
- Name: <UserType>k__BackingField
Entry: 9
Data: 8
@@ -2073,13 +2074,13 @@ MonoBehaviour:
Data:
- Name: $k
Entry: 1
Data: <Index>k__BackingField
Data: animatorKeyDirection
- Name: $v
Entry: 7
Data: 105|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
- Name: <Name>k__BackingField
Entry: 1
Data: <Index>k__BackingField
Data: animatorKeyDirection
- Name: <UserType>k__BackingField
Entry: 9
Data: 8
@@ -2122,13 +2123,13 @@ MonoBehaviour:
Data:
- Name: $k
Entry: 1
Data: animatorKeyDirection
Data: animatorKeyGhostType
- Name: $v
Entry: 7
Data: 107|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
- Name: <Name>k__BackingField
Entry: 1
Data: animatorKeyDirection
Data: animatorKeyGhostType
- Name: <UserType>k__BackingField
Entry: 9
Data: 8
@@ -2171,19 +2172,19 @@ MonoBehaviour:
Data:
- Name: $k
Entry: 1
Data: animatorKeyGhostType
Data: cardinalDirections
- Name: $v
Entry: 7
Data: 109|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
- Name: <Name>k__BackingField
Entry: 1
Data: animatorKeyGhostType
Data: cardinalDirections
- Name: <UserType>k__BackingField
Entry: 9
Data: 8
Data: 98
- Name: <SystemType>k__BackingField
Entry: 9
Data: 8
Data: 99
- Name: <SyncMode>k__BackingField
Entry: 7
Data: System.Nullable`1[[UdonSharp.UdonSyncMode, UdonSharp.Runtime]], mscorlib
@@ -2220,19 +2221,19 @@ MonoBehaviour:
Data:
- Name: $k
Entry: 1
Data: cardinalDirections
Data: horizontalDirections
- Name: $v
Entry: 7
Data: 111|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
- Name: <Name>k__BackingField
Entry: 1
Data: cardinalDirections
Data: horizontalDirections
- Name: <UserType>k__BackingField
Entry: 9
Data: 100
Data: 98
- Name: <SystemType>k__BackingField
Entry: 9
Data: 101
Data: 99
- Name: <SyncMode>k__BackingField
Entry: 7
Data: System.Nullable`1[[UdonSharp.UdonSyncMode, UdonSharp.Runtime]], mscorlib
@@ -2264,55 +2265,6 @@ MonoBehaviour:
- Name:
Entry: 8
Data:
- Name:
Entry: 7
Data:
- Name: $k
Entry: 1
Data: horizontalDirections
- Name: $v
Entry: 7
Data: 113|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
- Name: <Name>k__BackingField
Entry: 1
Data: horizontalDirections
- Name: <UserType>k__BackingField
Entry: 9
Data: 100
- Name: <SystemType>k__BackingField
Entry: 9
Data: 101
- 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: 114|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: 13
Data:

View File

@@ -76,7 +76,6 @@ namespace Marro.PacManUdon
private int housePelletCounter;
private bool housePelletCounterActive;
private int housePelletCounterLimit;
private bool faceInStartingDirectionUntilUnfrozen;
// Cutscene
private bool kinematic;
@@ -133,6 +132,11 @@ namespace Marro.PacManUdon
if (startState == PacManGhostStartState.TargetingIdlePosition1)
{
SetOffGridTarget(idlePosition1, false);
SetTargetDirection(Direction.Down);
}
else
{
SetTargetDirection(Direction.Up);
}
ghostState = PacManGhostState.Entering;
OffGridTargetReached();
@@ -148,7 +152,6 @@ namespace Marro.PacManUdon
rngState = 1;
UpdateSpeed();
faceInStartingDirectionUntilUnfrozen = true;
UpdateAnimator();
// Debug.Log($"{gameObject} reset with state: {state}, target: {target}, offGrid: {offGrid}");
@@ -519,15 +522,7 @@ namespace Marro.PacManUdon
}
}
if (faceInStartingDirectionUntilUnfrozen && startState == PacManGhostStartState.TargetingIdlePosition1)
{
SetAnimatorDirection((int)Direction.Up);
}
else if (faceInStartingDirectionUntilUnfrozen && startState == PacManGhostStartState.TargetingIdlePosition2)
{
SetAnimatorDirection((int)Direction.Down);
}
else if (specialLook || targetDirection != Direction.Zero)
if (specialLook || targetDirection != Direction.Zero)
{
SetAnimatorDirection((int)targetDirection);
}
@@ -680,12 +675,6 @@ namespace Marro.PacManUdon
frozenState = PacManGhostFrozenState.NotFrozen;
}
animator.speed = frozen && !keepAnimating ? 0 : 1; // This would cause issues if the returning sprite was animated, luckily it isn't :)
if (frozen == false && faceInStartingDirectionUntilUnfrozen)
{
faceInStartingDirectionUntilUnfrozen = false;
UpdateAnimator();
}
}
public void SetHousePelletCounterActive(bool active)
@@ -789,7 +778,6 @@ namespace Marro.PacManUdon
data.AppendAsByte(housePelletCounter, ref index);
data.Append(housePelletCounterActive, ref index);
data.AppendAsByte(housePelletCounterLimit, ref index);
data.Append(faceInStartingDirectionUntilUnfrozen, ref index);
base.CollectSyncedData(data, ref index, eventType);
}
@@ -817,7 +805,6 @@ namespace Marro.PacManUdon
housePelletCounter = data.ReadByte(ref index);
housePelletCounterActive = data.ReadBool(ref index);
housePelletCounterLimit = data.ReadByte(ref index);
faceInStartingDirectionUntilUnfrozen = data.ReadBool(ref index);
return base.WriteSyncedData(data, ref index, eventType);
}

View File

@@ -24,20 +24,20 @@ namespace Marro.PacManUdon
public readonly Vector2[] directionVectors =
{
Vector2.zero, // 0
Vector2.down, // 1
Vector2.up, // 2
Vector2.up, // 1
Vector2.down, // 2
Vector2.zero, // 3
Vector2.left, // 4
Vector2.down + Vector2.left, // 5
Vector2.up + Vector2.left, // 6
Vector2.up + Vector2.left, // 5
Vector2.down + Vector2.left, // 6
Vector2.left, // 7
Vector2.right, // 8
Vector2.down + Vector2.right, // 9
Vector2.up + Vector2.right, // 10
Vector2.up + Vector2.right, // 9
Vector2.down + Vector2.right, // 10
Vector2.right, // 11
Vector2.zero, // 12
Vector2.down, // 13
Vector2.up, // 14
Vector2.up, // 13
Vector2.down, // 14
Vector2.zero, // 15
};
@@ -122,11 +122,11 @@ namespace Marro.PacManUdon
{
if (vertical < 0)
{
return Direction.Up;
return Direction.Down;
}
if (vertical > 0)
{
return Direction.Down;
return Direction.Up;
}
return Direction.Zero;
}

View File

@@ -69,37 +69,37 @@ namespace Marro.PacManUdon
// Jagged or 2D arrays can't be static so we work with 1D arrays
public static byte[] GetMazeCollisionInfo() => new byte[]
{
192, 192, 192, 194, 194, 194, 194, 194, 194, 194, 194, 194, 194, 194, 194, 194, 194, 194, 194, 194, 194, 194, 194, 194, 194, 194, 194, 194, 194, 192, 192, 192,
192, 192, 200, 010, 076, 076, 076, 076, 076, 076, 076, 076, 076, 076, 014, 076, 076, 014, 076, 076, 076, 076, 076, 076, 076, 076, 076, 076, 006, 196, 192, 192,
192, 192, 200, 067, 133, 193, 193, 193, 193, 193, 193, 193, 193, 137, 067, 133, 137, 067, 133, 193, 193, 193, 193, 193, 193, 193, 193, 137, 067, 196, 192, 192,
192, 192, 200, 067, 134, 194, 194, 194, 194, 192, 192, 194, 194, 138, 067, 196, 200, 067, 134, 194, 194, 192, 192, 194, 194, 194, 194, 138, 067, 196, 192, 192,
192, 192, 200, 009, 076, 014, 076, 076, 006, 196, 200, 010, 076, 076, 005, 196, 200, 009, 076, 076, 006, 196, 200, 010, 076, 076, 014, 076, 005, 196, 192, 192,
192, 192, 192, 193, 137, 067, 133, 137, 067, 196, 200, 067, 133, 193, 193, 192, 192, 193, 193, 137, 067, 196, 200, 067, 133, 137, 067, 133, 193, 192, 192, 192,
192, 192, 192, 194, 138, 067, 196, 200, 067, 134, 138, 067, 134, 194, 194, 194, 194, 194, 194, 138, 067, 134, 138, 067, 196, 200, 067, 134, 194, 192, 192, 192,
192, 192, 200, 010, 076, 005, 196, 200, 011, 076, 076, 013, 076, 076, 030, 076, 076, 030, 076, 076, 013, 076, 076, 007, 196, 200, 009, 076, 006, 196, 192, 192,
192, 192, 200, 067, 133, 193, 192, 200, 067, 133, 193, 193, 193, 137, 067, 133, 137, 067, 133, 193, 193, 193, 137, 067, 196, 192, 193, 137, 067, 196, 192, 192,
192, 192, 200, 067, 134, 194, 194, 138, 067, 134, 194, 194, 194, 138, 067, 196, 200, 067, 134, 194, 194, 194, 138, 067, 134, 194, 194, 138, 067, 196, 192, 192,
192, 192, 200, 009, 076, 076, 076, 076, 015, 076, 076, 014, 076, 076, 005, 196, 200, 009, 076, 076, 014, 076, 076, 015, 076, 076, 076, 076, 005, 196, 192, 192,
192, 192, 192, 193, 193, 193, 193, 137, 067, 133, 137, 067, 133, 193, 193, 192, 192, 193, 193, 137, 067, 133, 137, 067, 133, 193, 193, 193, 193, 192, 192, 192,
192, 192, 192, 192, 192, 192, 192, 200, 067, 196, 200, 067, 134, 194, 194, 194, 194, 194, 194, 138, 067, 196, 200, 067, 196, 192, 192, 192, 192, 192, 192, 192,
192, 192, 192, 192, 192, 192, 192, 200, 067, 196, 200, 011, 076, 076, 076, 076, 076, 076, 076, 076, 007, 196, 200, 067, 196, 192, 192, 192, 192, 192, 192, 192,
192, 192, 192, 193, 193, 193, 193, 193, 193, 193, 193, 193, 193, 193, 193, 193, 193, 193, 193, 193, 193, 193, 193, 193, 193, 193, 193, 193, 193, 192, 192, 192,
192, 192, 200, 009, 076, 076, 076, 076, 076, 076, 076, 076, 076, 076, 013, 076, 076, 013, 076, 076, 076, 076, 076, 076, 076, 076, 076, 076, 005, 196, 192, 192,
192, 192, 200, 067, 134, 194, 194, 194, 194, 194, 194, 194, 194, 138, 067, 134, 138, 067, 134, 194, 194, 194, 194, 194, 194, 194, 194, 138, 067, 196, 192, 192,
192, 192, 200, 067, 133, 193, 193, 193, 193, 192, 192, 193, 193, 137, 067, 196, 200, 067, 133, 193, 193, 192, 192, 193, 193, 193, 193, 137, 067, 196, 192, 192,
192, 192, 200, 010, 076, 013, 076, 076, 005, 196, 200, 009, 076, 076, 006, 196, 200, 010, 076, 076, 005, 196, 200, 009, 076, 076, 013, 076, 006, 196, 192, 192,
192, 192, 192, 194, 138, 067, 134, 138, 067, 196, 200, 067, 134, 194, 194, 192, 192, 194, 194, 138, 067, 196, 200, 067, 134, 138, 067, 134, 194, 192, 192, 192,
192, 192, 192, 193, 137, 067, 196, 200, 067, 133, 137, 067, 133, 193, 193, 193, 193, 193, 193, 137, 067, 133, 137, 067, 196, 200, 067, 133, 193, 192, 192, 192,
192, 192, 200, 009, 076, 006, 196, 200, 011, 076, 076, 014, 076, 076, 029, 076, 076, 029, 076, 076, 014, 076, 076, 007, 196, 200, 010, 076, 005, 196, 192, 192,
192, 192, 200, 067, 134, 194, 192, 200, 067, 134, 194, 194, 194, 138, 067, 134, 138, 067, 134, 194, 194, 194, 138, 067, 196, 192, 194, 138, 067, 196, 192, 192,
192, 192, 200, 067, 133, 193, 193, 137, 067, 133, 193, 193, 193, 137, 067, 196, 200, 067, 133, 193, 193, 193, 137, 067, 133, 193, 193, 137, 067, 196, 192, 192,
192, 192, 200, 010, 076, 076, 076, 076, 015, 076, 076, 013, 076, 076, 006, 196, 200, 010, 076, 076, 013, 076, 076, 015, 076, 076, 076, 076, 006, 196, 192, 192,
192, 192, 192, 194, 194, 194, 194, 138, 067, 134, 138, 067, 134, 194, 194, 192, 192, 194, 194, 138, 067, 134, 138, 067, 134, 194, 194, 194, 194, 192, 192, 192,
192, 192, 192, 192, 192, 192, 192, 200, 067, 196, 200, 067, 133, 193, 193, 193, 193, 193, 193, 137, 067, 196, 200, 067, 196, 192, 192, 192, 192, 192, 192, 192,
194, 194, 194, 194, 194, 194, 194, 138, 067, 134, 138, 067, 196, 192, 192, 192, 192, 192, 192, 200, 067, 134, 138, 067, 134, 194, 194, 194, 194, 194, 194, 194,
108, 108, 108, 108, 108, 108, 108, 076, 015, 076, 076, 007, 196, 192, 192, 192, 192, 192, 192, 200, 011, 076, 076, 015, 076, 108, 108, 108, 108, 108, 108, 108,
193, 193, 193, 193, 193, 193, 193, 137, 067, 133, 137, 067, 196, 192, 192, 192, 192, 192, 192, 200, 067, 133, 137, 067, 133, 193, 193, 193, 193, 193, 193, 193,
192, 192, 192, 192, 192, 192, 192, 200, 067, 196, 200, 011, 076, 076, 076, 076, 076, 076, 076, 076, 007, 196, 200, 067, 196, 192, 192, 192, 192, 192, 192, 192,
192, 192, 192, 192, 192, 192, 192, 200, 067, 196, 200, 067, 134, 194, 194, 194, 194, 194, 194, 138, 067, 196, 200, 067, 196, 192, 192, 192, 192, 192, 192, 192,
192, 192, 192, 192, 192, 192, 192, 200, 067, 196, 200, 009, 076, 076, 030, 076, 076, 030, 076, 076, 005, 196, 200, 067, 196, 192, 192, 192, 192, 192, 192, 192,
192, 192, 192, 192, 192, 192, 192, 200, 067, 196, 192, 193, 193, 137, 067, 133, 137, 067, 133, 193, 193, 192, 200, 067, 196, 192, 192, 192, 192, 192, 192, 192,
192, 192, 192, 194, 194, 194, 194, 138, 067, 196, 192, 194, 194, 138, 067, 196, 200, 067, 134, 194, 194, 192, 200, 067, 134, 194, 194, 194, 194, 192, 192, 192,
192, 192, 200, 010, 076, 076, 076, 076, 007, 196, 200, 010, 076, 076, 005, 196, 200, 009, 076, 076, 006, 196, 200, 011, 076, 076, 076, 076, 006, 196, 192, 192,
192, 192, 200, 067, 133, 193, 193, 137, 067, 196, 200, 067, 133, 193, 193, 192, 192, 193, 193, 137, 067, 196, 200, 067, 133, 193, 193, 137, 067, 196, 192, 192,
192, 192, 200, 067, 134, 194, 194, 138, 067, 134, 138, 067, 134, 194, 194, 194, 194, 194, 194, 138, 067, 134, 138, 067, 134, 194, 194, 138, 067, 196, 192, 192,
192, 192, 200, 011, 076, 076, 076, 076, 015, 076, 076, 013, 076, 076, 014, 076, 076, 014, 076, 076, 013, 076, 076, 015, 076, 076, 076, 076, 007, 196, 192, 192,
192, 192, 200, 067, 133, 193, 193, 137, 067, 133, 193, 193, 193, 137, 067, 133, 137, 067, 133, 193, 193, 193, 137, 067, 133, 193, 193, 137, 067, 196, 192, 192,
193, 193, 193, 193, 193, 193, 193, 137, 067, 133, 137, 067, 196, 192, 192, 192, 192, 192, 192, 200, 067, 133, 137, 067, 133, 193, 193, 193, 193, 193, 193, 193,
108, 108, 108, 108, 108, 108, 108, 076, 015, 076, 076, 007, 196, 192, 192, 192, 192, 192, 192, 200, 011, 076, 076, 015, 076, 108, 108, 108, 108, 108, 108, 108,
194, 194, 194, 194, 194, 194, 194, 138, 067, 134, 138, 067, 196, 192, 192, 192, 192, 192, 192, 200, 067, 134, 138, 067, 134, 194, 194, 194, 194, 194, 194, 194,
192, 192, 192, 192, 192, 192, 192, 200, 067, 196, 200, 067, 133, 193, 193, 193, 193, 193, 193, 137, 067, 196, 200, 067, 196, 192, 192, 192, 192, 192, 192, 192,
192, 192, 192, 192, 192, 192, 192, 200, 067, 196, 200, 010, 076, 076, 029, 076, 076, 029, 076, 076, 006, 196, 200, 067, 196, 192, 192, 192, 192, 192, 192, 192,
192, 192, 192, 192, 192, 192, 192, 200, 067, 196, 192, 194, 194, 138, 067, 134, 138, 067, 134, 194, 194, 192, 200, 067, 196, 192, 192, 192, 192, 192, 192, 192,
192, 192, 192, 193, 193, 193, 193, 137, 067, 196, 192, 193, 193, 137, 067, 196, 200, 067, 133, 193, 193, 192, 200, 067, 133, 193, 193, 193, 193, 192, 192, 192,
192, 192, 200, 009, 076, 076, 076, 076, 007, 196, 200, 009, 076, 076, 006, 196, 200, 010, 076, 076, 005, 196, 200, 011, 076, 076, 076, 076, 005, 196, 192, 192,
192, 192, 200, 067, 134, 194, 194, 138, 067, 196, 200, 067, 134, 194, 194, 192, 192, 194, 194, 138, 067, 196, 200, 067, 134, 194, 194, 138, 067, 196, 192, 192,
192, 192, 200, 067, 133, 193, 193, 137, 067, 133, 137, 067, 133, 193, 193, 193, 193, 193, 193, 137, 067, 133, 137, 067, 133, 193, 193, 137, 067, 196, 192, 192,
192, 192, 200, 011, 076, 076, 076, 076, 015, 076, 076, 014, 076, 076, 013, 076, 076, 013, 076, 076, 014, 076, 076, 015, 076, 076, 076, 076, 007, 196, 192, 192,
192, 192, 200, 067, 134, 194, 194, 138, 067, 134, 194, 194, 194, 138, 067, 134, 138, 067, 134, 194, 194, 194, 138, 067, 134, 194, 194, 138, 067, 196, 192, 192,
192, 192, 200, 067, 196, 192, 192, 200, 067, 196, 192, 192, 192, 200, 067, 196, 200, 067, 196, 192, 192, 192, 200, 067, 196, 192, 192, 200, 067, 196, 192, 192,
192, 192, 200, 067, 134, 194, 194, 138, 067, 134, 194, 194, 194, 138, 067, 196, 200, 067, 134, 194, 194, 194, 138, 067, 134, 194, 194, 138, 067, 196, 192, 192,
192, 192, 200, 009, 076, 076, 076, 076, 013, 076, 076, 076, 076, 076, 005, 196, 200, 009, 076, 076, 076, 076, 076, 013, 076, 076, 076, 076, 005, 196, 192, 192,
192, 192, 192, 193, 193, 193, 193, 193, 193, 193, 193, 193, 193, 193, 193, 192, 192, 193, 193, 193, 193, 193, 193, 193, 193, 193, 193, 193, 193, 192, 192, 192,
192, 192, 200, 067, 133, 193, 193, 137, 067, 133, 193, 193, 193, 137, 067, 196, 200, 067, 133, 193, 193, 193, 137, 067, 133, 193, 193, 137, 067, 196, 192, 192,
192, 192, 200, 010, 076, 076, 076, 076, 014, 076, 076, 076, 076, 076, 006, 196, 200, 010, 076, 076, 076, 076, 076, 014, 076, 076, 076, 076, 006, 196, 192, 192,
192, 192, 192, 194, 194, 194, 194, 194, 194, 194, 194, 194, 194, 194, 194, 192, 192, 194, 194, 194, 194, 194, 194, 194, 194, 194, 194, 194, 194, 192, 192, 192,
192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192,
};

View File

@@ -100,7 +100,7 @@
return;
}
verticalValue = Math.Abs(value);
if (value < -0.5)
if (value > 0.5)
{
inputVertical = Direction.Up;
if (verticalValue >= horizontalValue)
@@ -108,7 +108,7 @@
SetPriority(false);
}
}
else if (value > 0.5)
else if (value < -0.5)
{
inputVertical = Direction.Down;
if (verticalValue >= horizontalValue)

View File

@@ -65,7 +65,7 @@ namespace Marro.PacManUdon.Dev
map[rightTileIndex] = (int)PacManConsumableType.FruitRight;
}
private void PrintMazeMap()
private static void PrintMazeMap()
{
int[] map = new int[width * height];
var collisionMap = GetCollisionMap();
@@ -73,7 +73,7 @@ namespace Marro.PacManUdon.Dev
for (int i = 0; i < map.Length; i++)
{
byte result = 0;
var tile = collisionMap[i];
var tile = GetTileAtIndex(collisionMap, i);
if (tile == (byte)CollisionMap.Wall)
{
@@ -92,34 +92,34 @@ namespace Marro.PacManUdon.Dev
result |= GetGhostTurnInformation(collisionMap, i, width, height);
map[(i % width) + (height - i / width - 1) * width] = result;
map[i] = result;
}
PrintMap(map, width);
}
private byte GetGhostTurnInformation(byte[] collisionMap, int i, int width, int height)
private static byte GetGhostTurnInformation(byte[] collisionMap, int i, int width, int height)
{
byte result = 0;
var totalAvailableDirections = 0;
if (collisionMap[GetTilemapIndex(i, Vector2.up, width, height)] != (byte)CollisionMap.Wall)
if (GetTileAtIndex(collisionMap, GetTilemapIndex(i, Vector2.up, width, height)) != (byte)CollisionMap.Wall)
{
result |= 0b0001;
result |= (byte)Direction.Up;
totalAvailableDirections += 1;
}
if (collisionMap[GetTilemapIndex(i, Vector2.down, width, height)] != (byte)CollisionMap.Wall)
if (GetTileAtIndex(collisionMap, GetTilemapIndex(i, Vector2.down, width, height)) != (byte)CollisionMap.Wall)
{
result |= 0b0010;
result |= (byte)Direction.Down;
totalAvailableDirections += 1;
}
if (collisionMap[GetTilemapIndex(i, Vector2.left, width, height)] != (byte)CollisionMap.Wall)
if (GetTileAtIndex(collisionMap, GetTilemapIndex(i, Vector2.left, width, height)) != (byte)CollisionMap.Wall)
{
result |= 0b0100;
result |= (byte)Direction.Left;
totalAvailableDirections += 1;
}
if (collisionMap[GetTilemapIndex(i, Vector2.right, width, height)] != (byte)CollisionMap.Wall)
if (GetTileAtIndex(collisionMap, GetTilemapIndex(i, Vector2.right, width, height)) != (byte)CollisionMap.Wall)
{
result |= 0b1000;
result |= (byte)Direction.Right;
totalAvailableDirections += 1;
}
@@ -132,39 +132,14 @@ namespace Marro.PacManUdon.Dev
return result;
}
private int GetTilemapIndex(int index, Vector2 direction, int width, int height)
private static int GetTilemapIndex(int index, Vector2 direction, int width, int height)
{
var position = new Vector2(index % width, index / width) + direction;
position = Clamp(position, 0, width - 1, 0, height - 1);
var result = (int)position.x + (int)position.y * width;
var result = ((int)position.x + width) % width + ((int)position.y + height) % height * width;
return result;
}
private static Vector2 Clamp(Vector2 vector, float xMin, float xMax, float yMin, float yMax)
{
if (vector.x < xMin)
{
vector.x = xMin;
}
if (vector.x > xMax)
{
vector.x = xMax;
}
if (vector.y < yMin)
{
vector.y = yMin;
}
if (vector.y > yMax)
{
vector.y = yMax;
}
return vector;
}
private void PrintMap(int[] map, int width)
private static void PrintMap(int[] map, int width)
{
var result = "";
for (int i = 0; i < map.Length; i++)
@@ -187,6 +162,10 @@ namespace Marro.PacManUdon.Dev
Debug.Log(result);
}
private static byte GetTileAtIndex(byte[] map, int index) => map[GetUpsideDownIndex(index)];
private static int GetUpsideDownIndex(int index) => (index % width) + (height - index / width - 1) * width;
public static byte[] GetCollisionMap() => new byte[] {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,