mirror of
https://github.com/nothke/quality-control.git
synced 2024-12-22 07:47:30 +00:00
Item spawn update.
This commit is contained in:
parent
b58dc516e1
commit
1b0cf8d159
@ -262,6 +262,67 @@ Transform:
|
|||||||
m_CorrespondingSourceObject: {fileID: 4626647624635935874, guid: 52253a366fba6644b8983c5cf7fbfc9f, type: 3}
|
m_CorrespondingSourceObject: {fileID: 4626647624635935874, guid: 52253a366fba6644b8983c5cf7fbfc9f, type: 3}
|
||||||
m_PrefabInstance: {fileID: 27502696}
|
m_PrefabInstance: {fileID: 27502696}
|
||||||
m_PrefabAsset: {fileID: 0}
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
--- !u!1001 &54662197
|
||||||
|
PrefabInstance:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
serializedVersion: 2
|
||||||
|
m_Modification:
|
||||||
|
serializedVersion: 3
|
||||||
|
m_TransformParent: {fileID: 0}
|
||||||
|
m_Modifications:
|
||||||
|
- target: {fileID: 270648843518875621, guid: 14d16caaceafb634f87449e796c4543a, type: 3}
|
||||||
|
propertyPath: m_LocalPosition.x
|
||||||
|
value: -5.343111
|
||||||
|
objectReference: {fileID: 0}
|
||||||
|
- target: {fileID: 270648843518875621, guid: 14d16caaceafb634f87449e796c4543a, type: 3}
|
||||||
|
propertyPath: m_LocalPosition.y
|
||||||
|
value: 0.625
|
||||||
|
objectReference: {fileID: 0}
|
||||||
|
- target: {fileID: 270648843518875621, guid: 14d16caaceafb634f87449e796c4543a, type: 3}
|
||||||
|
propertyPath: m_LocalPosition.z
|
||||||
|
value: 5.7854557
|
||||||
|
objectReference: {fileID: 0}
|
||||||
|
- target: {fileID: 270648843518875621, guid: 14d16caaceafb634f87449e796c4543a, type: 3}
|
||||||
|
propertyPath: m_LocalRotation.w
|
||||||
|
value: 1
|
||||||
|
objectReference: {fileID: 0}
|
||||||
|
- target: {fileID: 270648843518875621, guid: 14d16caaceafb634f87449e796c4543a, type: 3}
|
||||||
|
propertyPath: m_LocalRotation.x
|
||||||
|
value: 0
|
||||||
|
objectReference: {fileID: 0}
|
||||||
|
- target: {fileID: 270648843518875621, guid: 14d16caaceafb634f87449e796c4543a, type: 3}
|
||||||
|
propertyPath: m_LocalRotation.y
|
||||||
|
value: 0
|
||||||
|
objectReference: {fileID: 0}
|
||||||
|
- target: {fileID: 270648843518875621, guid: 14d16caaceafb634f87449e796c4543a, type: 3}
|
||||||
|
propertyPath: m_LocalRotation.z
|
||||||
|
value: 0
|
||||||
|
objectReference: {fileID: 0}
|
||||||
|
- target: {fileID: 270648843518875621, guid: 14d16caaceafb634f87449e796c4543a, type: 3}
|
||||||
|
propertyPath: m_LocalEulerAnglesHint.x
|
||||||
|
value: 0
|
||||||
|
objectReference: {fileID: 0}
|
||||||
|
- target: {fileID: 270648843518875621, guid: 14d16caaceafb634f87449e796c4543a, type: 3}
|
||||||
|
propertyPath: m_LocalEulerAnglesHint.y
|
||||||
|
value: 0
|
||||||
|
objectReference: {fileID: 0}
|
||||||
|
- target: {fileID: 270648843518875621, guid: 14d16caaceafb634f87449e796c4543a, type: 3}
|
||||||
|
propertyPath: m_LocalEulerAnglesHint.z
|
||||||
|
value: 0
|
||||||
|
objectReference: {fileID: 0}
|
||||||
|
- target: {fileID: 3486484010427172590, guid: 14d16caaceafb634f87449e796c4543a, type: 3}
|
||||||
|
propertyPath: m_Name
|
||||||
|
value: Produced E
|
||||||
|
objectReference: {fileID: 0}
|
||||||
|
- target: {fileID: 4275785426082247918, guid: 14d16caaceafb634f87449e796c4543a, type: 3}
|
||||||
|
propertyPath: Defect
|
||||||
|
value: 2048
|
||||||
|
objectReference: {fileID: 0}
|
||||||
|
m_RemovedComponents: []
|
||||||
|
m_RemovedGameObjects: []
|
||||||
|
m_AddedGameObjects: []
|
||||||
|
m_AddedComponents: []
|
||||||
|
m_SourcePrefab: {fileID: 100100000, guid: 14d16caaceafb634f87449e796c4543a, type: 3}
|
||||||
--- !u!1001 &169426980
|
--- !u!1001 &169426980
|
||||||
PrefabInstance:
|
PrefabInstance:
|
||||||
m_ObjectHideFlags: 0
|
m_ObjectHideFlags: 0
|
||||||
@ -1142,6 +1203,10 @@ PrefabInstance:
|
|||||||
propertyPath: ProductionPhases.Array.data[0].TotalSpawnCount
|
propertyPath: ProductionPhases.Array.data[0].TotalSpawnCount
|
||||||
value: 15
|
value: 15
|
||||||
objectReference: {fileID: 0}
|
objectReference: {fileID: 0}
|
||||||
|
- target: {fileID: 6695070873418123376, guid: a3cb7267f99421c4b9912896d1eb7a41, type: 3}
|
||||||
|
propertyPath: ProductionPhases.Array.data[0].ProductType
|
||||||
|
value:
|
||||||
|
objectReference: {fileID: 11400000, guid: 42240b227563f074aa0dd8fee3c0cb35, type: 2}
|
||||||
- target: {fileID: 9072778288000056937, guid: a3cb7267f99421c4b9912896d1eb7a41, type: 3}
|
- target: {fileID: 9072778288000056937, guid: a3cb7267f99421c4b9912896d1eb7a41, type: 3}
|
||||||
propertyPath: m_LocalPosition.x
|
propertyPath: m_LocalPosition.x
|
||||||
value: 9.5
|
value: 9.5
|
||||||
@ -2809,7 +2874,7 @@ PrefabInstance:
|
|||||||
objectReference: {fileID: 0}
|
objectReference: {fileID: 0}
|
||||||
- target: {fileID: 8361960510235702639, guid: cdb590802e3f6bd4db6d5eddce994501, type: 3}
|
- target: {fileID: 8361960510235702639, guid: cdb590802e3f6bd4db6d5eddce994501, type: 3}
|
||||||
propertyPath: m_LocalPosition.z
|
propertyPath: m_LocalPosition.z
|
||||||
value: 4.5982304
|
value: -3.1517696
|
||||||
objectReference: {fileID: 0}
|
objectReference: {fileID: 0}
|
||||||
- target: {fileID: 8361960510235702639, guid: cdb590802e3f6bd4db6d5eddce994501, type: 3}
|
- target: {fileID: 8361960510235702639, guid: cdb590802e3f6bd4db6d5eddce994501, type: 3}
|
||||||
propertyPath: m_LocalRotation.w
|
propertyPath: m_LocalRotation.w
|
||||||
@ -4249,7 +4314,7 @@ PrefabInstance:
|
|||||||
- target: {fileID: 7838576090119534409, guid: ae50320a2d4c84c4391086045d06a9c9, type: 3}
|
- target: {fileID: 7838576090119534409, guid: ae50320a2d4c84c4391086045d06a9c9, type: 3}
|
||||||
propertyPath: conversionProduct
|
propertyPath: conversionProduct
|
||||||
value:
|
value:
|
||||||
objectReference: {fileID: 11400000, guid: 1e626f6e0e642b44aaeb77b6628c8be7, type: 2}
|
objectReference: {fileID: 11400000, guid: 6f11438f5cec6a24cb2a32fccc6244d1, type: 2}
|
||||||
m_RemovedComponents:
|
m_RemovedComponents:
|
||||||
- {fileID: 7530552424279411822, guid: ae50320a2d4c84c4391086045d06a9c9, type: 3}
|
- {fileID: 7530552424279411822, guid: ae50320a2d4c84c4391086045d06a9c9, type: 3}
|
||||||
m_RemovedGameObjects: []
|
m_RemovedGameObjects: []
|
||||||
@ -4284,3 +4349,4 @@ SceneRoots:
|
|||||||
- {fileID: 721670239}
|
- {fileID: 721670239}
|
||||||
- {fileID: 1382857590}
|
- {fileID: 1382857590}
|
||||||
- {fileID: 447484957}
|
- {fileID: 447484957}
|
||||||
|
- {fileID: 54662197}
|
||||||
|
@ -22,6 +22,8 @@ public class HammerableRigidbody: RigidbodyInteractable
|
|||||||
}
|
}
|
||||||
|
|
||||||
var clip = product.Type.SelectClip(product.Defect != DefectType.None);
|
var clip = product.Type.SelectClip(product.Defect != DefectType.None);
|
||||||
NAudio.Play(clip, transform.position);
|
clip.Play(
|
||||||
|
transform.position,
|
||||||
|
Random.Range(0.8f, 1.2f));
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -62,7 +62,7 @@ public class Converter: MonoBehaviour, IResetable
|
|||||||
|
|
||||||
if (inputProducts[0].Type == expectedReagent)
|
if (inputProducts[0].Type == expectedReagent)
|
||||||
{
|
{
|
||||||
Spawner.SpawnProduct(conversionProduct);
|
Spawner.SpawnProduct(conversionProduct, currentProduct.Defect);
|
||||||
inputProducts.RemoveAt(0);
|
inputProducts.RemoveAt(0);
|
||||||
Destroy(currentProduct);
|
Destroy(currentProduct);
|
||||||
}
|
}
|
||||||
|
@ -1,14 +1,17 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
using UnityEngine.Serialization;
|
||||||
|
|
||||||
public class DoubleConverter: MonoBehaviour, IResetable
|
public class DoubleConverter: MonoBehaviour, IResetable
|
||||||
{
|
{
|
||||||
public ProductSpawner Spawner;
|
public ProductSpawner Spawner;
|
||||||
public List<Product> inputProducts;
|
public List<Product> inputTypeOne;
|
||||||
|
public List<Product> inputTypeTwo;
|
||||||
|
public List<Product> refuse;
|
||||||
|
|
||||||
public ProductType expectedReagent;
|
public ProductType expectedReagentA;
|
||||||
public Transform outputPoint;
|
public ProductType expectedReagentB;
|
||||||
public ProductType conversionProduct;
|
public ProductType conversionProduct;
|
||||||
|
|
||||||
public int CurrentHealth;
|
public int CurrentHealth;
|
||||||
@ -18,16 +21,25 @@ public class DoubleConverter: MonoBehaviour, IResetable
|
|||||||
private float _conversionTimer;
|
private float _conversionTimer;
|
||||||
|
|
||||||
public Transform refuseLauncher;
|
public Transform refuseLauncher;
|
||||||
public float launchPower = 10f;
|
public float launchPower = 5f;
|
||||||
|
|
||||||
public void OnTriggerEnter(Collider other)
|
public void OnTriggerEnter(Collider other)
|
||||||
{
|
{
|
||||||
var product = other.GetComponentInParent<Product>();
|
var product = other.GetComponentInParent<Product>();
|
||||||
|
|
||||||
if (product)
|
|
||||||
{
|
|
||||||
product.gameObject.SetActive(false);
|
product.gameObject.SetActive(false);
|
||||||
inputProducts.Add(product);
|
|
||||||
|
if (product.Type == expectedReagentA)
|
||||||
|
{
|
||||||
|
inputTypeOne.Add(product);
|
||||||
|
}
|
||||||
|
else if (product.Type == expectedReagentB)
|
||||||
|
{
|
||||||
|
inputTypeTwo.Add(product);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
refuse.Add(product);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -41,7 +53,9 @@ public class DoubleConverter: MonoBehaviour, IResetable
|
|||||||
_conversionTimer = conversionDuration;
|
_conversionTimer = conversionDuration;
|
||||||
CurrentHealth = MaxHealth;
|
CurrentHealth = MaxHealth;
|
||||||
|
|
||||||
inputProducts.Clear();
|
inputTypeOne.Clear();
|
||||||
|
inputTypeTwo.Clear();
|
||||||
|
refuse.Clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Update()
|
public void Update()
|
||||||
@ -51,25 +65,30 @@ public class DoubleConverter: MonoBehaviour, IResetable
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (inputProducts.Count == 0)
|
if (refuse.Count == 0 && inputTypeOne.Count == 0 && inputTypeTwo.Count == 0)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_conversionTimer <= 0f)
|
if (_conversionTimer <= 0f)
|
||||||
{
|
{
|
||||||
var currentProduct = inputProducts[0];
|
if (refuse.Count > 0)
|
||||||
|
|
||||||
if (inputProducts[0].Type == expectedReagent)
|
|
||||||
{
|
{
|
||||||
Spawner.SpawnProduct(conversionProduct);
|
Expel(refuse[0]);
|
||||||
inputProducts.RemoveAt(0);
|
refuse.RemoveAt(0);
|
||||||
Destroy(currentProduct);
|
_conversionTimer = conversionDuration;
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
else
|
|
||||||
|
if (inputTypeOne.Count > 0 && inputTypeTwo.Count > 0)
|
||||||
{
|
{
|
||||||
Expel(inputProducts[0]);
|
DefectType defectType = inputTypeOne[0].Defect & inputTypeTwo[0].Defect;
|
||||||
inputProducts.RemoveAt(0);
|
|
||||||
|
inputTypeOne.RemoveAt(0);
|
||||||
|
inputTypeTwo.RemoveAt(0);
|
||||||
|
|
||||||
|
Spawner.SpawnProduct(conversionProduct, defectType);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
_conversionTimer = conversionDuration;
|
_conversionTimer = conversionDuration;
|
||||||
|
@ -16,4 +16,15 @@ public class ProductSpawner: MonoBehaviour
|
|||||||
|
|
||||||
ProductType.SpawnProduct(type, transform, randomOrientation.position, rotation);
|
ProductType.SpawnProduct(type, transform, randomOrientation.position, rotation);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void SpawnProduct(ProductType type, DefectType defect)
|
||||||
|
{
|
||||||
|
var randomIndex = Random.Range(0, PossibleOrientations.Count);
|
||||||
|
var randomOrientation = PossibleOrientations[randomIndex];
|
||||||
|
|
||||||
|
var rotation = Quaternion.AngleAxis(Random.Range(yRotation.x, yRotation.y), Vector3.up) *
|
||||||
|
randomOrientation.rotation;
|
||||||
|
|
||||||
|
ProductType.SpawnProduct(type, defect, transform, randomOrientation.position, rotation);
|
||||||
|
}
|
||||||
}
|
}
|
@ -27,6 +27,13 @@ public class ProductType : ScriptableObject
|
|||||||
newProduct.ApplyDefect(type.SelectDefect());
|
newProduct.ApplyDefect(type.SelectDefect());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void SpawnProduct(ProductType type, DefectType defect, Transform parent, Vector3 position, Quaternion rotation)
|
||||||
|
{
|
||||||
|
var newProduct = Instantiate(type.Prefab, position, rotation, parent);
|
||||||
|
newProduct.Type = type;
|
||||||
|
newProduct.ApplyDefect(defect);
|
||||||
|
}
|
||||||
|
|
||||||
public DefectType SelectDefect()
|
public DefectType SelectDefect()
|
||||||
{
|
{
|
||||||
float randomValue = Random.Range(0, 100);
|
float randomValue = Random.Range(0, 100);
|
||||||
|
Loading…
Reference in New Issue
Block a user