mirror of
https://github.com/nothke/quality-control.git
synced 2025-08-08 23:03:43 +00:00
Audio for some of the machines
This commit is contained in:
@@ -2,7 +2,7 @@ using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class ConveyorBelt : MonoBehaviour
|
||||
public class ConveyorBelt : MonoBehaviour, IResetable
|
||||
{
|
||||
Rigidbody _rb;
|
||||
Rigidbody rb { get { if (!_rb) _rb = GetComponent<Rigidbody>(); return _rb; } }
|
||||
@@ -15,8 +15,30 @@ public class ConveyorBelt : MonoBehaviour
|
||||
public float scrollingTextureSpeedMult = 1;
|
||||
public Renderer scrollingTextureRenderer;
|
||||
|
||||
public AudioClip conveyorClip;
|
||||
public float volume = 0.25f;
|
||||
private AudioSource _audioSource;
|
||||
|
||||
public void ResetMachine()
|
||||
{
|
||||
if (_audioSource)
|
||||
{
|
||||
_audioSource.Stop();
|
||||
Destroy(_audioSource.gameObject);
|
||||
_audioSource = null;
|
||||
}
|
||||
|
||||
if (isActiveAndEnabled)
|
||||
{
|
||||
_audioSource = NAudio.Play(conveyorClip, transform.position, volume);
|
||||
_audioSource.loop = true;
|
||||
}
|
||||
}
|
||||
|
||||
private void Start()
|
||||
{
|
||||
ResetMachine();
|
||||
|
||||
startPosition = rb.position;
|
||||
|
||||
//scrollingTextureSpeedMult = -0.1625f * speed;
|
||||
|
@@ -33,7 +33,6 @@ public class StagingManager: MonoBehaviour
|
||||
|
||||
foreach (var stageProp in FindObjectsOfType<StageProp>(true))
|
||||
{
|
||||
Debug.Log(stageProp.ActiveAtStages.HasFlag(stage));
|
||||
stageProp.gameObject.SetActive(stageProp.ActiveAtStages.HasFlag(stage));
|
||||
}
|
||||
}
|
||||
|
@@ -1,6 +1,7 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Serialization;
|
||||
|
||||
public class Converter: MonoBehaviour, IResetable
|
||||
{
|
||||
@@ -17,6 +18,9 @@ public class Converter: MonoBehaviour, IResetable
|
||||
public float conversionDuration = 5f;
|
||||
private float _conversionTimer;
|
||||
|
||||
[FormerlySerializedAs("conversionSound")] public AudioClip conversionClip;
|
||||
private AudioSource _audioSource;
|
||||
|
||||
public Transform refuseLauncher;
|
||||
public float launchPower = 10f;
|
||||
|
||||
@@ -42,6 +46,13 @@ public class Converter: MonoBehaviour, IResetable
|
||||
CurrentHealth = MaxHealth;
|
||||
|
||||
inputProducts.Clear();
|
||||
|
||||
if (_audioSource)
|
||||
{
|
||||
_audioSource.Stop();
|
||||
Destroy(_audioSource.gameObject);
|
||||
_audioSource = null;
|
||||
}
|
||||
}
|
||||
|
||||
public void Update()
|
||||
@@ -65,6 +76,8 @@ public class Converter: MonoBehaviour, IResetable
|
||||
Spawner.SpawnProduct(conversionProduct, currentProduct.Defect);
|
||||
inputProducts.RemoveAt(0);
|
||||
Destroy(currentProduct);
|
||||
|
||||
_audioSource = NAudio.Play(conversionClip, transform.position, 0.75f);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
Reference in New Issue
Block a user