Few bug fixes

Fixed `Time Left!` display. Added obstacle course ends for all 4 maps. Sets obstacle course end goals to only work on the correct gamemode. Set correct time limits for keep away in every map.
This commit is contained in:
djkellerman
2025-04-17 17:19:02 -04:00
parent 6b7dbea593
commit 98f0713ebe
13 changed files with 346 additions and 12 deletions

View File

@@ -0,0 +1,71 @@
using System.Collections.Generic;
using UnityEngine; using Game; using Music; using Player;
namespace Music
{
public class AudioManager : MonoBehaviour
{
public List<SoundEffect> soundEffects = new List<SoundEffect>();
public static AudioManager Instance;
private void Awake()
{
if (Instance == null)
{
Instance = this;
DontDestroyOnLoad(gameObject);
}
else
{
Destroy(gameObject);
}
foreach (Transform child in transform)
{
var soundEffect = new SoundEffect(child.name, child.GetComponent<AudioSource>());
if (soundEffect != null)
{
soundEffects.Add(soundEffect);
}
}
print(soundEffects);
}
public void PlaySound(string soundName)
{
if (soundName == "Punch")
{
soundEffects.Find(x => x.name == "Punch").audioSource.Play();
soundEffects.Find(x => x.name == "Punch 2").audioSource.Play();
soundEffects.Find(x => x.name == "Punch 3").audioSource.Play();
return;
}
foreach (var soundEffect in soundEffects)
{
if (soundEffect.name == soundName)
{
soundEffect.audioSource.Play();
return;
}
}
Debug.LogWarning($"Sound '{soundName}' not found!");
}
}
public class SoundEffect
{
public string name;
public AudioSource audioSource;
public SoundEffect(string name, AudioSource audioSource)
{
this.name = name;
this.audioSource = audioSource;
}
}
}

View File

@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: ab3338b5eb5fc46caac119dfaba50ae3

View File

@@ -0,0 +1,19 @@
using UnityEngine; using Game; using Music; using Player;
namespace Game
{
public class ObstacleCourse : MonoBehaviour
{
public static GameObject playerWon;
void OnTriggerEnter2D(Collider2D collision)
{
if (collision.gameObject.CompareTag("Player"))
{
playerWon = collision.gameObject;
GameManager.Instance.GameOver();
}
}
}
}

View File

@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: 746e2bd0f68be467eb1b2b19c7c513af

View File

@@ -0,0 +1,27 @@
using Game;
using UnityEngine;
public class ObstacleEnd : MonoBehaviour
{
void Start()
{
UpdateVisibility();
}
void Update()
{
UpdateVisibility();
}
private void UpdateVisibility() // Sets object active if playing obstacle course
{
if (GameManager.gameMode == GameManager.GameMode.obstacleCourse)
{
gameObject.SetActive(true);
}
else
{
gameObject.SetActive(false);
}
}
}

View File

@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: 69fc903d39ac3d24aab4ce7a68dba447