diff --git a/Game/Assets/Scripts/TreeDecorations.cs b/Game/Assets/Scripts/TreeDecorations.cs new file mode 100644 index 0000000..bd47449 --- /dev/null +++ b/Game/Assets/Scripts/TreeDecorations.cs @@ -0,0 +1,43 @@ +using UnityEngine; + +public class TreeDecorations : MonoBehaviour +{ + public GameObject[] decorationPrefabs; + + public int minAmount = 2; + public int maxAmount = 6; + + public float minY = -4f; + public float maxY = 4f; + + public float minScale = 0.5f; + public float maxScale = 1.5f; + + void Start() + { + int amount = Random.Range(minAmount, maxAmount + 1); + + for (int i = 0; i < amount; i++) + { + GameObject prefab = decorationPrefabs[ + Random.Range(0, decorationPrefabs.Length) + ]; + + float randomY = Random.Range(minY, maxY); + + float side = Random.value < 0.5f ? -1f : 1f; + float randomX = side * Random.Range(1.5f, 3f); + + Vector3 spawnPos = transform.position + new Vector3(randomX, randomY, 0); + + GameObject decoration = Instantiate(prefab, spawnPos, Quaternion.identity, transform); + + float randomScale = Random.Range(minScale, maxScale); + decoration.transform.localScale = new Vector3( + randomScale * side, + randomScale, + 1 + ); + } + } +} \ No newline at end of file diff --git a/Game/Assets/Scripts/TreeDecorations.cs.meta b/Game/Assets/Scripts/TreeDecorations.cs.meta new file mode 100644 index 0000000..d64b543 --- /dev/null +++ b/Game/Assets/Scripts/TreeDecorations.cs.meta @@ -0,0 +1,2 @@ +fileFormatVersion: 2 +guid: 727394ee11af15e40a3af3dee3fbb28a \ No newline at end of file