mirror of
https://github.com/Ratstail91/Keep-It-Alive.git
synced 2025-11-29 02:24:27 +11:00
Added audio, it's finished
This commit is contained in:
@@ -4,6 +4,9 @@ using UnityEngine;
|
||||
using UnityEngine.SceneManagement;
|
||||
|
||||
public class Character : MonoBehaviour {
|
||||
//references
|
||||
AudioController audioController;
|
||||
|
||||
//components
|
||||
SpriteRenderer spriteRenderer;
|
||||
Rigidbody2D rb;
|
||||
@@ -22,6 +25,8 @@ public class Character : MonoBehaviour {
|
||||
float huntingTime;
|
||||
|
||||
void Awake() {
|
||||
audioController = GameObject.Find("AudioController").GetComponent<AudioController>();
|
||||
|
||||
spriteRenderer = GetComponent<SpriteRenderer>();
|
||||
rb = GetComponent<Rigidbody2D>();
|
||||
fadeToBlack = GetComponent<FadeToBlack>();
|
||||
@@ -75,8 +80,13 @@ public class Character : MonoBehaviour {
|
||||
void HandleHunted() {
|
||||
if (fadeToBlack.brightness < 0f) {
|
||||
huntingTime -= Time.deltaTime;
|
||||
|
||||
if (!audioController.GetPlaying("hunted")) {
|
||||
audioController.Play("hunted");
|
||||
}
|
||||
} else {
|
||||
huntingTime = 3f;
|
||||
audioController.Stop("hunted");
|
||||
}
|
||||
|
||||
if (huntingTime <= 0f) {
|
||||
|
||||
@@ -5,6 +5,7 @@ using UnityEngine;
|
||||
public class Fire : MonoBehaviour {
|
||||
Animator animator;
|
||||
LevelController levelController;
|
||||
AudioController audioController;
|
||||
|
||||
[SerializeField]
|
||||
int size = 1;
|
||||
@@ -12,6 +13,7 @@ public class Fire : MonoBehaviour {
|
||||
void Awake() {
|
||||
animator = GetComponent<Animator>();
|
||||
levelController = GameObject.Find("Level Controller").GetComponent<LevelController>();
|
||||
audioController = GameObject.Find("AudioController").GetComponent<AudioController>();
|
||||
}
|
||||
|
||||
void Start() {
|
||||
@@ -38,6 +40,8 @@ public class Fire : MonoBehaviour {
|
||||
levelController.globalWood -= 1;
|
||||
levelController.globalLightLevel += 0.2f;
|
||||
levelController.globalLightLevel = Mathf.Clamp(levelController.globalLightLevel, 0f, 1f);
|
||||
|
||||
audioController.Play("crackle");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -4,6 +4,7 @@ using UnityEngine;
|
||||
|
||||
public class Tree : MonoBehaviour {
|
||||
static LevelController levelController;
|
||||
static AudioController audioController;
|
||||
static GameObject character;
|
||||
|
||||
SpriteRenderer spriteRenderer;
|
||||
@@ -19,6 +20,10 @@ public class Tree : MonoBehaviour {
|
||||
levelController = GameObject.Find("Level Controller").GetComponent<LevelController>();
|
||||
}
|
||||
|
||||
if (!audioController) {
|
||||
audioController = GameObject.Find("AudioController").GetComponent<AudioController>();
|
||||
}
|
||||
|
||||
if (!character) {
|
||||
character = GameObject.Find("Character");
|
||||
}
|
||||
@@ -28,6 +33,8 @@ public class Tree : MonoBehaviour {
|
||||
if (GamePad.GetState().Pressed(CButton.Y)) {
|
||||
life -= 1;
|
||||
|
||||
audioController.Play("cut");
|
||||
|
||||
//wiggle
|
||||
StartCoroutine(Wiggle());
|
||||
|
||||
|
||||
Reference in New Issue
Block a user