mirror of
https://github.com/nothke/quality-control.git
synced 2025-08-09 23:23:44 +00:00
Added more prefabs
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
using UnityEngine;
|
||||
|
||||
public class DefectiveProduct : MonoBehaviour
|
||||
public class DefectiveProduct : Product
|
||||
{
|
||||
|
||||
}
|
6
Assets/Scripts/Products/Product.cs
Normal file
6
Assets/Scripts/Products/Product.cs
Normal file
@@ -0,0 +1,6 @@
|
||||
using UnityEngine;
|
||||
|
||||
public class Product : MonoBehaviour
|
||||
{
|
||||
|
||||
}
|
3
Assets/Scripts/Products/Product.cs.meta
Normal file
3
Assets/Scripts/Products/Product.cs.meta
Normal file
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 813c296fdd6145aeaa5dfd4a2b2ca423
|
||||
timeCreated: 1723917512
|
@@ -1,73 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class ProductSpawner : MonoBehaviour
|
||||
{
|
||||
public enum ProductionPhaseType
|
||||
{
|
||||
Pause = 0,
|
||||
Production = 1,
|
||||
}
|
||||
|
||||
[Serializable]
|
||||
public struct ProductionPhase
|
||||
{
|
||||
public ProductionPhaseType Type;
|
||||
public ProductDescription Description;
|
||||
[Min(1f)]
|
||||
public float Duration;
|
||||
[Min(1f)]
|
||||
public float TotalSpawnCount;
|
||||
|
||||
public float SpawnInterval => Duration / TotalSpawnCount;
|
||||
}
|
||||
|
||||
public List<ProductionPhase> ProductionPhases;
|
||||
|
||||
public float _remainingDuration;
|
||||
public float _spawnTimer;
|
||||
|
||||
private void Update()
|
||||
{
|
||||
if (ProductionPhases.Count == 0)
|
||||
{
|
||||
enabled = false;
|
||||
return;
|
||||
}
|
||||
|
||||
var currentPhase = ProductionPhases[0];
|
||||
|
||||
if (_remainingDuration <= 0)
|
||||
{
|
||||
_remainingDuration = currentPhase.Duration;
|
||||
_spawnTimer = 0f;
|
||||
}
|
||||
|
||||
_remainingDuration -= Time.deltaTime;
|
||||
|
||||
if (currentPhase.Type != ProductionPhaseType.Pause)
|
||||
{
|
||||
_spawnTimer -= Time.deltaTime;
|
||||
|
||||
if (_spawnTimer >= 0f)
|
||||
{
|
||||
if (_remainingDuration <= 0)
|
||||
{
|
||||
ProductionPhases.RemoveAt(0);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
_spawnTimer = currentPhase.SpawnInterval;
|
||||
|
||||
Instantiate(currentPhase.Description.GetRandomProduct(), transform.position, Quaternion.identity);
|
||||
}
|
||||
|
||||
if (_remainingDuration <= 0)
|
||||
{
|
||||
ProductionPhases.RemoveAt(0);
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,3 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 13fa2421a3e649448c929ac42745ad65
|
||||
timeCreated: 1723896826
|
Reference in New Issue
Block a user