This commit is contained in:
2026-05-31 20:55:36 +02:00
parent 4655e57aaf
commit c78bdc2b2a
42 changed files with 135 additions and 7399 deletions

View File

@@ -7,18 +7,11 @@ using System.Collections.Generic;
public class ObjectSpawner : MonoBehaviour
{
public static ObjectSpawner Instance;
<<<<<<< HEAD
[SerializeField]
private List<GameObject> spawnedHoles = new List<GameObject>();
[Header("Prefaby")]
public GameObject[] objectPrefabs;
=======
[Header("Prefaby")]
public GameObject[] objectPrefabs;
public GameObject holePrefab;
>>>>>>> origin/main
[Header("Počty")]
[Tooltip("Kolik předmětů spawnovat")]
@@ -31,7 +24,7 @@ public class ObjectSpawner : MonoBehaviour
public float holeMoveSpeed = 2f;
[Header("Spawn hranice (odpovídají kameře)")]
<<<<<<< HEAD
public float minX = 1f;
public float maxX = 1f;
public float minY = 0f;
@@ -39,20 +32,6 @@ public class ObjectSpawner : MonoBehaviour
private List<GameObject> spawnedObjects = new List<GameObject>();
=======
public float minX = -3.5f;
public float maxX = 3.5f;
public float minY = -5f;
public float maxY = 4f;
[Header("Rodiče pro přehlednost (volitelné)")]
public Transform objectParent;
public Transform holeParent;
private List<GameObject> spawnedObjects = new List<GameObject>();
private List<GameObject> spawnedHoles = new List<GameObject>();
>>>>>>> origin/main
void Awake()
{
@@ -76,7 +55,6 @@ public class ObjectSpawner : MonoBehaviour
LevelManager.Instance.ResetCounter();
}
<<<<<<< HEAD
//SpawnHoles();
SpawnObjects();
}
@@ -117,52 +95,11 @@ public class ObjectSpawner : MonoBehaviour
spawnedObjects.Add(obj);
}
Time.timeScale = 1f;
=======
SpawnHoles();
SpawnObjects();
}
void SpawnHoles()
{
for (int i = 0; i < holeCount; i++)
{
Vector2 pos = RandomPos(1f);
GameObject hole = Instantiate(holePrefab, pos, Quaternion.identity, holeParent);
Hole h = hole.GetComponent<Hole>();
if (h != null && holesMove)
{
h.hasMovement = true;
h.moveSpeed = holeMoveSpeed;
h.moveRange = new Vector2(Random.Range(0.8f, 1.8f), 0f);
}
spawnedHoles.Add(hole);
}
}
void SpawnObjects()
{
for (int i = 0; i < objectCount; i++)
{
GameObject prefab = objectPrefabs[Random.Range(0, objectPrefabs.Length)];
Vector2 pos = RandomPos(0.5f);
GameObject obj = Instantiate(prefab, pos, Quaternion.identity, objectParent);
// Náhodná barva
SpriteRenderer sr = obj.GetComponent<SpriteRenderer>();
if (sr != null)
sr.color = Random.ColorHSV(0f, 1f, 0.7f, 1f, 0.9f, 1f);
spawnedObjects.Add(obj);
}
>>>>>>> origin/main
}
public void Clear()
{
foreach (var o in spawnedObjects) if (o != null) Destroy(o);
<<<<<<< HEAD
//foreach (var h in spawnedHoles) if (h != null) Destroy(h);
//spawnedObjects.Clear();
spawnedHoles.Clear();
@@ -176,16 +113,5 @@ public class ObjectSpawner : MonoBehaviour
Random.Range(-2f, 1.5f)
);
}
=======
foreach (var h in spawnedHoles) if (h != null) Destroy(h);
spawnedObjects.Clear();
spawnedHoles.Clear();
}
Vector2 RandomPos(float margin) =>
new Vector2(
Random.Range(minX + margin, maxX - margin),
Random.Range(minY + margin, maxY - margin)
);
>>>>>>> origin/main
}