Compare commits

..

2 Commits

Author SHA1 Message Date
a24f237bd5 Bonus fruit hitbox 2026-06-15 17:21:16 +02:00
c601dda10a Pellet collision 2026-06-15 14:36:07 +02:00
14 changed files with 764 additions and 530 deletions

View File

@@ -11,8 +11,6 @@ GameObject:
- component: {fileID: 1315692994360949719} - component: {fileID: 1315692994360949719}
- component: {fileID: 967117457436250906} - component: {fileID: 967117457436250906}
- component: {fileID: 7512162431685415002} - component: {fileID: 7512162431685415002}
- component: {fileID: 2135601224056198654}
- component: {fileID: 3963523032509914404}
- component: {fileID: 9117212235706742114} - component: {fileID: 9117212235706742114}
m_Layer: 0 m_Layer: 0
m_Name: Pellet m_Name: Pellet
@@ -111,54 +109,7 @@ MonoBehaviour:
SerializationNodes: [] SerializationNodes: []
_udonSharpBackingUdonBehaviour: {fileID: 9117212235706742114} _udonSharpBackingUdonBehaviour: {fileID: 9117212235706742114}
isPowerPellet: 0 isPowerPellet: 0
--- !u!65 &2135601224056198654 pelletRenderer: {fileID: 0}
BoxCollider:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 4099390335584803315}
m_Material: {fileID: 0}
m_IncludeLayers:
serializedVersion: 2
m_Bits: 0
m_ExcludeLayers:
serializedVersion: 2
m_Bits: 0
m_LayerOverridePriority: 0
m_IsTrigger: 1
m_ProvidesContacts: 0
m_Enabled: 1
serializedVersion: 3
m_Size: {x: 0.5, y: 0.5, z: 0.5}
m_Center: {x: 0, y: 0, z: 0}
--- !u!54 &3963523032509914404
Rigidbody:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 4099390335584803315}
serializedVersion: 4
m_Mass: 1
m_Drag: 0
m_AngularDrag: 0.05
m_CenterOfMass: {x: 0, y: 0, z: 0}
m_InertiaTensor: {x: 1, y: 1, z: 1}
m_InertiaRotation: {x: 0, y: 0, z: 0, w: 1}
m_IncludeLayers:
serializedVersion: 2
m_Bits: 0
m_ExcludeLayers:
serializedVersion: 2
m_Bits: 0
m_ImplicitCom: 1
m_ImplicitTensor: 1
m_UseGravity: 1
m_IsKinematic: 1
m_Interpolate: 0
m_Constraints: 0
m_CollisionDetection: 0
--- !u!114 &9117212235706742114 --- !u!114 &9117212235706742114
MonoBehaviour: MonoBehaviour:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0

View File

