Factory puzzle feedback and VO

This commit is contained in:
journaliciouz
2025-12-18 19:53:22 +01:00
parent 61f6da7a7d
commit 44a0cb4522
206 changed files with 14462 additions and 45 deletions

View File

@@ -13,7 +13,8 @@
"NewAssembly",
"Unity.Cinemachine",
"ScreenshotHelper",
"SwanDevCommon"
"SwanDevCommon",
"MoreMountains.Tools"
],
"includePlatforms": [],
"excludePlatforms": [],

View File

@@ -87,6 +87,7 @@ public class GlowOutline : ManagedBehaviour
if (itemSprite.sprite != null)
{
childSprite.sprite = itemSprite.sprite;
childSprite.flipX = itemSprite.flipX;
}
}

View File

@@ -0,0 +1,67 @@
using Core;
using Core.Lifecycle;
using System;
using UnityEngine;
public class FactoryGameStats : ManagedBehaviour
{
public int partsFoundInLevel;
// Save system configuration
public override bool AutoRegisterForSave => true;
internal override void OnManagedStart()
{
// Initialize after all managers are ready
}
public void PartFound()
{
partsFoundInLevel += 1;
}
#region Save/Load Lifecycle Hooks
internal override string OnSceneSaveRequested()
{
// Save scene-specific progress
var state = new BirdGameState
{
birdsFoundInLevel = this.partsFoundInLevel
};
return JsonUtility.ToJson(state);
}
internal override void OnSceneRestoreRequested(string serializedData)
{
if (string.IsNullOrEmpty(serializedData))
{
// No saved data, keep default values
return;
}
try
{
var state = JsonUtility.FromJson<BirdGameState>(serializedData);
if (state != null)
{
partsFoundInLevel = state.birdsFoundInLevel;
}
}
catch (Exception ex)
{
Logging.Warning($"[BirdGameStats] Failed to restore state: {ex.Message}");
}
}
#endregion
}
/// <summary>
/// Serializable state for bird game progress
/// </summary>
[Serializable]
public class BirdGameState
{
public int birdsFoundInLevel;
}

View File

@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: 576335826d79ec54c86fd1b24154809e

View File

@@ -0,0 +1,130 @@
using AudioSourceEvents;
using Levels;
using MoreMountains.Feedbacks;
using System;
using System.Diagnostics.Tracing;
using UnityEditor.Animations;
using UnityEngine;
using UnityEngine.Audio;
public class MrCementBehavior : MonoBehaviour
{
private MMF_Player _feedbackPlayer;
private Animator _animator;
private AppleAudioSource _appleAudioSource;
private IAudioEventSource _eventSource;
public AudioResource wheelAudioClip;
public AudioResource cogAudioClip;
public AudioResource beltAudioClip;
public AudioResource propellerAudioClip;
public AudioResource[] partsLeftClips;
public FactoryGameStats factoryGameStats;
public GameObject glowOutline;
public GameObject levelSwitcher;
public void Start()
{
_feedbackPlayer = GetComponent<MMF_Player>();
_animator = GetComponent<Animator>();
_appleAudioSource = GetComponent<AppleAudioSource>();
}
public void PlayCementAngry()
{
_feedbackPlayer.PauseFeedbacks();
_animator.SetTrigger("isAngry");
}
public void ContinuePatrol()
{
_feedbackPlayer.ResumeFeedbacks();
}
public void PlayCementFeedback(string partName)
{
switch (partName)
{
case "cog":
_feedbackPlayer.PauseFeedbacks();
_animator.SetTrigger("isHappy");
_appleAudioSource.audioSource.resource = cogAudioClip;
_appleAudioSource.Play(0);
_eventSource = _appleAudioSource.audioSource.RequestEventHandlers();
_eventSource.AudioStopped += StoppedTalking;
factoryGameStats.PartFound();
break;
case "wheel":
_feedbackPlayer.PauseFeedbacks();
_animator.SetTrigger("isHappy");
_appleAudioSource.audioSource.resource = wheelAudioClip;
_appleAudioSource.Play(0);
_eventSource = _appleAudioSource.audioSource.RequestEventHandlers();
_eventSource.AudioStopped += StoppedTalking;
factoryGameStats.PartFound();
break;
case "belt":
_feedbackPlayer.PauseFeedbacks();
_animator.SetTrigger("isHappy");
_appleAudioSource.audioSource.resource = beltAudioClip;
_appleAudioSource.Play(0);
_eventSource = _appleAudioSource.audioSource.RequestEventHandlers();
_eventSource.AudioStopped += StoppedTalking;
factoryGameStats.PartFound();
break;
case "propeller":
_feedbackPlayer.PauseFeedbacks();
_animator.SetTrigger("isHappy");
_appleAudioSource.audioSource.resource = propellerAudioClip;
_appleAudioSource.Play(0);
_eventSource = _appleAudioSource.audioSource.RequestEventHandlers();
_eventSource.AudioStopped += StoppedTalking;
factoryGameStats.PartFound();
break;
}
}
private void StoppedTalking(object sender, EventArgs e)
{
_eventSource.AudioStopped -= StoppedTalking;
switch (factoryGameStats.partsFoundInLevel)
{
case 1:
_appleAudioSource.audioSource.resource = partsLeftClips[0];
_appleAudioSource.Play(0);
break;
case 2:
_appleAudioSource.audioSource.resource = partsLeftClips[1];
_appleAudioSource.Play(0);
break;
case 3:
_appleAudioSource.audioSource.resource = partsLeftClips[2];
_appleAudioSource.Play(0);
break;
case 4:
_appleAudioSource.audioSource.resource = partsLeftClips[3];
_appleAudioSource.Play(0);
EnableMiniGameTrigger();
break;
}
}
private void EnableMiniGameTrigger()
{
// stop feedback
_feedbackPlayer.StopFeedbacks();
// happy loop animation
_animator.SetBool("allPartsFound", true);
// enable glowoutline
glowOutline.SetActive(true);
// enable minigameswitcher
levelSwitcher.SetActive(true);
}
}

View File

@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: 9a1f2eb571c9b3c4b8985a63d117ebfd

View File

@@ -0,0 +1,34 @@
using Interactions;
using System;
using UnityEngine;
public class PartfeedbackChecker : MonoBehaviour
{
public MrCementBehavior mrCement;
public ItemSlot itemSlot;
public void Start()
{
itemSlot.OnItemSlotted += ItemSlot_OnItemSlotted;
}
private void ItemSlot_OnItemSlotted(PickupItemData arg1, PickupItemData arg2)
{
switch (arg2.name)
{
case "Pickup_CementWheel":
mrCement.PlayCementFeedback("wheel");
break;
case "Pickup_CookieGear":
mrCement.PlayCementFeedback("cog");
break;
case "Pickup_FlowerPropeller":
mrCement.PlayCementFeedback("propeller");
break;
case "Pickup_FancyBelt":
mrCement.PlayCementFeedback("belt");
break;
}
}
}

View File

@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: 9f027035ff7849045a150a5f0d7a0da5