Compare commits

..

4 Commits

Author SHA1 Message Date
4ef936bf16 PrepareForCutscene 2025-12-26 18:27:04 +01:00
a15f977107 No SetMazeActive 2025-12-26 18:15:51 +01:00
f53a41f70c Cleaning up 2025-12-26 18:14:48 +01:00
16b0a348e4 Removed queue 2025-12-26 16:48:39 +01:00
22 changed files with 1048 additions and 1119 deletions

View File

@@ -44,14 +44,14 @@
public void Spawn()
{
Debug.Log($"{gameObject} Spawned");
// Debug.Log($"{gameObject} Spawned");
SetActive(true);
activeCountdown = Random.Range(9, 10);
}
public void Despawn()
{
Debug.Log($"{gameObject} Despawned");
// Debug.Log($"{gameObject} Despawned");
SetActive(false);
}

File diff suppressed because it is too large Load Diff

View File

@@ -192,6 +192,13 @@ namespace Marro.PacManUdon
pelletManager.SetPowerPelletsBlink(false);
}
private void PrepareForCutscene()
{
HideEverything();
RestartLevel();
SetFrozen(true);
}
public void GotPellet(bool addScore = true)
{
pelletCountRemaining--;
@@ -283,7 +290,6 @@ namespace Marro.PacManUdon
private void HideEverything()
{
SetMazeActive(false);
SetPelletsActive(false);
SetMazeVisible(false);
SetGhostsActive(false);
@@ -298,11 +304,6 @@ namespace Marro.PacManUdon
demo.gameObject.SetActive(false);
}
void SetMazeActive(bool active)
{
maze.gameObject.SetActive(active);
}
void SetPelletsActive(bool active)
{
pelletPool.gameObject.SetActive(active);

View File

@@ -558,10 +558,10 @@ namespace Marro.PacManUdon
}
}
void UpdateSpeed()
public void UpdateSpeed()
{
speed = ghostManager.GetTargetSpeed(this, ghostState, isScared, inTunnel);
Debug.Log($"Ghost updated speed to {speed}, level: {ghostManager.elroyLevel}");
// Debug.Log($"Ghost with type {ghostType} updated speed to {speed}, ghostState: {ghostState}, isScared: {isScared}, inTunnel: {inTunnel}, elroyLevel: {ghostManager.elroyLevel}");
}
public void ResetHousePelletCounter()
@@ -695,14 +695,10 @@ namespace Marro.PacManUdon
}
animator.speed = frozen && !keepAnimating ? 0 : 1; // This would cause issues if the returning sprite was animated, luckily it isn't :)
if (frozen == false)
if (frozen == false && faceInStartingDirectionUntilUnfrozen)
{
if (faceInStartingDirectionUntilUnfrozen)
{
faceInStartingDirectionUntilUnfrozen = false;
UpdateAnimator();
}
faceInStartingDirectionUntilUnfrozen = false;
UpdateAnimator();
}
}

View File

@@ -190,14 +190,14 @@
gameController.GhostCaught(0);
return;
}
Debug.Log($"{gameObject} GhostCaughtQueue with ghost {ghost}");
// Debug.Log($"{gameObject} GhostCaughtQueue with ghost {ghost}");
ghostScaredQueue.Add(ghost);
GhostCaughtExecute(ghost);
}
public void GhostCaughtContinue()
{
Debug.Log($"{gameObject} GhostCaughtContinue with ghost queue length {ghostScaredQueue.Count}");
// 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!");
@@ -326,9 +326,10 @@
pelletTimeoutLimit = PacManConstants.GetGhostHousePelletTimeoutLimitForLevel(level);
int[] privatePelletCounterReleaseValues = PacManConstants.GetGhostHousePrivatePelletCounterLimitForLevel(level);
for (int i = 0; i < Math.Min(sharedPelletCounterReleaseValues.Length, ghosts.Length); i++)
for (int i = 0; i < ghosts.Length; i++)
{
ghosts[i].SetHousePelletCounterLimit(privatePelletCounterReleaseValues[i]);
ghosts[i].Reset(); // Reset needed to properly apply level
}
}

