This commit is contained in:
nothke
2024-08-20 00:20:44 +02:00
18 changed files with 3812 additions and 444 deletions

View File

@@ -19,7 +19,8 @@ public class ConveyorBelt : MonoBehaviour
private void Start()
{
audioSource.time += Random.Range(1f, 3f);
float length = audioSource.clip.length;
audioSource.time += Random.Range(0.2f * length, 0.4f * length);
audioSource.pitch = Random.Range(-0.05f, 0.05f) + speed / 2f;
startPosition = rb.position;

View File

@@ -13,14 +13,13 @@ public class LevelObjective : ScriptableObject
{
public ProductType Type;
public int Quantity;
[Range(0, 100)]
public int MaxDefectivePercentage;
}
public List<ProductQuota> Quotas;
public float TimeLimit;
[Range(0, 100)]
public int MaxDefectivePercentage;
[TextArea]
public string LevelMessage;

View File

@@ -169,7 +169,7 @@ public class Scoreboard: MonoBehaviour
Debug.Log($"{quota.Type.name}: {TotalCount(quota.Type)}/{quota.Quantity}");
if (CurrentObjective.MaxDefectivePercentage < DefectPercentage(quota.Type))
if (quota.MaxDefectivePercentage < DefectPercentage(quota.Type))
{
success = false;
Debug.LogError($"Too many broken {quota.Type.name}");

View File

@@ -19,8 +19,8 @@ public class Converter: MonoBehaviour, IResetable
public float conversionDuration = 5f;
private float _conversionTimer;
[FormerlySerializedAs("conversionSound")] public AudioClip conversionClip;
private AudioSource _audioSource;
public AudioClip conversionClip;
public AudioClip launchClip;
public Transform refuseLauncher;
public float launchPower = 10f;
@@ -47,13 +47,6 @@ public class Converter: MonoBehaviour, IResetable
CurrentHealth = MaxHealth;
inputProducts.Clear();
if (_audioSource)
{
_audioSource.Stop();
Destroy(_audioSource.gameObject);
_audioSource = null;
}
}
public void Update()
@@ -86,12 +79,14 @@ public class Converter: MonoBehaviour, IResetable
inputProducts.RemoveAt(0);
Destroy(currentProduct);
_audioSource = NAudio.Play(conversionClip, transform.position, 0.75f);
NAudio.Play(conversionClip, transform.position, 0.75f);
}
else
{
Expel(inputProducts[0]);
inputProducts.RemoveAt(0);
NAudio.Play(launchClip, transform.position);
}
_conversionTimer = conversionDuration;

View File

@@ -6,6 +6,8 @@ public class ProductSpawner: MonoBehaviour
public List<Transform> PossibleOrientations;
public Vector2 yRotation;
public AudioClip spawnClip;
public void SpawnProduct(ProductType type)
{
var randomIndex = Random.Range(0, PossibleOrientations.Count);
@@ -15,6 +17,7 @@ public class ProductSpawner: MonoBehaviour
randomOrientation.rotation;
ProductType.SpawnProduct(type, transform, randomOrientation.position, rotation);
NAudio.Play(spawnClip, transform.position);
}
public void SpawnProduct(ProductType type, DefectType defect)