Improving sync
This commit is contained in:
@@ -15,6 +15,15 @@ namespace Marro.PacManUdon
|
||||
Special,
|
||||
}
|
||||
|
||||
enum PacManGhostAnimatorState
|
||||
{
|
||||
Normal,
|
||||
Caught,
|
||||
Scared,
|
||||
ScaredWhite,
|
||||
Special
|
||||
}
|
||||
|
||||
public enum PacManGhostState
|
||||
{
|
||||
Normal,
|
||||
@@ -68,6 +77,7 @@ namespace Marro.PacManUdon
|
||||
// State
|
||||
private PacManGhostState ghostState;
|
||||
private bool isScared;
|
||||
private bool whiteScared;
|
||||
private bool scattering;
|
||||
private PacManGhostFrozenState frozenState;
|
||||
|
||||
@@ -540,21 +550,20 @@ namespace Marro.PacManUdon
|
||||
SetAnimatorDirection((int)targetDirection);
|
||||
}
|
||||
|
||||
if (isScared) // Don't update ghost type while scared as this interrupts the white/blue blinking
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
PacManGhostType ghostType = this.ghostType;
|
||||
|
||||
if (specialLook)
|
||||
if (isScared)
|
||||
{
|
||||
ghostType = PacManGhostType.Special;
|
||||
ghostType = whiteScared ? PacManGhostType.ScaredWhite : PacManGhostType.Scared;
|
||||
}
|
||||
else if (ghostState == PacManGhostState.Returning || ghostState == PacManGhostState.Entering)
|
||||
{
|
||||
ghostType = PacManGhostType.Caught;
|
||||
}
|
||||
else if (specialLook)
|
||||
{
|
||||
ghostType = PacManGhostType.Special;
|
||||
}
|
||||
|
||||
SetAnimatorGhostType((int)ghostType);
|
||||
}
|
||||
@@ -671,13 +680,8 @@ namespace Marro.PacManUdon
|
||||
private void SetScared(bool scared)
|
||||
{
|
||||
isScared = scared;
|
||||
UpdateAnimator();
|
||||
SetWhite(false);
|
||||
UpdateSpeed();
|
||||
|
||||
if (isScared)
|
||||
{
|
||||
SetWhite(false);
|
||||
}
|
||||
}
|
||||
|
||||
public void SetScattering(bool scattering, bool reverseDirection = true)
|
||||
@@ -738,10 +742,8 @@ namespace Marro.PacManUdon
|
||||
|
||||
public void SetWhite(bool white)
|
||||
{
|
||||
if (!isScared || !gameObject.activeInHierarchy)
|
||||
return;
|
||||
|
||||
SetAnimatorGhostType(white ? (int)PacManGhostType.ScaredWhite : (int)PacManGhostType.Scared);
|
||||
whiteScared = white;
|
||||
UpdateAnimator();
|
||||
}
|
||||
|
||||
public void SetElroy(int elroyLevel)
|
||||
@@ -820,6 +822,7 @@ namespace Marro.PacManUdon
|
||||
|
||||
data.AppendAsByte((int)ghostState, ref index);
|
||||
data.Append(isScared, ref index);
|
||||
data.Append(whiteScared, ref index);
|
||||
data.Append(scattering, ref index);
|
||||
data.AppendAsByte((int)frozenState, ref index);
|
||||
|
||||
@@ -847,6 +850,7 @@ namespace Marro.PacManUdon
|
||||
|
||||
ghostState = (PacManGhostState)data.ReadByte(ref index);
|
||||
isScared = data.ReadBool(ref index);
|
||||
whiteScared = data.ReadBool(ref index);
|
||||
scattering = data.ReadBool(ref index);
|
||||
frozenState = (PacManGhostFrozenState)data.ReadByte(ref index);
|
||||
|
||||
@@ -855,6 +859,8 @@ namespace Marro.PacManUdon
|
||||
housePelletCounterActive = data.ReadBool(ref index);
|
||||
housePelletCounterLimit = data.ReadByte(ref index);
|
||||
|
||||
UpdateSpeed();
|
||||
|
||||
return base.WriteSyncedData(data, ref index, eventType);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user