This commit is contained in:
RochesterX
2025-04-16 13:44:03 -04:00
parent 3cce475c6f
commit 186811be42
24 changed files with 6703 additions and 1621 deletions

View File

@@ -0,0 +1,67 @@
using System.Collections.Generic;
using UnityEngine;
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,15 @@
using UnityEngine;
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