View File

@@ -8,18 +8,18 @@ namespace Marro.PacManUdon
{
public virtual Vector2 GetPosition()
{
Debug.LogWarning($"{gameObject} does not implement GetPosition");
Debug.LogError($"{gameObject} does not implement GetPosition");
return Vector2.zero;
}
public virtual void SetPosition(Vector2 position)
{
Debug.LogWarning($"{gameObject} does not implement SetPosition");
Debug.LogError($"{gameObject} does not implement SetPosition");
}
public virtual Vector2 GetDirection()
{
Debug.LogWarning($"{gameObject} does not implement GetDirection");
Debug.LogError($"{gameObject} does not implement GetDirection");
return Vector2.zero;
}
}

View File

@@ -101,14 +101,12 @@ namespace Marro.PacManUdon
if (level == PoleStrechLevels.Strech1 || level == PoleStrechLevels.Separated) // Step forward timed procedure
{
Debug.Log($"Intermission2Pole Intermission2PoleUpdate");
_gameManager.Intermission2PoleUpdate();
}
}
public void SetStrechLevel(PoleStrechLevels level)
{
Debug.Log($"Intermission2Pole SetStrechLevel {level}");
_animator.SetFloat("Strech", GetAnimatorValueForStrechLevel(level));
}

View File

@@ -30,7 +30,7 @@
}
powerPellets = GetComponentsInChildren<Animator>(true);
Debug.Log($"{gameObject} Initialized, powerPellets: {powerPellets}");
// Debug.Log($"{gameObject} Initialized, powerPellets: {powerPellets}");
powerPelletBlinkToggleInterval = PacManConstants.GetPowerPelletBlinkToggleInterval();
SetPowerPelletsBlink(false);
}

View File

