Some conflicts resolved
This commit is contained in:
@@ -7,11 +7,18 @@ 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")]
|
||||
@@ -24,6 +31,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;
|
||||
@@ -32,6 +40,19 @@ 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()
|
||||
{
|
||||
@@ -55,6 +76,7 @@ public class ObjectSpawner : MonoBehaviour
|
||||
LevelManager.Instance.ResetCounter();
|
||||
}
|
||||
|
||||
<<<<<<< HEAD
|
||||
//SpawnHoles();
|
||||
SpawnObjects();
|
||||
}
|
||||
@@ -95,11 +117,52 @@ 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();
|
||||
@@ -113,4 +176,16 @@ 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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user