2024-08-17 13:12:00 +00:00
|
|
|
using System.Collections.Generic;
|
|
|
|
using UnityEngine;
|
|
|
|
|
2024-08-18 21:36:45 +00:00
|
|
|
public class ProductSpawner: MonoBehaviour
|
2024-08-17 13:12:00 +00:00
|
|
|
{
|
2024-08-18 21:36:45 +00:00
|
|
|
public List<Transform> PossibleOrientations;
|
|
|
|
public Vector2 yRotation;
|
2024-08-18 20:01:15 +00:00
|
|
|
|
2024-08-18 21:36:45 +00:00
|
|
|
public void SpawnProduct(ProductType type)
|
2024-08-18 20:01:15 +00:00
|
|
|
{
|
2024-08-18 21:36:45 +00:00
|
|
|
var randomIndex = Random.Range(0, PossibleOrientations.Count);
|
|
|
|
var randomOrientation = PossibleOrientations[randomIndex];
|
2024-08-17 13:12:00 +00:00
|
|
|
|
2024-08-18 21:36:45 +00:00
|
|
|
var rotation = Quaternion.AngleAxis(Random.Range(yRotation.x, yRotation.y), Vector3.up) *
|
|
|
|
randomOrientation.rotation;
|
2024-08-17 13:12:00 +00:00
|
|
|
|
2024-08-18 21:36:45 +00:00
|
|
|
ProductType.SpawnProduct(type, transform, randomOrientation.position, rotation);
|
2024-08-17 13:12:00 +00:00
|
|
|
}
|
2024-08-18 22:26:03 +00:00
|
|
|
|
|
|
|
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);
|
|
|
|
}
|
2024-08-18 21:36:45 +00:00
|
|
|
}
|