@@ -9,20 +9,17 @@ namespace Marro.PacManUdon
switch (sequenceProgress)
{
case 0:
PrepareForCutscene();
SetGameState(PacManGameState.AttractModeDemo);
HideEverything();
SetFrozen(true);
break;
case 1:
InitializeLevel();
SetMazeActive(true);
SetMazeVisible(true);
SetLevel(1);
break;
case 2:
// Reset ghosts
RestartLevel();
// Setup ghosts
ghostManager.Ghosts[0].SetPredefinedPath(new Vector2[]{ // Blinky
Vector2.down,
Vector2.left,

View File

@@ -9,13 +9,12 @@ namespace Marro.PacManUdon
switch (sequenceProgress)
{
case 0:
PrepareForCutscene();
SetGameState(PacManGameState.AttractMode);
// Initialize
soundManager.SuppressSound(true);
RestartLevel();
HideEverything();
SetFrozen(true);
attractScreen.gameObject.SetActive(true);
attractScreen.Initialize();
for (int i = 0; i <= 15; i++)

View File

@@ -11,8 +11,9 @@ namespace Marro.PacManUdon
switch (sequenceProgress)
{
case 0:
PrepareForCutscene();
// Show just level display
RestartLevel();
statusDisplay.SetLevelDisplayVisible(true);
break;
case 1:
@@ -20,7 +21,6 @@ namespace Marro.PacManUdon
soundManager.SuppressSound(false);
soundManager.StartIntermissionSound();
pacMan.Reset();
pacMan.SetLevel(4);
pacMan.SetPowerPellet(false); // Update speed
pacMan.SetKinematic(true);
@@ -28,7 +28,6 @@ namespace Marro.PacManUdon
pacMan.SetPosition(intermissionScreenElements[0].transform.localPosition);
pacMan.SetDirection(Vector2.left);
ghostManager.Reset();
ghostManager.SetLevel(5);
ghostManager.SetKinematic(true);
ghostManager.gameObject.SetActive(true);

View File

@@ -11,8 +11,9 @@ namespace Marro.PacManUdon
switch (sequenceProgress)
{
case 0:
PrepareForCutscene();
// Show just level display
RestartLevel();
statusDisplay.SetLevelDisplayVisible(true);
break;
case 1:
@@ -27,7 +28,6 @@ namespace Marro.PacManUdon
break;
case 3:
// Start animation, pacman running and blinky prepared to chase
pacMan.Reset();
pacMan.SetLevel(4);
pacMan.SetPowerPellet(false); // Update speed
pacMan.SetKinematic(true);
@@ -35,7 +35,6 @@ namespace Marro.PacManUdon
pacMan.SetPosition(intermissionScreenElements[0].transform.localPosition);
pacMan.SetDirection(Vector2.left);
ghostManager.Reset();
ghostManager.SetLevel(5);
ghostManager.SetKinematic(true);
ghostManager.gameObject.SetActive(true);

View File

@@ -11,8 +11,9 @@ namespace Marro.PacManUdon
switch (sequenceProgress)
{
case 0:
PrepareForCutscene();
// Show just level display
RestartLevel();
statusDisplay.SetLevelDisplayVisible(true);
break;
case 1:
@@ -20,7 +21,6 @@ namespace Marro.PacManUdon
soundManager.SuppressSound(false);
soundManager.StartIntermissionSound();
pacMan.Reset();
pacMan.SetLevel(4);
pacMan.SetPowerPellet(false); // Update speed
pacMan.SetKinematic(true);
@@ -28,7 +28,6 @@ namespace Marro.PacManUdon
pacMan.SetPosition(intermissionScreenElements[0].transform.localPosition);
pacMan.SetDirection(Vector2.left);
ghostManager.Reset();
ghostManager.SetLevel(5);
ghostManager.SetKinematic(true);
ghostManager.gameObject.SetActive(true);

View File

@@ -21,7 +21,7 @@ namespace Marro.PacManUdon
soundManager.PlayDeathSound();
break;
case 3:
// Hide pacman, start next state
// Hide pacman
SetPacManActive(false);
break;
}

View File

@@ -12,35 +12,21 @@ namespace Marro.PacManUdon
// Prepare new game, hide everything except score bar
gameState = PacManGameState.InGame;
HideEverything();
SetMazeActive(true);
InitializeNewGame();
InitializeLevel();
RestartLevel();
SetFrozen(true);
PrepareForCutscene();
soundManager.SuppressSound(false);
soundManager.PlayGameStartSound();
break;
case 1:
// Show maze, lives indicator, level indicator, player 1 and ready text
// SOMEWHERE IN HERE UNITY (EDITOR) APPEARS TO HAVE A SMALL RANDOM CHANCE OF CRASHING !!
Debug.Log("Log dump in case of crash");
Debug.Log("Setting pellets visible");
SetPelletsActive(true);
Debug.Log("Setting maze visible");
SetMazeVisible(true);
Debug.Log("Setting extra lives display visible");
statusDisplay.SetExtraLivesDisplayVisible(true);
Debug.Log("Setting level display visible");
statusDisplay.SetLevelDisplayVisible(true);
Debug.Log("Setting player 1 text visible");
statusDisplay.SetPlayer1TextVisible(true);
Debug.Log("Setting ready text visible");
statusDisplay.SetReadyTextVisible(true);
Debug.Log("Starting 1UP blink");
statusDisplay.SetLabel1UPTextBlinking(true);
break;
case 2:

View File

@@ -7,12 +7,12 @@ namespace Marro.PacManUdon
switch (sequenceProgress)
{
case 0:
PrepareForCutscene();
// Reset, show maze and score display
InitializeLevel();
RestartLevel();
SetMazeVisible(true);
statusDisplay.SetScoreDisplayVisible(true);
soundManager.SuppressSound(false);
break;
case 1:
// Increment level, show ready, show pellets, show lives indicators
@@ -39,6 +39,7 @@ namespace Marro.PacManUdon
{
// Unfreeze
SetFrozen(false);
soundManager.SuppressSound(false);
soundManager.StartGhostSound();
}
}

View File

@@ -13,31 +13,23 @@ namespace Marro.PacManUdon
// I'm not redoing this unless I get instantiatable classes before I wrap up this project.
bool currentlyInTimeSequence;
bool waitingForTimeSequenceFinish;
bool jumpingToTimeSequence;
PacManTimeSequence currentTimeSequence;
bool hasTimeSequenceQueued;
private DataList timeSequenceQueue;
[UdonSynced] float timeSequenceSecondsPassed;
int timeSequenceProgress;
float[] timeSequenceKeyframeTimes;
private void StartTimeSequence(PacManTimeSequence timeSequence)
{
if (timeSequenceQueue == null)
{
timeSequenceQueue = new DataList();
}
if (currentlyInTimeSequence == true)
{
int timeSequenceInt = (int)timeSequence; // Doing the conversion in the line below crashes the script. I love working in Udon
timeSequenceQueue.Add(timeSequenceInt);
hasTimeSequenceQueued = true;
return;
}
Debug.Log($"StartTimeSequence: {timeSequence}");
if (currentlyInTimeSequence)
{
TimeSequenceEndCurrent();
}
TimeSequencePrepareForStart(timeSequence);
currentlyInTimeSequence = true;
currentTimeSequence = timeSequence;
timeSequenceProgress = 0;
@@ -45,32 +37,22 @@ namespace Marro.PacManUdon
timeSequenceKeyframeTimes = GetTimeSequenceKeyframeTimes(timeSequence);
TimeSequenceProgressToTime(timeSequenceSecondsPassed);
}
private void TimeSequenceEndCurrent()
{
jumpingToTimeSequence = true;
TimeSequenceProgressToTime(100000f);
jumpingToTimeSequence = false;
}
private void TimeSequenceUpdate(float deltaSeconds)
{
if (!currentlyInTimeSequence && hasTimeSequenceQueued)
if (!currentlyInTimeSequence)
{
timeSequenceQueue.TryGetValue(0, out DataToken nextTimeSequence);
StartTimeSequence((PacManTimeSequence)nextTimeSequence.Int);
timeSequenceQueue.RemoveAt(0);
hasTimeSequenceQueued = timeSequenceQueue.Count > 0 ? true : false;
return;
}
if (currentlyInTimeSequence)
{
if (hasTimeSequenceQueued)
{
while (currentlyInTimeSequence)
{
TimeSequenceSkipToNextStep();
}
}
else
{
TimeSequenceProgressToTime(timeSequenceSecondsPassed + deltaSeconds);
}
}
TimeSequenceProgressToTime(timeSequenceSecondsPassed + deltaSeconds);
}
private void TimeSequenceSkipToNextStep()
@@ -92,26 +74,26 @@ namespace Marro.PacManUdon
timeSequenceSecondsPassed = seconds;
while (timeSequenceSecondsPassed >= timeSequenceKeyframeTimes[timeSequenceProgress])
{
TimeSequenceExecuteStep(timeSequenceProgress);
TimeSequenceExecuteStep(currentTimeSequence, timeSequenceProgress);
timeSequenceProgress += 1;
if (timeSequenceProgress >= timeSequenceKeyframeTimes.Length)
{
currentlyInTimeSequence = false;
TimeSequencePrepareForFinish();
TimeSequencePrepareForFinish(currentTimeSequence);
break;
}
}
}
private void TimeSequencePrepareForFinish()
private void TimeSequencePrepareForFinish(PacManTimeSequence timeSequence)
{
if (Networking.IsOwner(gameObject))
{
TimeSequenceExecuteFinalize();
if (!hasTimeSequenceQueued)
TimeSequenceExecuteFinalize(timeSequence);
if (!jumpingToTimeSequence)
{
TimeSequenceExecuteFinished();
TimeSequenceExecuteFinished(timeSequence);
}
}
else
@@ -201,10 +183,37 @@ namespace Marro.PacManUdon
#region Jump tables
private void TimeSequenceExecuteStep(int sequenceProgress)
private void TimeSequencePrepareForStart(PacManTimeSequence timeSequence)
{
switch (timeSequence)
{
default:
Debug.LogError($"{gameObject} No time sequence start known for sequence {currentTimeSequence}");
break;
case PacManTimeSequence.AttractScreenIntroduction:
case PacManTimeSequence.AttractScreenDemo:
case PacManTimeSequence.StartNewGame:
case PacManTimeSequence.WaitForStart:
case PacManTimeSequence.StartNewLevel:
case PacManTimeSequence.Intermission1:
case PacManTimeSequence.Intermission2:
case PacManTimeSequence.Intermission3:
case PacManTimeSequence.AttractScreenWaitToRestart:
case PacManTimeSequence.WaitForStartTimeout:
case PacManTimeSequence.GhostCaught:
case PacManTimeSequence.GameOver:
case PacManTimeSequence.PacManCaught:
case PacManTimeSequence.BoardClear:
case PacManTimeSequence.RestartLevel:
// These don't have start logic
break;
}
}
private void TimeSequenceExecuteStep(PacManTimeSequence timeSequence, int sequenceProgress)
{
// Debug.Log($"{gameObject} Triggered time sequence step for sequence {currentTimeSequence} with progress {sequenceProgress}");
switch (currentTimeSequence)
switch (timeSequence)
{
default:
Debug.LogError($"{gameObject} No time sequence keyframes known for sequence {currentTimeSequence}");
@@ -255,10 +264,10 @@ namespace Marro.PacManUdon
}
}
private void TimeSequenceExecuteFinalize()
private void TimeSequenceExecuteFinalize(PacManTimeSequence timeSequence)
{
// Debug.Log($"{gameObject} Triggered time sequence step for sequence {currentTimeSequence} with progress {sequenceProgress}");
switch (currentTimeSequence)
switch (timeSequence)
{
default:
Debug.LogError($"{gameObject} No time sequence finalize known for sequence {currentTimeSequence}");
@@ -299,10 +308,10 @@ namespace Marro.PacManUdon
}
}
private void TimeSequenceExecuteFinished()
private void TimeSequenceExecuteFinished(PacManTimeSequence timeSequence)
{
// Debug.Log($"{gameObject} Triggered time sequence step for sequence {currentTimeSequence} with progress {sequenceProgress}");
switch (currentTimeSequence)
switch (timeSequence)
{
default:
Debug.LogError($"{gameObject} No time sequence finish known for sequence {currentTimeSequence}");

View File

@@ -1,5 +1,5 @@
fileFormatVersion: 2
guid: a11df70b39ac2924c825f9951b58dafd
guid: 506fd020620e6d24787a909c153b2da5
MonoImporter:
externalObjects: {}
serializedVersion: 2

View File

@@ -7,8 +7,9 @@ namespace Marro.PacManUdon
switch (sequenceProgress)
{
case 0:
PrepareForCutscene();
SetGameState(PacManGameState.WaitForStart);
HideEverything();
soundManager.SuppressSound(false);
soundManager.PlayCoinSound();
break;

View File

@@ -188,17 +188,17 @@ public class SoundManager : UdonSharpBehaviour
return;
}
if (!audioSource.isPlaying || audioSource.clip == null)
{
PlaySound(audioSource, audioClip, loop);
}
if (audioSource.clip == audioClip)
{
// No need to switch
return;
}
if (!audioSource.isPlaying || audioSource.clip == null)
{
PlaySound(audioSource, audioClip, loop);
}
var newTimeSamples = (int)(audioSource.timeSamples / (double)audioSource.clip.samples * audioClip.samples);
audioSource.clip = audioClip;

View File

@@ -44,7 +44,7 @@
{
extraLifeIndicators[i - 1] = extraLifeIndicatorTransforms[i].gameObject;
}
Debug.Log($"{gameObject} extraLifeIndicators.Length: {extraLifeIndicators.Length}");
// Debug.Log($"{gameObject} extraLifeIndicators.Length: {extraLifeIndicators.Length}");
}

View File

@@ -511,7 +511,7 @@ PlayerSettings:
m_Automatic: 0
- m_BuildTarget: iOSSupport
m_APIs: 10000000
m_Automatic: 1
m_Automatic: 0
- m_BuildTarget: WindowsStandaloneSupport
m_APIs: 02000000
m_Automatic: 0