@@ -6,14 +6,12 @@ namespace Marro.PacManUdon
{ {
[RequireComponent(typeof(Animator))] [RequireComponent(typeof(Animator))]
[RequireComponent(typeof(Renderer))] [RequireComponent(typeof(Renderer))]
[RequireComponent(typeof(Collider))]
public class BonusFruit : SyncedObject public class BonusFruit : SyncedObject
{ {
PacManFruitType fruitType; PacManFruitType fruitType;
Animator animator; Animator animator;
new Renderer renderer; new Renderer renderer;
new Collider collider;
ScoreBonusDisplay scoreBonusDisplay; ScoreBonusDisplay scoreBonusDisplay;
[UdonSynced] bool active; [UdonSynced] bool active;
@@ -25,7 +23,6 @@ namespace Marro.PacManUdon
{ {
animator = GetComponent<Animator>(); animator = GetComponent<Animator>();
renderer = GetComponent<Renderer>(); renderer = GetComponent<Renderer>();
collider = GetComponent<Collider>();
scoreBonusDisplay = transform.Find("ScoreBonusDisplay").gameObject.GetComponent<ScoreBonusDisplay>(); scoreBonusDisplay = transform.Find("ScoreBonusDisplay").gameObject.GetComponent<ScoreBonusDisplay>();
scoreBonusDisplay.Initialize(); scoreBonusDisplay.Initialize();
SetActive(false); SetActive(false);
@@ -78,7 +75,6 @@ namespace Marro.PacManUdon
void SetActive(bool active) void SetActive(bool active)
{ // This replaces GameObject.active, as attempting to update an animator while a gameobject is inactive seems to result in a silent failure { // This replaces GameObject.active, as attempting to update an animator while a gameobject is inactive seems to result in a silent failure
renderer.enabled = active; renderer.enabled = active;
collider.enabled = active;
this.active = active; this.active = active;
} }

View File

@@ -43,7 +43,7 @@ MonoBehaviour:
Data: Data:
- Name: - Name:
Entry: 12 Entry: 12
Data: 11 Data: 10
- Name: - Name:
Entry: 7 Entry: 7
Data: Data:
@@ -277,25 +277,25 @@ MonoBehaviour:
Data: Data:
- Name: $k - Name: $k
Entry: 1 Entry: 1
Data: collider Data: scoreBonusDisplay
- Name: $v - Name: $v
Entry: 7 Entry: 7
Data: 16|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor Data: 16|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
- Name: <Name>k__BackingField - Name: <Name>k__BackingField
Entry: 1 Entry: 1
Data: collider Data: scoreBonusDisplay
- Name: <UserType>k__BackingField - Name: <UserType>k__BackingField
Entry: 7 Entry: 7
Data: 17|System.RuntimeType, mscorlib Data: 17|System.RuntimeType, mscorlib
- Name: - Name:
Entry: 1 Entry: 1
Data: UnityEngine.Collider, UnityEngine.PhysicsModule Data: Marro.PacManUdon.ScoreBonusDisplay, Assembly-CSharp
- Name: - Name:
Entry: 8 Entry: 8
Data: Data:
- Name: <SystemType>k__BackingField - Name: <SystemType>k__BackingField
Entry: 9 Entry: 9
Data: 17 Data: 4
- 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
@@ -331,25 +331,79 @@ MonoBehaviour:
Data: Data:
- Name: $k - Name: $k
Entry: 1 Entry: 1
Data: scoreBonusDisplay Data: active
- Name: $v - Name: $v
Entry: 7 Entry: 7
Data: 19|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor Data: 19|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
- Name: <Name>k__BackingField - Name: <Name>k__BackingField
Entry: 1 Entry: 1
Data: scoreBonusDisplay Data: active
- Name: <UserType>k__BackingField - Name: <UserType>k__BackingField
Entry: 7 Entry: 7
Data: 20|System.RuntimeType, mscorlib Data: 20|System.RuntimeType, mscorlib
- Name: - Name:
Entry: 1 Entry: 1
Data: Marro.PacManUdon.ScoreBonusDisplay, Assembly-CSharp Data: System.Boolean, mscorlib
- Name: - Name:
Entry: 8 Entry: 8
Data: Data:
- Name: <SystemType>k__BackingField - Name: <SystemType>k__BackingField
Entry: 9 Entry: 9
Data: 4 Data: 20
- Name: <SyncMode>k__BackingField
Entry: 7
Data: System.Nullable`1[[UdonSharp.UdonSyncMode, UdonSharp.Runtime]], mscorlib
- Name:
Entry: 3
Data: 1
- Name:
Entry: 8
Data:
- Name: <IsSerialized>k__BackingField
Entry: 5
Data: false
- Name: _fieldAttributes
Entry: 7
Data: 21|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib
- Name:
Entry: 12
Data: 1
- Name:
Entry: 7
Data: 22|UdonSharp.UdonSyncedAttribute, UdonSharp.Runtime
- Name:
Entry: 8
Data:
- 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: value
- Name: $v
Entry: 7
Data: 23|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
- Name: <Name>k__BackingField
Entry: 1
Data: value
- Name: <UserType>k__BackingField
Entry: 9
Data: 8
- Name: <SystemType>k__BackingField
Entry: 9
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
@@ -364,7 +418,7 @@ MonoBehaviour:
Data: false Data: false
- Name: _fieldAttributes - Name: _fieldAttributes
Entry: 7 Entry: 7
Data: 21|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib Data: 24|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib
- Name: - Name:
Entry: 12 Entry: 12
Data: 0 Data: 0
@@ -385,79 +439,25 @@ MonoBehaviour:
Data: Data:
- Name: $k - Name: $k
Entry: 1 Entry: 1
Data: active Data: activeCountdown
- Name: $v - Name: $v
Entry: 7 Entry: 7
Data: 22|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor Data: 25|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
- Name: <Name>k__BackingField - Name: <Name>k__BackingField
Entry: 1 Entry: 1
Data: active Data: activeCountdown
- Name: <UserType>k__BackingField - Name: <UserType>k__BackingField
Entry: 7 Entry: 7
Data: 23|System.RuntimeType, mscorlib Data: 26|System.RuntimeType, mscorlib
- Name: - Name:
Entry: 1 Entry: 1
Data: System.Boolean, mscorlib Data: System.Single, mscorlib
- Name: - Name:
Entry: 8 Entry: 8
Data: Data:
- Name: <SystemType>k__BackingField - Name: <SystemType>k__BackingField
Entry: 9 Entry: 9
Data: 23 Data: 26
- Name: <SyncMode>k__BackingField
Entry: 7
Data: System.Nullable`1[[UdonSharp.UdonSyncMode, UdonSharp.Runtime]], mscorlib
- Name:
Entry: 3
Data: 1
- Name:
Entry: 8
Data:
- Name: <IsSerialized>k__BackingField
Entry: 5
Data: false
- Name: _fieldAttributes
Entry: 7
Data: 24|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib
- Name:
Entry: 12
Data: 1
- Name:
Entry: 7
Data: 25|UdonSharp.UdonSyncedAttribute, UdonSharp.Runtime
- Name:
Entry: 8
Data:
- 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: value
- Name: $v
Entry: 7
Data: 26|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
- Name: <Name>k__BackingField
Entry: 1
Data: value
- Name: <UserType>k__BackingField
Entry: 9
Data: 8
- Name: <SystemType>k__BackingField
Entry: 9
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
@@ -493,25 +493,19 @@ MonoBehaviour:
Data: Data:
- Name: $k - Name: $k
Entry: 1 Entry: 1
Data: activeCountdown Data: frozen
- Name: $v - Name: $v
Entry: 7 Entry: 7
Data: 28|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor Data: 28|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
- Name: <Name>k__BackingField - Name: <Name>k__BackingField
Entry: 1 Entry: 1
Data: activeCountdown Data: frozen
- Name: <UserType>k__BackingField - Name: <UserType>k__BackingField
Entry: 7 Entry: 9
Data: 29|System.RuntimeType, mscorlib Data: 20
- Name:
Entry: 1
Data: System.Single, mscorlib
- Name:
Entry: 8
Data:
- Name: <SystemType>k__BackingField - Name: <SystemType>k__BackingField
Entry: 9 Entry: 9
Data: 29 Data: 20
- 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
@@ -526,7 +520,7 @@ MonoBehaviour:
Data: false Data: false
- Name: _fieldAttributes - Name: _fieldAttributes
Entry: 7 Entry: 7
Data: 30|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib Data: 29|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib
- Name: - Name:
Entry: 12 Entry: 12
Data: 0 Data: 0
@@ -547,19 +541,25 @@ MonoBehaviour:
Data: Data:
- Name: $k - Name: $k
Entry: 1 Entry: 1
Data: frozen Data: fruitScoreValue
- Name: $v - Name: $v
Entry: 7 Entry: 7
Data: 31|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor Data: 30|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
- Name: <Name>k__BackingField - Name: <Name>k__BackingField
Entry: 1 Entry: 1
Data: frozen Data: fruitScoreValue
- Name: <UserType>k__BackingField - Name: <UserType>k__BackingField
Entry: 9 Entry: 7
Data: 23 Data: 31|System.RuntimeType, mscorlib
- Name:
Entry: 1
Data: VRC.SDK3.Data.DataDictionary, VRCSDK3
- Name:
Entry: 8
Data:
- Name: <SystemType>k__BackingField - Name: <SystemType>k__BackingField
Entry: 9 Entry: 9
Data: 23 Data: 31
- 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
@@ -590,60 +590,6 @@ MonoBehaviour:
- Name: - Name:
Entry: 8 Entry: 8
Data: Data:
- Name:
Entry: 7
Data:
- Name: $k
Entry: 1
Data: fruitScoreValue
- Name: $v
Entry: 7
Data: 33|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
- Name: <Name>k__BackingField
Entry: 1
Data: fruitScoreValue
- Name: <UserType>k__BackingField
Entry: 7
Data: 34|System.RuntimeType, mscorlib
- Name:
Entry: 1
Data: VRC.SDK3.Data.DataDictionary, VRCSDK3
- Name:
Entry: 8
Data:
- Name: <SystemType>k__BackingField
Entry: 9
Data: 34
- 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: 35|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: - Name:
Entry: 13 Entry: 13
Data: Data:

View File

@@ -61,7 +61,7 @@ namespace Marro.PacManUdon
ghostManager.Initialize(maze.ghostStarts, maze.ghostTargets, pacMan, pelletManager, this); ghostManager.Initialize(maze.ghostStarts, maze.ghostTargets, pacMan, pelletManager, this);
pacMan.Initialize(playerInput, maze.pacManStart, this, pelletManager); pacMan.Initialize(playerInput, maze.pacManStart, this, pelletManager);
bonusFruit.Initialize(); bonusFruit.Initialize();
pelletManager.Initialize(); pelletManager.Initialize(this, bonusFruit);
statusDisplay.Initialize(); statusDisplay.Initialize();
playerInput.Initialize(this); playerInput.Initialize(this);
soundManager.Initialize(); soundManager.Initialize();
@@ -163,25 +163,35 @@ namespace Marro.PacManUdon
SetFrozen(true); SetFrozen(true);
} }
public void GotPellet(Pellet pellet, bool addScore = true) internal void GotPellet(Pellet pellet, PelletType pelletType, int pelletsCollectedCount, int pelletsRemainingCount)
{ {
var pelletCollectedCount = pelletManager.PelletCollected(pellet); AddScore(pelletType == PelletType.PowerPellet ? 50 : 10);
if (addScore) AddScore(10); ghostManager.PelletConsumed(pelletsRemainingCount);
ghostManager.PelletConsumed();
soundManager.PlayPelletSound(); soundManager.PlayPelletSound();
soundManager.UpdatePelletCount(pelletsRemainingCount);
var pelletCountRemaining = pelletManager.PelletCount - pelletCollectedCount; if (pelletsRemainingCount <= 0)
soundManager.UpdatePelletCount(pelletCountRemaining);
if (pelletCountRemaining <= 0)
{ {
StartTimeSequence(PacManTimeSequence.BoardClear); StartTimeSequence(PacManTimeSequence.BoardClear);
return;
} }
else if (pelletCollectedCount == 70 || pelletCollectedCount == 170)
if (pelletType == PelletType.PowerPellet)
{
if (gameState == PacManGameState.AttractMode)
{
TimeSequenceSkipToNextStep();
return;
}
ghostManager.SetPowerPellet(true);
pacMan.SetPowerPellet(true);
soundManager.SetGhostBlue(true);
}
if (pelletsCollectedCount == 70 || pelletsCollectedCount == 170)
{ {
bonusFruit.Spawn(); bonusFruit.Spawn();
} }
@@ -191,16 +201,7 @@ namespace Marro.PacManUdon
{ {
//Debug.Log($"{gameObject} GotPowerPellet"); //Debug.Log($"{gameObject} GotPowerPellet");
if (gameState == PacManGameState.AttractMode)
{
TimeSequenceSkipToNextStep();
return;
}
GotPellet(pellet, addScore: false);
AddScore(50);
ghostManager.SetPowerPellet(true);
pacMan.SetPowerPellet(true);
soundManager.SetGhostBlue(true);
} }
public void EndPowerPellet() public void EndPowerPellet()

View File

@@ -259,7 +259,7 @@ namespace Marro.PacManUdon
return; return;
} }
Debug.Log($"{gameObject.name} Turned from direction {direction} to direction {newDirection}"); //Debug.Log($"{gameObject.name} Turned from direction {direction} to direction {newDirection}");
nextPosition = GetNextPosition(gridPosition, directionVectors[(int)newDirection], speed, networkManager.SyncedDeltaTime); nextPosition = GetNextPosition(gridPosition, directionVectors[(int)newDirection], speed, networkManager.SyncedDeltaTime);
SetDirection(newDirection); SetDirection(newDirection);
} }

View File

@@ -105,7 +105,7 @@ namespace Marro.PacManUdon
public void NewLevel() public void NewLevel()
{ {
SetSharedPelletCounterActive(false); SetSharedPelletCounterActive(false);
UpdateElroyLevel(); UpdateElroyLevel(pelletManager.PelletCount);
foreach (Ghost ghost in ghosts) foreach (Ghost ghost in ghosts)
{ {
ghost.ResetHousePelletCounter(); ghost.ResetHousePelletCounter();
@@ -404,11 +404,11 @@ namespace Marro.PacManUdon
} }
} }
public void PelletConsumed() public void PelletConsumed(int pelletsRemainingCount)
{ {
pelletTimeout = 0; pelletTimeout = 0;
UpdateElroyLevel(); UpdateElroyLevel(pelletsRemainingCount);
if (sharedPelletCounterActive) if (sharedPelletCounterActive)
{ {
@@ -452,14 +452,13 @@ namespace Marro.PacManUdon
} }
} }
void UpdateElroyLevel() void UpdateElroyLevel(int pelletsRemainingCount)
{ {
// Debug.Log($"{gameObject} Updating Elroy Level with pelletsRemaining {pelletsRemaining} with elroy2PelletCount {elroy2PelletCount} and elroy1PelletCount {elroy1PelletCount}"); // Debug.Log($"{gameObject} Updating Elroy Level with pelletsRemaining {pelletsRemaining} with elroy2PelletCount {elroy2PelletCount} and elroy1PelletCount {elroy1PelletCount}");
var oldElroyLevel = elroyLevel; var oldElroyLevel = elroyLevel;
var pelletsRemaining = pelletManager.PelletCount - pelletManager.PelletCollectedCount; if (pelletsRemainingCount < elroy2PelletCount) elroyLevel = 2;
if (pelletsRemaining < elroy2PelletCount) elroyLevel = 2; else if (pelletsRemainingCount < elroy1PelletCount) elroyLevel = 1;
else if (pelletsRemaining < elroy1PelletCount) elroyLevel = 1;
else elroyLevel = 0; else elroyLevel = 0;
if (elroyLevel != oldElroyLevel) if (elroyLevel != oldElroyLevel)

View File

@@ -199,11 +199,11 @@ namespace Marro.PacManUdon
if (IsHorizontal(direction)) if (IsHorizontal(direction))
{ {
result = result || Math.Floor(currentPosition.x) != Math.Floor(nextPosition.x); result = Math.Floor(currentPosition.x) != Math.Floor(nextPosition.x);
} }
if (IsVertical(direction)) if (!result && IsVertical(direction))
{ {
result = result || Math.Floor(currentPosition.y) != Math.Floor(nextPosition.y); result = Math.Floor(currentPosition.y) != Math.Floor(nextPosition.y);
} }
return result; return result;
@@ -215,15 +215,11 @@ namespace Marro.PacManUdon
if (IsHorizontal(direction)) if (IsHorizontal(direction))
{ {
result = result || nextPosition.x != currentPosition.x result = Math.Round(currentPosition.x) != Math.Round(nextPosition.x);
&& ((Math.Floor(currentPosition.x) != Math.Floor(nextPosition.x) && nextPosition.x % 1 != 0)
|| currentPosition.x % 1 == 0);
} }
if (IsVertical(direction)) if (!result && IsVertical(direction))
{ {
result = result || nextPosition.y != currentPosition.y result = Math.Round(currentPosition.y) != Math.Round(nextPosition.y);
&& ((Math.Floor(currentPosition.y) != Math.Floor(nextPosition.y) && nextPosition.y % 1 != 0)
|| currentPosition.y % 1 == 0);
} }
return result; return result;
} }

View File

@@ -120,6 +120,11 @@ namespace Marro.PacManUdon
} }
} }
if (CrossesTileBorder(position, nextPosition, direction))
{
CheckNewTile(position, nextPosition);
}
SetPosition(nextPosition); SetPosition(nextPosition);
} }
@@ -207,6 +212,20 @@ namespace Marro.PacManUdon
return nextPosition; return nextPosition;
} }
private void CheckNewTile(Vector2 position, Vector2 nextPosition)
{
var pellet = pelletManager.EatAtTile(position, nextPosition);
if (pellet == PelletType.Pellet)
{
freezeSeconds = 0.0166666666666667f;
}
else if (pellet == PelletType.PowerPellet)
{
freezeSeconds = freezeSeconds = 0.05f;
}
}
protected override void UpdateAnimator() protected override void UpdateAnimator()
{ {
// Debug.Log($"{gameObject} UpdateAnimator with direction {direction}, dead {dead}, frozen {frozen}"); // Debug.Log($"{gameObject} UpdateAnimator with direction {direction}, dead {dead}, frozen {frozen}");
@@ -322,29 +341,6 @@ namespace Marro.PacManUdon
UpdateAnimator(); UpdateAnimator();
} }
void OnTriggerEnter(Collider other)
{
Pellet pellet = other.gameObject.GetComponent<Pellet>();
if (pellet)
{
if (pellet.isPowerPellet)
{
gameManager.GotPowerPellet(pellet);
freezeSeconds = 0.05f;
}
else
{
gameManager.GotPellet(pellet);
freezeSeconds = 0.0166666666666667f;
}
return;
}
else if (other.gameObject.GetComponent<BonusFruit>())
{
gameManager.GotFruit();
}
}
public override void CollectSyncedData(byte[] data, ref int index, NetworkEventType eventType) public override void CollectSyncedData(byte[] data, ref int index, NetworkEventType eventType)
{ {
if (eventType != NetworkEventType.PacManTurn) if (eventType != NetworkEventType.PacManTurn)

View File

@@ -50,12 +50,19 @@ namespace Marro.PacManUdon
Intermission3 Intermission3
} }
public enum PacManTileType public enum PacManCollisionType
{ {
Empty = -1, Empty = -1,
Wall = -2, Wall = -2,
} }
public enum PacManConsumableType
{
None = -1,
FruitLeft = -2,
FruitRight = -3,
}
public static class PacManConstants public static class PacManConstants
{ {
// Jagged or 2D arrays can't be static so we work with 1D arrays // Jagged or 2D arrays can't be static so we work with 1D arrays
@@ -97,25 +104,25 @@ namespace Marro.PacManUdon
public static int[] GetMazePelletMap() => new int[] public static int[] GetMazePelletMap() => new int[]
{ {
-01, -01, -01, -01, -01, -01, -01, -01, -01, -01, -01, -01, -01, -01, -01, -01, -01, -01, -01, -01, -01, -01, -01, -01, -01, -01, -01, -01, -01, -01, -01, -01, -01, -01, -01, -01, -01, -01, -01, -01, -01, -01, -01, -01, -01, -01, -01, -01, -01, -01, -01, -01, -01, -01, -01, -01,
-01, 216, 215, 214, 213, 212, 196, 195, 194, 193, 192, 191, 190, -01, -01, 178, 179, 180, 181, 182, 183, 152, 151, 150, 149, 148, 147, -01, -01, 215, 214, 213, 212, 211, 195, 194, 193, 192, 191, 190, 189, -01, -01, 177, 178, 179, 180, 181, 182, 151, 150, 149, 148, 147, 146, -01,
-01, 217, -01, -01, -01, -01, 197, -01, -01, -01, -01, -01, 189, -01, -01, 177, -01, -01, -01, -01, -01, 153, -01, -01, -01, -01, 146, -01, -01, 216, -01, -01, -01, -01, 196, -01, -01, -01, -01, -01, 188, -01, -01, 176, -01, -01, -01, -01, -01, 152, -01, -01, -01, -01, 145, -01,
-01, 003, -01, -01, -01, -01, 198, -01, -01, -01, -01, -01, 188, -01, -01, 176, -01, -01, -01, -01, -01, 154, -01, -01, -01, -01, 002, -01, -01, 003, -01, -01, -01, -01, 197, -01, -01, -01, -01, -01, 187, -01, -01, 175, -01, -01, -01, -01, -01, 153, -01, -01, -01, -01, 002, -01,
-01, 218, -01, -01, -01, -01, 199, -01, -01, -01, -01, -01, 187, -01, -01, 175, -01, -01, -01, -01, -01, 155, -01, -01, -01, -01, 145, -01, -01, 217, -01, -01, -01, -01, 198, -01, -01, -01, -01, -01, 186, -01, -01, 174, -01, -01, -01, -01, -01, 154, -01, -01, -01, -01, 144, -01,
-01, 219, 220, 221, 222, 223, 200, 201, 202, 203, 204, 205, 186, 185, 184, 174, 173, 172, 165, 164, 163, 156, 157, 158, 159, 160, 144, -01, -01, 218, 219, 220, 221, 222, 199, 200, 201, 202, 203, 204, 185, 184, 183, 173, 172, 171, 164, 163, 162, 155, 156, 157, 158, 159, 143, -01,
-01, 224, -01, -01, -01, -01, 231, -01, -01, 206, -01, -01, -01, -01, -01, -01, -01, -01, 166, -01, -01, 161, -01, -01, -01, -01, 143, -01, -01, 223, -01, -01, -01, -01, 230, -01, -01, 205, -01, -01, -01, -01, -01, -01, -01, -01, 165, -01, -01, 160, -01, -01, -01, -01, 142, -01,
-01, 225, -01, -01, -01, -01, 232, -01, -01, 207, -01, -01, -01, -01, -01, -01, -01, -01, 167, -01, -01, 162, -01, -01, -01, -01, 142, -01, -01, 224, -01, -01, -01, -01, 231, -01, -01, 206, -01, -01, -01, -01, -01, -01, -01, -01, 166, -01, -01, 161, -01, -01, -01, -01, 141, -01,
-01, 226, 227, 228, 229, 230, 233, -01, -01, 208, 209, 210, 211, -01, -01, 171, 170, 169, 168, -01, -01, 136, 137, 138, 139, 140, 141, -01, -01, 225, 226, 227, 228, 229, 232, -01, -01, 207, 208, 209, 210, -01, -01, 170, 169, 168, 167, -01, -01, 135, 136, 137, 138, 139, 140, -01,
-01, -01, -01, -01, -01, -01, 234, -01, -01, -01, -01, -01, -01, -01, -01, -01, -01, -01, -01, -01, -01, 134, -01, -01, -01, -01, -01, -01, -01, -01, -01, -01, -01, -01, 233, -01, -01, -01, -01, -01, -01, -01, -01, -01, -01, -01, -01, -01, -01, 134, -01, -01, -01, -01, -01, -01,
-01, -01, -01, -01, -01, -01, 235, -01, -01, -01, -01, -01, -01, -01, -01, -01, -01, -01, -01, -01, -01, 133, -01, -01, -01, -01, -01, -01, -01, -01, -01, -01, -01, -01, 234, -01, -01, -01, -01, -01, -01, -01, -01, -01, -01, -01, -01, -01, -01, 133, -01, -01, -01, -01, -01, -01,
-01, -01, -01, -01, -01, -01, 236, -01, -01, -01, -01, -01, -01, -01, -01, -01, -01, -01, -01, -01, -01, 132, -01, -01, -01, -01, -01, -01, -01, -01, -01, -01, -01, -01, 235, -01, -01, -01, -01, -01, -01, -01, -01, -01, -01, -01, -01, -01, -01, 132, -01, -01, -01, -01, -01, -01,
-01, -01, -01, -01, -01, -01, 237, -01, -01, -01, -01, -01, -01, -01, -01, -01, -01, -01, -01, -01, -01, 131, -01, -01, -01, -01, -01, -01, -01, -01, -01, -01, -01, -01, 236, -01, -01, -01, -01, -01, -01, -01, -01, -01, -01, -01, -01, -01, -01, 131, -01, -01, -01, -01, -01, -01,
-01, -01, -01, -01, -01, -01, 238, -01, -01, -01, -01, -01, -01, -01, -01, -01, -01, -01, -01, -01, -01, 130, -01, -01, -01, -01, -01, -01, -01, -01, -01, -01, -01, -01, 237, -01, -01, -01, -01, -01, -01, -01, -01, -01, -01, -01, -01, -01, -01, 130, -01, -01, -01, -01, -01, -01,
-01, -01, -01, -01, -01, -01, 239, -01, -01, -01, -01, -01, -01, -01, -01, -01, -01, -01, -01, -01, -01, 129, -01, -01, -01, -01, -01, -01, -01, -01, -01, -01, -01, -01, 238, -01, -01, -01, -01, -01, -01, -01, -01, -01, -01, -01, -01, -01, -01, 129, -01, -01, -01, -01, -01, -01,
-01, -01, -01, -01, -01, -01, 240, -01, -01, -01, -01, -01, -01, -01, -01, -01, -01, -01, -01, -01, -01, 128, -01, -01, -01, -01, -01, -01, -01, -01, -01, -01, -01, -01, 239, -01, -01, -01, -01, -01, -01, -01, -01, -01, -01, -01, -01, -01, -01, 128, -01, -01, -01, -01, -01, -01,
-01, -01, -01, -01, -01, -01, 241, -01, -01, -01, -01, -01, -01, -01, -01, -01, -01, -01, -01, -01, -01, 127, -01, -01, -01, -01, -01, -01, -01, -01, -01, -01, -01, -01, 240, -01, -01, -01, -01, -01, -01, -01, -01, -01, -01, -01, -01, -01, -01, 127, -01, -01, -01, -01, -01, -01,
-01, -01, -01, -01, -01, -01, 242, -01, -01, -01, -01, -01, -01, -01, -01, -01, -01, -01, -01, -01, -01, 126, -01, -01, -01, -01, -01, -01, -01, -01, -01, -01, -01, -01, 241, -01, -01, -01, -01, -01, -01, -02, -03, -01, -01, -01, -01, -01, -01, 126, -01, -01, -01, -01, -01, -01,
-01, -01, -01, -01, -01, -01, 243, -01, -01, -01, -01, -01, -01, -01, -01, -01, -01, -01, -01, -01, -01, 125, -01, -01, -01, -01, -01, -01, -01, -01, -01, -01, -01, -01, 242, -01, -01, -01, -01, -01, -01, -01, -01, -01, -01, -01, -01, -01, -01, 125, -01, -01, -01, -01, -01, -01,
-01, -01, -01, -01, -01, -01, 244, -01, -01, -01, -01, -01, -01, -01, -01, -01, -01, -01, -01, -01, -01, 124, -01, -01, -01, -01, -01, -01, -01, -01, -01, -01, -01, -01, 243, -01, -01, -01, -01, -01, -01, -01, -01, -01, -01, -01, -01, -01, -01, 124, -01, -01, -01, -01, -01, -01,
-01, 086, 087, 088, 089, 090, 091, 094, 095, 096, 097, 098, 099, -01, -01, 104, 105, 106, 107, 108, 109, 110, 123, 122, 121, 120, 119, -01, -01, 086, 087, 088, 089, 090, 091, 094, 095, 096, 097, 098, 099, -01, -01, 104, 105, 106, 107, 108, 109, 110, 123, 122, 121, 120, 119, -01,
-01, 085, -01, -01, -01, -01, 092, -01, -01, -01, -01, -01, 100, -01, -01, 103, -01, -01, -01, -01, -01, 111, -01, -01, -01, -01, 118, -01, -01, 085, -01, -01, -01, -01, 092, -01, -01, -01, -01, -01, 100, -01, -01, 103, -01, -01, -01, -01, -01, 111, -01, -01, -01, -01, 118, -01,
-01, 084, -01, -01, -01, -01, 093, -01, -01, -01, -01, -01, 101, -01, -01, 102, -01, -01, -01, -01, -01, 112, -01, -01, -01, -01, 117, -01, -01, 084, -01, -01, -01, -01, 093, -01, -01, -01, -01, -01, 101, -01, -01, 102, -01, -01, -01, -01, -01, 112, -01, -01, -01, -01, 117, -01,
@@ -139,14 +146,14 @@ namespace Marro.PacManUdon
703, 675, 647, 646, 617, 589, 561, 562, 563, 564, 565, 566, 594, 622, 567, 568, 703, 675, 647, 646, 617, 589, 561, 562, 563, 564, 565, 566, 594, 622, 567, 568,
569, 570, 571, 572, 600, 628, 631, 603, 575, 576, 577, 578, 579, 580, 581, 609, 569, 570, 571, 572, 600, 628, 631, 603, 575, 576, 577, 578, 579, 580, 581, 609,
637, 724, 696, 668, 669, 642, 614, 586, 585, 584, 583, 582, 553, 525, 497, 469, 637, 724, 696, 668, 669, 642, 614, 586, 585, 584, 583, 582, 553, 525, 497, 469,
441, 413, 385, 357, 329, 301, 273, 245, 245, 246, 247, 248, 249, 250, 222, 194, 441, 413, 385, 357, 329, 301, 273, 245, 246, 247, 248, 249, 250, 222, 194, 166,
166, 138, 082, 054, 053, 052, 051, 050, 049, 077, 105, 133, 161, 162, 163, 164, 138, 082, 054, 053, 052, 051, 050, 049, 077, 105, 133, 161, 162, 163, 164, 165,
165, 189, 217, 160, 159, 158, 186, 214, 242, 241, 240, 239, 157, 156, 155, 127, 189, 217, 160, 159, 158, 186, 214, 242, 241, 240, 239, 157, 156, 155, 127, 099,
099, 071, 043, 044, 045, 046, 047, 048, 154, 153, 152, 124, 096, 068, 040, 039, 071, 043, 044, 045, 046, 047, 048, 154, 153, 152, 124, 096, 068, 040, 039, 038,
038, 037, 036, 035, 034, 062, 090, 118, 146, 147, 148, 149, 150, 151, 177, 205, 037, 036, 035, 034, 062, 090, 118, 146, 147, 148, 149, 150, 151, 177, 205, 233,
233, 234, 235, 236, 033, 032, 031, 030, 029, 057, 113, 141, 142, 143, 144, 145, 234, 235, 236, 033, 032, 031, 030, 029, 057, 113, 141, 142, 143, 144, 145, 169,
169, 197, 225, 226, 227, 228, 229, 174, 202, 230, 258, 286, 314, 342, 370, 398, 197, 225, 226, 227, 228, 229, 174, 202, 230, 258, 286, 314, 342, 370, 398, 426,
426, 454, 482, 510, 538, 454, 482, 510, 538,
}; };
public static GameObject[] ComponentsToGameObjects(Component[] components, bool skipFirstComponent = false) public static GameObject[] ComponentsToGameObjects(Component[] components, bool skipFirstComponent = false)

View File

@@ -43,7 +43,7 @@ MonoBehaviour:
Data: Data:
- Name: - Name:
Entry: 12 Entry: 12
Data: 10 Data: 13
- Name: - Name:
Entry: 7 Entry: 7
Data: Data:
@@ -163,16 +163,124 @@ MonoBehaviour:
Data: Data:
- Name: $k - Name: $k
Entry: 1 Entry: 1
Data: pellets Data: gameManager
- Name: $v - Name: $v
Entry: 7 Entry: 7
Data: 9|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor Data: 9|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
- Name: <Name>k__BackingField - Name: <Name>k__BackingField
Entry: 1 Entry: 1
Data: pellets Data: gameManager
- Name: <UserType>k__BackingField - Name: <UserType>k__BackingField
Entry: 7 Entry: 7
Data: 10|System.RuntimeType, mscorlib Data: 10|System.RuntimeType, mscorlib
- Name:
Entry: 1
Data: Marro.PacManUdon.GameManager, Assembly-CSharp
- Name:
Entry: 8
Data:
- Name: <SystemType>k__BackingField
Entry: 9
Data: 4
- 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: 11|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: bonusFruit
- Name: $v
Entry: 7
Data: 12|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
- Name: <Name>k__BackingField
Entry: 1
Data: bonusFruit
- Name: <UserType>k__BackingField
Entry: 7
Data: 13|System.RuntimeType, mscorlib
- Name:
Entry: 1
Data: Marro.PacManUdon.BonusFruit, Assembly-CSharp
- Name:
Entry: 8
Data:
- Name: <SystemType>k__BackingField
Entry: 9
Data: 4
- 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: 14|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: pellets
- Name: $v
Entry: 7
Data: 15|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
- Name: <Name>k__BackingField
Entry: 1
Data: pellets
- Name: <UserType>k__BackingField
Entry: 7
Data: 16|System.RuntimeType, mscorlib
- Name: - Name:
Entry: 1 Entry: 1
Data: Marro.PacManUdon.Pellet[], Assembly-CSharp Data: Marro.PacManUdon.Pellet[], Assembly-CSharp
@@ -181,7 +289,7 @@ MonoBehaviour:
Data: Data:
- Name: <SystemType>k__BackingField - Name: <SystemType>k__BackingField
Entry: 7 Entry: 7
Data: 11|System.RuntimeType, mscorlib Data: 17|System.RuntimeType, mscorlib
- Name: - Name:
Entry: 1 Entry: 1
Data: UnityEngine.Component[], UnityEngine.CoreModule Data: UnityEngine.Component[], UnityEngine.CoreModule
@@ -200,114 +308,6 @@ MonoBehaviour:
- Name: <IsSerialized>k__BackingField - Name: <IsSerialized>k__BackingField
Entry: 5 Entry: 5
Data: false Data: false
- Name: _fieldAttributes
Entry: 7
Data: 12|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: powerPellets
- Name: $v
Entry: 7
Data: 13|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
- Name: <Name>k__BackingField
Entry: 1
Data: powerPellets
- Name: <UserType>k__BackingField
Entry: 7
Data: 14|System.RuntimeType, mscorlib
- Name:
Entry: 1
Data: UnityEngine.Animator[], UnityEngine.AnimationModule
- Name:
Entry: 8
Data:
- Name: <SystemType>k__BackingField
Entry: 9
Data: 14
- 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: 15|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: powerPelletBlinkEnabled
- Name: $v
Entry: 7
Data: 16|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
- Name: <Name>k__BackingField
Entry: 1
Data: powerPelletBlinkEnabled
- Name: <UserType>k__BackingField
Entry: 7
Data: 17|System.RuntimeType, mscorlib
- Name:
Entry: 1
Data: System.Boolean, mscorlib
- Name:
Entry: 8
Data:
- Name: <SystemType>k__BackingField
Entry: 9
Data: 17
- 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 - Name: _fieldAttributes
Entry: 7 Entry: 7
Data: 18|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib Data: 18|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib
@@ -331,19 +331,19 @@ MonoBehaviour:
Data: Data:
- Name: $k - Name: $k
Entry: 1 Entry: 1
Data: powerPelletBlinkToggleInterval Data: powerPellets
- Name: $v - Name: $v
Entry: 7 Entry: 7
Data: 19|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor Data: 19|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
- Name: <Name>k__BackingField - Name: <Name>k__BackingField
Entry: 1 Entry: 1
Data: powerPelletBlinkToggleInterval Data: powerPellets
- Name: <UserType>k__BackingField - Name: <UserType>k__BackingField
Entry: 7 Entry: 7
Data: 20|System.RuntimeType, mscorlib Data: 20|System.RuntimeType, mscorlib
- Name: - Name:
Entry: 1 Entry: 1
Data: System.Single, mscorlib Data: UnityEngine.Animator[], UnityEngine.AnimationModule
- Name: - Name:
Entry: 8 Entry: 8
Data: Data:
@@ -385,19 +385,127 @@ MonoBehaviour:
Data: Data:
- Name: $k - Name: $k
Entry: 1 Entry: 1
Data: powerPelletBlinkProgress Data: powerPelletBlinkEnabled
- Name: $v - Name: $v
Entry: 7 Entry: 7
Data: 22|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor Data: 22|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
- Name: <Name>k__BackingField
Entry: 1
Data: powerPelletBlinkEnabled
- Name: <UserType>k__BackingField
Entry: 7
Data: 23|System.RuntimeType, mscorlib
- Name:
Entry: 1
Data: System.Boolean, mscorlib
- Name:
Entry: 8
Data:
- Name: <SystemType>k__BackingField
Entry: 9
Data: 23
- 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: 24|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: powerPelletBlinkToggleInterval
- Name: $v
Entry: 7
Data: 25|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
- Name: <Name>k__BackingField
Entry: 1
Data: powerPelletBlinkToggleInterval
- Name: <UserType>k__BackingField
Entry: 7
Data: 26|System.RuntimeType, mscorlib
- Name:
Entry: 1
Data: System.Single, mscorlib
- Name:
Entry: 8
Data:
- Name: <SystemType>k__BackingField
Entry: 9
Data: 26
- 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: 27|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: powerPelletBlinkProgress
- Name: $v
Entry: 7
Data: 28|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
- Name: <Name>k__BackingField - Name: <Name>k__BackingField
Entry: 1 Entry: 1
Data: powerPelletBlinkProgress Data: powerPelletBlinkProgress
- Name: <UserType>k__BackingField - Name: <UserType>k__BackingField
Entry: 9 Entry: 9
Data: 20 Data: 26
- Name: <SystemType>k__BackingField - Name: <SystemType>k__BackingField
Entry: 9 Entry: 9
Data: 20 Data: 26
- 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
@@ -412,7 +520,7 @@ MonoBehaviour:
Data: false Data: false
- Name: _fieldAttributes - Name: _fieldAttributes
Entry: 7 Entry: 7
Data: 23|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib Data: 29|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib
- Name: - Name:
Entry: 12 Entry: 12
Data: 0 Data: 0
@@ -436,124 +544,16 @@ MonoBehaviour:
Data: powerPelletBlinkCurrentlyVisible Data: powerPelletBlinkCurrentlyVisible
- Name: $v - Name: $v
Entry: 7 Entry: 7
Data: 24|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor Data: 30|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
- Name: <Name>k__BackingField - Name: <Name>k__BackingField
Entry: 1 Entry: 1
Data: powerPelletBlinkCurrentlyVisible Data: powerPelletBlinkCurrentlyVisible
- Name: <UserType>k__BackingField - Name: <UserType>k__BackingField
Entry: 9 Entry: 9
Data: 17 Data: 23
- Name: <SystemType>k__BackingField - Name: <SystemType>k__BackingField
Entry: 9 Entry: 9
Data: 17 Data: 23
- 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: 25|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: syncedPelletsCollected
- Name: $v
Entry: 7
Data: 26|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
- Name: <Name>k__BackingField
Entry: 1
Data: syncedPelletsCollected
- Name: <UserType>k__BackingField
Entry: 7
Data: 27|System.RuntimeType, mscorlib
- Name:
Entry: 1
Data: System.Byte[], mscorlib
- Name:
Entry: 8
Data:
- Name: <SystemType>k__BackingField
Entry: 9
Data: 27
- 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: 28|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: collisionMap
- Name: $v
Entry: 7
Data: 29|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
- Name: <Name>k__BackingField
Entry: 1
Data: collisionMap
- Name: <UserType>k__BackingField
Entry: 7
Data: 30|System.RuntimeType, mscorlib
- Name:
Entry: 1
Data: System.Int32[], mscorlib
- Name:
Entry: 8
Data:
- Name: <SystemType>k__BackingField
Entry: 9
Data: 30
- 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
@@ -584,6 +584,162 @@ MonoBehaviour:
- Name: - Name:
Entry: 8 Entry: 8
Data: Data:
- Name:
Entry: 7
Data:
- Name: $k
Entry: 1
Data: syncedPelletsCollected
- Name: $v
Entry: 7
Data: 32|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
- Name: <Name>k__BackingField
Entry: 1
Data: syncedPelletsCollected
- Name: <UserType>k__BackingField
Entry: 7
Data: 33|System.RuntimeType, mscorlib
- Name:
Entry: 1
Data: System.Byte[], mscorlib
- Name:
Entry: 8
Data:
- Name: <SystemType>k__BackingField
Entry: 9
Data: 33
- 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: 34|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: collisionMap
- Name: $v
Entry: 7
Data: 35|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
- Name: <Name>k__BackingField
Entry: 1
Data: collisionMap
- Name: <UserType>k__BackingField
Entry: 7
Data: 36|System.RuntimeType, mscorlib
- Name:
Entry: 1
Data: System.Int32[], mscorlib
- Name:
Entry: 8
Data:
- Name: <SystemType>k__BackingField
Entry: 9
Data: 36
- 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: 37|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: pelletMap
- Name: $v
Entry: 7
Data: 38|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
- Name: <Name>k__BackingField
Entry: 1
Data: pelletMap
- Name: <UserType>k__BackingField
Entry: 9
Data: 36
- Name: <SystemType>k__BackingField
Entry: 9
Data: 36
- 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: 39|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: - Name:
Entry: 13 Entry: 13
Data: Data:

View File

@@ -3,11 +3,20 @@ using UnityEngine;
namespace Marro.PacManUdon namespace Marro.PacManUdon
{ {
enum PelletType
{
None,
Pellet,
PowerPellet
}
public class PelletManager : SyncedObject public class PelletManager : SyncedObject
{ {
public int PelletCount => pellets.Length; public int PelletCount => pellets.Length;
public int PelletCollectedCount { get; private set; } public int PelletCollectedCount { get; private set; }
private GameManager gameManager;
private BonusFruit bonusFruit;
Pellet[] pellets; Pellet[] pellets;
Animator[] powerPellets; Animator[] powerPellets;
@@ -19,12 +28,16 @@ namespace Marro.PacManUdon
byte[] syncedPelletsCollected; byte[] syncedPelletsCollected;
int[] collisionMap; int[] collisionMap;
int[] pelletMap;
const int mazeWidth = 28; const int mazeWidth = 28;
const int mazeHeight = 31; const int mazeHeight = 31;
public void Initialize() public void Initialize(GameManager gameManager, BonusFruit bonusFruit)
{ {
this.gameManager = gameManager;
this.bonusFruit = bonusFruit;
gameObject.SetActive(true); gameObject.SetActive(true);
pellets = GetComponentsInChildren<Pellet>(includeInactive: true); pellets = GetComponentsInChildren<Pellet>(includeInactive: true);
@@ -32,6 +45,8 @@ namespace Marro.PacManUdon
powerPelletBlinkToggleInterval = PacManConstants.GetPowerPelletBlinkToggleInterval(); powerPelletBlinkToggleInterval = PacManConstants.GetPowerPelletBlinkToggleInterval();
SetPowerPelletsBlink(false); SetPowerPelletsBlink(false);
collisionMap = PacManConstants.GetMazeCollisionInfo();
RestoreAllPellets(); RestoreAllPellets();
SubscribeToEvent(NetworkEventType.SyncPellets); SubscribeToEvent(NetworkEventType.SyncPellets);
@@ -83,10 +98,40 @@ namespace Marro.PacManUdon
#region Collision #region Collision
public bool IsWallUpcoming(Vector2 position, Vector2 directionVector) public bool IsWallUpcoming(Vector2 position, Vector2 directionVector)
{ {
var result = GetTileAt(position + directionVector) == (int)PacManTileType.Wall; var result = GetTileAt(position + directionVector) == (int)PacManCollisionType.Wall;
return result; return result;
} }
internal PelletType EatAtTile(Vector2 position, Vector2 nextPosition)
{
var tilemapIndex = GetTilemapIndex(nextPosition);
var tile = pelletMap[tilemapIndex];
TryCollectFruit(tile, position, nextPosition);
return TryCollectPellet(tile, tilemapIndex);
}
private void TryCollectFruit(int tile, Vector2 position, Vector2 nextPosition)
{
if (tile != (int)PacManConsumableType.FruitLeft && tile != (int)PacManConsumableType.FruitRight
|| !bonusFruit.Active)
{
return;
}
var previousTile = pelletMap[GetTilemapIndex(position)];
Debug.Log($"On fruit tile {tile}, previous tile was {previousTile}. Position {position}, nextPosition {nextPosition}");
if (tile == (int)PacManConsumableType.FruitLeft && previousTile == (int)PacManConsumableType.FruitRight
|| tile == (int)PacManConsumableType.FruitRight && previousTile == (int)PacManConsumableType.FruitLeft)
{
Debug.Log("Collecting fruit");
gameManager.GotFruit();
}
}
public int GetAvailableDirections(Vector2 position) public int GetAvailableDirections(Vector2 position)
{ {
var directions = GetTileAt(position); var directions = GetTileAt(position);
@@ -101,7 +146,7 @@ namespace Marro.PacManUdon
private int GetTileAt(Vector2 position) => collisionMap[GetTilemapIndex(position)]; private int GetTileAt(Vector2 position) => collisionMap[GetTilemapIndex(position)];
private int GetTilemapIndex(Vector2 position) internal static int GetTilemapIndex(Vector2 position)
{ {
position = Clamp(position, 0, mazeWidth - 1, 1 - mazeHeight, 0); position = Clamp(position, 0, mazeWidth - 1, 1 - mazeHeight, 0);
var index = (int)(position.x + 0.5) - (int)(position.y - 0.5) * mazeWidth; var index = (int)(position.x + 0.5) - (int)(position.y - 0.5) * mazeWidth;
@@ -110,8 +155,16 @@ namespace Marro.PacManUdon
#endregion #endregion
#region Pellet collecting #region Pellet collecting
public int PelletCollected(Pellet pellet) private PelletType TryCollectPellet(int tile, int tilemapIndex)
{ {
if (tile < 0 || tile >= pellets.Length)
{
return PelletType.None;
}
pelletMap[tilemapIndex] = -1;
var pellet = pellets[tile];
pellet.gameObject.SetActive(false); pellet.gameObject.SetActive(false);
var index = pellet.transform.GetSiblingIndex(); var index = pellet.transform.GetSiblingIndex();
@@ -119,7 +172,11 @@ namespace Marro.PacManUdon
PelletCollectedCount++; PelletCollectedCount++;
return PelletCollectedCount; var pelletType = pellet.isPowerPellet ? PelletType.PowerPellet : PelletType.Pellet;
gameManager.GotPellet(pellet, pelletType, PelletCollectedCount, PelletCount - PelletCollectedCount);
return pelletType;
} }
public int RestoreAllPellets() public int RestoreAllPellets()
@@ -132,7 +189,7 @@ namespace Marro.PacManUdon
syncedPelletsCollected = new byte[pellets.Length/8 + 1]; syncedPelletsCollected = new byte[pellets.Length/8 + 1];
PelletCollectedCount = 0; PelletCollectedCount = 0;
collisionMap = PacManConstants.GetMazeCollisionInfo(); pelletMap = PacManConstants.GetMazePelletMap();
return PelletCount; return PelletCount;
} }

View File

@@ -16,7 +16,7 @@ namespace Marro.PacManUdon
// Initialize // Initialize
soundManager.SuppressSound(true); soundManager.SuppressSound(true);
attractScreen.gameObject.SetActive(true); attractScreen.gameObject.SetActive(true);
attractScreen.Initialize(); attractScreen.Initialize(this, bonusFruit);
for (int i = 0; i <= 15; i++) for (int i = 0; i <= 15; i++)
{ {
// Debug.Log($"{gameObject} TimeSequenceAttractScreen deactivating with iteration i"); // Debug.Log($"{gameObject} TimeSequenceAttractScreen deactivating with iteration i");

View File

@@ -41,6 +41,54 @@ MonoBehaviour:
- Name: - Name:
Entry: 8 Entry: 8
Data: Data:
- Name:
Entry: 12
Data: 2
- Name:
Entry: 7
Data:
- Name: $k
Entry: 1
Data: bonusFruit
- Name: $v
Entry: 7
Data: 2|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
- Name: <Name>k__BackingField
Entry: 1
Data: bonusFruit
- Name: <UserType>k__BackingField
Entry: 7
Data: 3|System.RuntimeType, mscorlib
- Name:
Entry: 1
Data: Marro.PacManUdon.BonusFruit, Assembly-CSharp
- Name:
Entry: 8
Data:
- Name: <SystemType>k__BackingField
Entry: 7
Data: 4|System.RuntimeType, mscorlib
- Name:
Entry: 1
Data: VRC.Udon.UdonBehaviour, VRC.Udon
- Name:
Entry: 8
Data:
- 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: true
- Name: _fieldAttributes
Entry: 7
Data: 5|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib
- Name: - Name:
Entry: 12 Entry: 12
Data: 0 Data: 0
@@ -50,3 +98,69 @@ MonoBehaviour:
- Name: - Name:
Entry: 8 Entry: 8
Data: Data:
- Name:
Entry: 8
Data:
- Name:
Entry: 8
Data:
- Name:
Entry: 7
Data:
- Name: $k
Entry: 1
Data: pelletManager
- Name: $v
Entry: 7
Data: 6|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
- Name: <Name>k__BackingField
Entry: 1
Data: pelletManager
- Name: <UserType>k__BackingField
Entry: 7
Data: 7|System.RuntimeType, mscorlib
- Name:
Entry: 1
Data: Marro.PacManUdon.PelletManager, Assembly-CSharp
- Name:
Entry: 8
Data:
- Name: <SystemType>k__BackingField
Entry: 9
Data: 4
- 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: true
- Name: _fieldAttributes
Entry: 7
Data: 8|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:
- Name:
Entry: 8
Data:

View File

@@ -2,11 +2,15 @@
using Marro.PacManUdon; using Marro.PacManUdon;
using UdonSharp; using UdonSharp;
using UnityEngine; using UnityEngine;
using UnityEngine.UIElements;
using VRC.SDKBase; using VRC.SDKBase;
using VRC.Udon; using VRC.Udon;
public class MazeDefinitionGenerator : UdonSharpBehaviour public class MazeDefinitionGenerator : UdonSharpBehaviour
{ {
public BonusFruit bonusFruit;
public PelletManager pelletManager;
void Start() void Start()
{ {
PrintPelletMap(); PrintPelletMap();
@@ -18,7 +22,7 @@ public class MazeDefinitionGenerator : UdonSharpBehaviour
var width = 28; var width = 28;
var height = 31; var height = 31;
var pellets = GetComponentsInChildren<Pellet>(includeInactive: true); var pellets = pelletManager.gameObject.GetComponentsInChildren<Pellet>(includeInactive: true);
int[] map = new int[width * height]; int[] map = new int[width * height];
int[] pelletLocations = new int[pellets.Length]; int[] pelletLocations = new int[pellets.Length];
@@ -37,10 +41,21 @@ public class MazeDefinitionGenerator : UdonSharpBehaviour
pelletLocations[i] = index; pelletLocations[i] = index;
} }
WriteBonusFruitTiles(map);
PrintMap(map, width); PrintMap(map, width);
PrintMap(pelletLocations, 16); PrintMap(pelletLocations, 16);
} }
private void WriteBonusFruitTiles(int[] map)
{
var position = bonusFruit.transform.localPosition;
var leftTileIndex = PelletManager.GetTilemapIndex(new Vector2(position.x - 0.5f, position.y));
map[leftTileIndex] = (int)PacManConsumableType.FruitLeft;
var rightTileIndex = PelletManager.GetTilemapIndex(new Vector2(position.x + 0.5f, position.y));
map[rightTileIndex] = (int)PacManConsumableType.FruitRight;
}
private void PrintMazeMap() private void PrintMazeMap()
{ {
var width = 28; var width = 28;
@@ -53,7 +68,7 @@ public class MazeDefinitionGenerator : UdonSharpBehaviour
{ {
if (collisionMap[i]) if (collisionMap[i])
{ {
map[i] = (int)PacManTileType.Wall; map[i] = (int)PacManCollisionType.Wall;
continue; continue;
} }
@@ -90,12 +105,12 @@ public class MazeDefinitionGenerator : UdonSharpBehaviour
if (totalAvailableDirections < 2) if (totalAvailableDirections < 2)
{ {
return (int)PacManTileType.Empty; return (int)PacManCollisionType.Empty;
} }
if (availableDirections == 0b0011 || availableDirections == 0b1100) if (availableDirections == 0b0011 || availableDirections == 0b1100)
{ {
return (int)PacManTileType.Empty; return (int)PacManCollisionType.Empty;
} }
return availableDirections; return availableDirections;