Fixed ghost caught queue
This commit is contained in:
@@ -43,7 +43,7 @@ MonoBehaviour:
|
||||
Data:
|
||||
- Name:
|
||||
Entry: 12
|
||||
Data: 16
|
||||
Data: 17
|
||||
- Name:
|
||||
Entry: 7
|
||||
Data:
|
||||
@@ -890,6 +890,54 @@ MonoBehaviour:
|
||||
- Name:
|
||||
Entry: 8
|
||||
Data:
|
||||
- Name:
|
||||
Entry: 7
|
||||
Data:
|
||||
- Name: $k
|
||||
Entry: 1
|
||||
Data: frozen
|
||||
- Name: $v
|
||||
Entry: 7
|
||||
Data: 47|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
|
||||
- Name: <Name>k__BackingField
|
||||
Entry: 1
|
||||
Data: frozen
|
||||
- Name: <UserType>k__BackingField
|
||||
Entry: 9
|
||||
Data: 26
|
||||
- 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: 48|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:
|
||||
|
||||
@@ -38,6 +38,8 @@ namespace Marro.PacManUdon
|
||||
private int[] ghostPositions = new int[4];
|
||||
private int pacManPosition;
|
||||
|
||||
private bool frozen;
|
||||
|
||||
public void Initialize(GameManager gameManager, BonusFruit bonusFruit, Ghost[] ghosts)
|
||||
{
|
||||
this.gameManager = gameManager;
|
||||
@@ -49,13 +51,29 @@ namespace Marro.PacManUdon
|
||||
|
||||
powerPellets = GetComponentsInChildren<Animator>(true);
|
||||
powerPelletBlinkToggleInterval = PacManConstants.GetPowerPelletBlinkToggleInterval();
|
||||
SetPowerPelletsBlink(false);
|
||||
|
||||
collisionMap = PacManConstants.GetMazeCollisionInfo();
|
||||
|
||||
RestoreAllPellets();
|
||||
|
||||
SubscribeToEvent(NetworkEventType.SyncPellets);
|
||||
|
||||
Reset();
|
||||
}
|
||||
|
||||
public void Reset()
|
||||
{
|
||||
SetPowerPelletsBlink(false);
|
||||
|
||||
RestoreAllPellets();
|
||||
}
|
||||
|
||||
internal void SetFrozen(bool frozen)
|
||||
{
|
||||
this.frozen = frozen;
|
||||
|
||||
if (!frozen)
|
||||
{
|
||||
SetPowerPelletsBlink(true);
|
||||
}
|
||||
}
|
||||
|
||||
#region Collision
|
||||
@@ -74,7 +92,7 @@ namespace Marro.PacManUdon
|
||||
|
||||
ghostPositions[ghostIndex] = tile;
|
||||
|
||||
if (tile == pacManPosition)
|
||||
if (!frozen && tile == pacManPosition)
|
||||
{
|
||||
Debug.Log("Ghost hit PacMan!");
|
||||
ghosts[ghostIndex].HitPacMan();
|
||||
@@ -90,20 +108,28 @@ namespace Marro.PacManUdon
|
||||
|
||||
pacManPosition = tilemapIndex;
|
||||
|
||||
TryEatGhost(tilemapIndex);
|
||||
if (!frozen)
|
||||
{
|
||||
PacManTryEatGhost();
|
||||
}
|
||||
|
||||
TryCollectFruit(tile, position);
|
||||
return TryCollectPellet(tile, tilemapIndex);
|
||||
}
|
||||
|
||||
private void TryEatGhost(int tilemapIndex)
|
||||
internal void PacManTryEatGhost()
|
||||
{
|
||||
for (int i = 0; i < ghosts.Length; i++)
|
||||
{
|
||||
if (ghostPositions[i] == tilemapIndex)
|
||||
if (ghostPositions[i] != pacManPosition)
|
||||
{
|
||||
Debug.Log("PacMan hit ghost!");
|
||||
ghosts[i].HitPacMan();
|
||||
continue;
|
||||
}
|
||||
|
||||
if (ghosts[i].HitPacMan()) // Only one collision may happen at a time
|
||||
{
|
||||
Debug.Log("PacMan hit ghost!");
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -248,6 +274,8 @@ namespace Marro.PacManUdon
|
||||
|
||||
data.Append((byte)PelletCollectedCount, ref index);
|
||||
data.Append(syncedPelletsCollected, ref index);
|
||||
|
||||
data.Append(frozen, ref index);
|
||||
}
|
||||
|
||||
public override bool WriteSyncedData(byte[] data, ref int index, NetworkEventType eventType)
|
||||
@@ -261,6 +289,8 @@ namespace Marro.PacManUdon
|
||||
Array.Copy(data, index, syncedPelletsCollected, 0, syncedPelletsCollected.Length);
|
||||
index += syncedPelletsCollected.Length;
|
||||
SetPelletsCollectedFromSync();
|
||||
|
||||
frozen = data.ReadBool(ref index);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -136,8 +136,6 @@ namespace Marro.PacManUdon
|
||||
{
|
||||
//Debug.Log($"{gameObject} New level started!");
|
||||
|
||||
collisionManager.RestoreAllPellets();
|
||||
|
||||
ghostManager.NewLevel();
|
||||
|
||||
mazeSpriteAnimator.SetBool("Blinking", false);
|
||||
@@ -153,7 +151,7 @@ namespace Marro.PacManUdon
|
||||
pacMan.Reset();
|
||||
bonusFruit.Despawn();
|
||||
soundManager.Reset();
|
||||
collisionManager.SetPowerPelletsBlink(false);
|
||||
collisionManager.Reset();
|
||||
}
|
||||
|
||||
private void PrepareForCutscene()
|
||||
@@ -391,11 +389,7 @@ namespace Marro.PacManUdon
|
||||
pacMan.SetFrozen(frozen);
|
||||
bonusFruit.SetFrozen(frozen);
|
||||
ghostManager.SetFrozen(frozen, ignoreIfCaught: ghostIgnoreIfCaught);
|
||||
|
||||
if (!frozen)
|
||||
{
|
||||
collisionManager.SetPowerPelletsBlink(true);
|
||||
}
|
||||
collisionManager.SetFrozen(frozen);
|
||||
}
|
||||
|
||||
public override void CollectSyncedData(byte[] data, ref int index, NetworkEventType eventType)
|
||||
|
||||
@@ -593,18 +593,23 @@ namespace Marro.PacManUdon
|
||||
}
|
||||
}
|
||||
|
||||
internal void HitPacMan()
|
||||
internal bool HitPacMan()
|
||||
{
|
||||
if (ghostState != PacManGhostState.Normal)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (isScared)
|
||||
{
|
||||
Debug.Log($"{gameObject} was cought!");
|
||||
ghostManager.GhostCaughtQueue(this);
|
||||
}
|
||||
else if (ghostState == PacManGhostState.Normal)
|
||||
{
|
||||
Debug.Log($"{gameObject} cought PacMan!");
|
||||
ghostManager.CapturedPacMan();
|
||||
ghostManager.GhostCaught(this);
|
||||
return true;
|
||||
}
|
||||
|
||||
Debug.Log($"{gameObject} cought PacMan!");
|
||||
ghostManager.CapturedPacMan();
|
||||
return true;
|
||||
}
|
||||
|
||||
public void Caught(int scoreBonus)
|
||||
@@ -695,25 +700,33 @@ namespace Marro.PacManUdon
|
||||
|
||||
public void SetFrozen(bool frozen, bool ignoreIfCaught = false, bool keepAnimating = false)
|
||||
{
|
||||
animator.speed = frozen && !keepAnimating ? 0 : 1; // This would cause issues if the returning sprite was animated, luckily it isn't :)
|
||||
|
||||
if (frozen && !ignoreIfCaught)
|
||||
{
|
||||
frozenState = PacManGhostFrozenState.Frozen;
|
||||
return;
|
||||
}
|
||||
else if (frozen && ignoreIfCaught)
|
||||
|
||||
if (frozen && ignoreIfCaught)
|
||||
{
|
||||
frozenState = PacManGhostFrozenState.FrozenIfNotCaught;
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
var oldFrozenState = frozenState;
|
||||
frozenState = PacManGhostFrozenState.NotFrozen;
|
||||
|
||||
if (oldFrozenState == PacManGhostFrozenState.FrozenIfNotCaught) // Catch animator up after not updating during FrozenIfNotCaught
|
||||
{
|
||||
UpdateAnimator();
|
||||
}
|
||||
var oldFrozenState = frozenState;
|
||||
frozenState = PacManGhostFrozenState.NotFrozen;
|
||||
|
||||
if (oldFrozenState == PacManGhostFrozenState.FrozenIfNotCaught) // Catch animator up after not updating during FrozenIfNotCaught
|
||||
{
|
||||
UpdateAnimator();
|
||||
}
|
||||
|
||||
if (ghostState == PacManGhostState.CaughtScore)
|
||||
{
|
||||
ReturnHome(); // Return home when unfreezing after being caught
|
||||
collisionManager.PacManTryEatGhost(); // We may have skipped collisions while frozen
|
||||
}
|
||||
animator.speed = frozen && !keepAnimating ? 0 : 1; // This would cause issues if the returning sprite was animated, luckily it isn't :)
|
||||
}
|
||||
|
||||
public void SetHousePelletCounterActive(bool active)
|
||||
|
||||
@@ -43,7 +43,7 @@ MonoBehaviour:
|
||||
Data:
|
||||
- Name:
|
||||
Entry: 12
|
||||
Data: 33
|
||||
Data: 32
|
||||
- Name:
|
||||
Entry: 7
|
||||
Data:
|
||||
@@ -1081,64 +1081,10 @@ MonoBehaviour:
|
||||
Data:
|
||||
- Name: $k
|
||||
Entry: 1
|
||||
Data: ghostScaredQueue
|
||||
Data: blinkingActivated
|
||||
- Name: $v
|
||||
Entry: 7
|
||||
Data: 54|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
|
||||
- Name: <Name>k__BackingField
|
||||
Entry: 1
|
||||
Data: ghostScaredQueue
|
||||
- Name: <UserType>k__BackingField
|
||||
Entry: 7
|
||||
Data: 55|System.RuntimeType, mscorlib
|
||||
- Name:
|
||||
Entry: 1
|
||||
Data: VRC.SDK3.Data.DataList, VRCSDK3
|
||||
- Name:
|
||||
Entry: 8
|
||||
Data:
|
||||
- Name: <SystemType>k__BackingField
|
||||
Entry: 9
|
||||
Data: 55
|
||||
- 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: 56|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: blinkingActivated
|
||||
- Name: $v
|
||||
Entry: 7
|
||||
Data: 57|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
|
||||
- Name: <Name>k__BackingField
|
||||
Entry: 1
|
||||
Data: blinkingActivated
|
||||
@@ -1162,7 +1108,7 @@ MonoBehaviour:
|
||||
Data: false
|
||||
- Name: _fieldAttributes
|
||||
Entry: 7
|
||||
Data: 58|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib
|
||||
Data: 55|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib
|
||||
- Name:
|
||||
Entry: 12
|
||||
Data: 0
|
||||
@@ -1186,7 +1132,7 @@ MonoBehaviour:
|
||||
Data: blinkCountdown
|
||||
- Name: $v
|
||||
Entry: 7
|
||||
Data: 59|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
|
||||
Data: 56|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
|
||||
- Name: <Name>k__BackingField
|
||||
Entry: 1
|
||||
Data: blinkCountdown
|
||||
@@ -1210,7 +1156,7 @@ MonoBehaviour:
|
||||
Data: false
|
||||
- Name: _fieldAttributes
|
||||
Entry: 7
|
||||
Data: 60|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib
|
||||
Data: 57|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib
|
||||
- Name:
|
||||
Entry: 12
|
||||
Data: 0
|
||||
@@ -1234,7 +1180,7 @@ MonoBehaviour:
|
||||
Data: blinkCurrentlyWhite
|
||||
- Name: $v
|
||||
Entry: 7
|
||||
Data: 61|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
|
||||
Data: 58|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
|
||||
- Name: <Name>k__BackingField
|
||||
Entry: 1
|
||||
Data: blinkCurrentlyWhite
|
||||
@@ -1258,7 +1204,7 @@ MonoBehaviour:
|
||||
Data: false
|
||||
- Name: _fieldAttributes
|
||||
Entry: 7
|
||||
Data: 62|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib
|
||||
Data: 59|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib
|
||||
- Name:
|
||||
Entry: 12
|
||||
Data: 0
|
||||
@@ -1282,7 +1228,7 @@ MonoBehaviour:
|
||||
Data: scatterCounter
|
||||
- Name: $v
|
||||
Entry: 7
|
||||
Data: 63|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
|
||||
Data: 60|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
|
||||
- Name: <Name>k__BackingField
|
||||
Entry: 1
|
||||
Data: scatterCounter
|
||||
@@ -1306,7 +1252,7 @@ MonoBehaviour:
|
||||
Data: false
|
||||
- Name: _fieldAttributes
|
||||
Entry: 7
|
||||
Data: 64|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib
|
||||
Data: 61|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib
|
||||
- Name:
|
||||
Entry: 12
|
||||
Data: 0
|
||||
@@ -1330,7 +1276,7 @@ MonoBehaviour:
|
||||
Data: scatterPatternIndex
|
||||
- Name: $v
|
||||
Entry: 7
|
||||
Data: 65|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
|
||||
Data: 62|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
|
||||
- Name: <Name>k__BackingField
|
||||
Entry: 1
|
||||
Data: scatterPatternIndex
|
||||
@@ -1354,7 +1300,7 @@ MonoBehaviour:
|
||||
Data: false
|
||||
- Name: _fieldAttributes
|
||||
Entry: 7
|
||||
Data: 66|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib
|
||||
Data: 63|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib
|
||||
- Name:
|
||||
Entry: 12
|
||||
Data: 0
|
||||
@@ -1378,7 +1324,7 @@ MonoBehaviour:
|
||||
Data: elroyLevel
|
||||
- Name: $v
|
||||
Entry: 7
|
||||
Data: 67|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
|
||||
Data: 64|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
|
||||
- Name: <Name>k__BackingField
|
||||
Entry: 1
|
||||
Data: elroyLevel
|
||||
@@ -1402,7 +1348,7 @@ MonoBehaviour:
|
||||
Data: true
|
||||
- Name: _fieldAttributes
|
||||
Entry: 7
|
||||
Data: 68|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib
|
||||
Data: 65|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib
|
||||
- Name:
|
||||
Entry: 12
|
||||
Data: 0
|
||||
@@ -1426,7 +1372,7 @@ MonoBehaviour:
|
||||
Data: sharedPelletCounterActive
|
||||
- Name: $v
|
||||
Entry: 7
|
||||
Data: 69|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
|
||||
Data: 66|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
|
||||
- Name: <Name>k__BackingField
|
||||
Entry: 1
|
||||
Data: sharedPelletCounterActive
|
||||
@@ -1450,7 +1396,7 @@ MonoBehaviour:
|
||||
Data: false
|
||||
- Name: _fieldAttributes
|
||||
Entry: 7
|
||||
Data: 70|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib
|
||||
Data: 67|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib
|
||||
- Name:
|
||||
Entry: 12
|
||||
Data: 0
|
||||
@@ -1474,7 +1420,7 @@ MonoBehaviour:
|
||||
Data: sharedPelletCounter
|
||||
- Name: $v
|
||||
Entry: 7
|
||||
Data: 71|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
|
||||
Data: 68|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
|
||||
- Name: <Name>k__BackingField
|
||||
Entry: 1
|
||||
Data: sharedPelletCounter
|
||||
@@ -1496,6 +1442,60 @@ MonoBehaviour:
|
||||
- Name: <IsSerialized>k__BackingField
|
||||
Entry: 5
|
||||
Data: false
|
||||
- Name: _fieldAttributes
|
||||
Entry: 7
|
||||
Data: 69|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: sharedPelletCounterReleaseValues
|
||||
- Name: $v
|
||||
Entry: 7
|
||||
Data: 70|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
|
||||
- Name: <Name>k__BackingField
|
||||
Entry: 1
|
||||
Data: sharedPelletCounterReleaseValues
|
||||
- Name: <UserType>k__BackingField
|
||||
Entry: 7
|
||||
Data: 71|System.RuntimeType, mscorlib
|
||||
- Name:
|
||||
Entry: 1
|
||||
Data: System.Int32[], mscorlib
|
||||
- Name:
|
||||
Entry: 8
|
||||
Data:
|
||||
- Name: <SystemType>k__BackingField
|
||||
Entry: 9
|
||||
Data: 71
|
||||
- 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: 72|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib
|
||||
@@ -1519,64 +1519,10 @@ MonoBehaviour:
|
||||
Data:
|
||||
- Name: $k
|
||||
Entry: 1
|
||||
Data: sharedPelletCounterReleaseValues
|
||||
Data: pelletTimeout
|
||||
- Name: $v
|
||||
Entry: 7
|
||||
Data: 73|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
|
||||
- Name: <Name>k__BackingField
|
||||
Entry: 1
|
||||
Data: sharedPelletCounterReleaseValues
|
||||
- Name: <UserType>k__BackingField
|
||||
Entry: 7
|
||||
Data: 74|System.RuntimeType, mscorlib
|
||||
- Name:
|
||||
Entry: 1
|
||||
Data: System.Int32[], mscorlib
|
||||
- Name:
|
||||
Entry: 8
|
||||
Data:
|
||||
- Name: <SystemType>k__BackingField
|
||||
Entry: 9
|
||||
Data: 74
|
||||
- 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: 75|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: pelletTimeout
|
||||
- Name: $v
|
||||
Entry: 7
|
||||
Data: 76|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
|
||||
- Name: <Name>k__BackingField
|
||||
Entry: 1
|
||||
Data: pelletTimeout
|
||||
@@ -1600,7 +1546,7 @@ MonoBehaviour:
|
||||
Data: false
|
||||
- Name: _fieldAttributes
|
||||
Entry: 7
|
||||
Data: 77|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib
|
||||
Data: 74|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib
|
||||
- Name:
|
||||
Entry: 12
|
||||
Data: 0
|
||||
@@ -1624,7 +1570,7 @@ MonoBehaviour:
|
||||
Data: frozen
|
||||
- Name: $v
|
||||
Entry: 7
|
||||
Data: 78|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
|
||||
Data: 75|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
|
||||
- Name: <Name>k__BackingField
|
||||
Entry: 1
|
||||
Data: frozen
|
||||
@@ -1648,7 +1594,7 @@ MonoBehaviour:
|
||||
Data: false
|
||||
- Name: _fieldAttributes
|
||||
Entry: 7
|
||||
Data: 79|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib
|
||||
Data: 76|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib
|
||||
- Name:
|
||||
Entry: 12
|
||||
Data: 0
|
||||
@@ -1672,7 +1618,7 @@ MonoBehaviour:
|
||||
Data: kinematic
|
||||
- Name: $v
|
||||
Entry: 7
|
||||
Data: 80|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
|
||||
Data: 77|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
|
||||
- Name: <Name>k__BackingField
|
||||
Entry: 1
|
||||
Data: kinematic
|
||||
@@ -1696,7 +1642,7 @@ MonoBehaviour:
|
||||
Data: false
|
||||
- Name: _fieldAttributes
|
||||
Entry: 7
|
||||
Data: 81|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib
|
||||
Data: 78|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib
|
||||
- Name:
|
||||
Entry: 12
|
||||
Data: 0
|
||||
|
||||
@@ -33,8 +33,6 @@ namespace Marro.PacManUdon
|
||||
private float powerPelletCountdown;
|
||||
private int powerPelletMultiplier;
|
||||
|
||||
private DataList ghostScaredQueue;
|
||||
|
||||
// Blink logic
|
||||
private const float blinkCycleRate = 0.233333333f;
|
||||
private bool blinkingActivated;
|
||||
@@ -80,7 +78,6 @@ namespace Marro.PacManUdon
|
||||
|
||||
public void RestartLevel(bool afterLifeLost = false)
|
||||
{
|
||||
ghostScaredQueue = new DataList();
|
||||
powerPelletActive = false;
|
||||
scatterCounter = 0;
|
||||
scatterPatternIndex = 0;
|
||||
@@ -186,7 +183,7 @@ namespace Marro.PacManUdon
|
||||
}
|
||||
}
|
||||
|
||||
public void GhostCaughtQueue(Ghost ghost)
|
||||
public void GhostCaught(Ghost ghost)
|
||||
{
|
||||
if (gameController.GameState == PacManGameState.AttractMode)
|
||||
{
|
||||
@@ -194,34 +191,6 @@ namespace Marro.PacManUdon
|
||||
return;
|
||||
}
|
||||
|
||||
// Debug.Log($"{gameObject} GhostCaughtQueue with ghost {ghost}");
|
||||
//networkManager.SendEventSoon(NetworkEventType.TimeSequenceSync);
|
||||
//networkManager.SendEventSoon(NetworkEventType.GhostUpdate);
|
||||
|
||||
ghostScaredQueue.Add(ghost);
|
||||
GhostCaughtExecute(ghost);
|
||||
}
|
||||
|
||||
public void GhostCaughtContinue()
|
||||
{
|
||||
// Debug.Log($"{gameObject} GhostCaughtContinue with ghost queue length {ghostScaredQueue.Count}");
|
||||
if (!ghostScaredQueue.TryGetValue(0, out DataToken currentGhost))
|
||||
{
|
||||
Debug.LogError("Called GhostCaughtContinue without a ghost in the queue!");
|
||||
return;
|
||||
}
|
||||
|
||||
((Ghost)currentGhost.Reference).ReturnHome();
|
||||
ghostScaredQueue.RemoveAt(0);
|
||||
|
||||
if (ghostScaredQueue.TryGetValue(0, out DataToken nextGhost))
|
||||
{
|
||||
GhostCaughtExecute((Ghost)nextGhost.Reference);
|
||||
}
|
||||
}
|
||||
|
||||
void GhostCaughtExecute(Ghost ghost)
|
||||
{
|
||||
int scoreBonus = 200 * (int)Math.Pow(2, powerPelletMultiplier);
|
||||
powerPelletMultiplier += 1;
|
||||
ghost.Caught(scoreBonus);
|
||||
@@ -518,20 +487,6 @@ namespace Marro.PacManUdon
|
||||
data.Append(kinematic, ref index);
|
||||
|
||||
data.AppendAsByte(gameController.Level, ref index);
|
||||
|
||||
var ghostScaredQueueArray = new byte[ghosts.Length];
|
||||
for (int i = 0; i < ghostScaredQueueArray.Length; i++)
|
||||
{
|
||||
var add = ghostScaredQueue.TryGetValue(i, out var ghost);
|
||||
if (!add)
|
||||
{
|
||||
ghostScaredQueueArray[i] = byte.MaxValue; // Add a terminator
|
||||
break;
|
||||
}
|
||||
ghostScaredQueueArray[i] = (byte)((Ghost)ghost.Reference).Index;
|
||||
}
|
||||
//Debug.Log($"{gameObject} Sent a ghostScareQueue of length {ghostScaredQueue.Count}");
|
||||
data.Append(ghostScaredQueueArray, ref index);
|
||||
}
|
||||
|
||||
public override bool WriteSyncedData(byte[] data, ref int index, NetworkEventType eventType)
|
||||
@@ -569,19 +524,6 @@ namespace Marro.PacManUdon
|
||||
var level = data.ReadByte(ref index);
|
||||
SetLevelConstants(level);
|
||||
|
||||
ghostScaredQueue.Clear();
|
||||
for (int i = 0; i < ghosts.Length; i++)
|
||||
{
|
||||
var ghostIndex = data[index + i];
|
||||
if (ghostIndex > ghosts.Length) // Reached terminator
|
||||
{
|
||||
break;
|
||||
}
|
||||
ghostScaredQueue.Add(ghosts[ghostIndex]);
|
||||
}
|
||||
index += ghosts.Length;
|
||||
//Debug.Log($"{gameObject} Read back a ghostScareQueue of length {ghostScaredQueue.Count}");
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -501,7 +501,7 @@ namespace Marro.PacManUdon
|
||||
|
||||
if (!IsOwner)
|
||||
{
|
||||
Debug.LogWarning($"({nameof(PacManUdon)} {nameof(NetworkManager)}) Attempted {nameof(SendEventSoon)} while not the owner!");
|
||||
//Debug.LogWarning($"({nameof(PacManUdon)} {nameof(NetworkManager)}) Attempted {nameof(SendEventSoon)} while not the owner!");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -323,7 +323,6 @@ namespace Marro.PacManUdon
|
||||
break;
|
||||
case 3:
|
||||
SetPelletsActive(true);
|
||||
collisionManager.RestoreAllPellets();
|
||||
statusDisplay.SetGameOverTextVisible(true);
|
||||
break;
|
||||
case 4:
|
||||
|
||||
@@ -21,8 +21,7 @@ namespace Marro.PacManUdon
|
||||
{
|
||||
// Unfreeze and reveal pacman
|
||||
SetPacManActive(true);
|
||||
SetFrozen(false);
|
||||
ghostManager.GhostCaughtContinue();
|
||||
SetFrozen(false); // This also makes the caught ghost return home
|
||||
soundManager.SetGhostRetreat(true);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user