MonsterSpawner.cs 996 B

12345678910111213141516171819202122232425262728293031323334353637
  1. using UnityEngine;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. [System.Serializable]
  5. public class SpawnEntry
  6. {
  7. public MonsterData monsterData;
  8. public Vector3 position;
  9. }
  10. public class MonsterSpawner : MonoBehaviour
  11. {
  12. public List<SpawnEntry> spawnList;
  13. public Transform monsterParent;
  14. public void SpawnAll()
  15. {
  16. foreach (var entry in spawnList)
  17. {
  18. GameObject groupObject = new GameObject("MonsterGroup_" + entry.monsterData.monsterName);
  19. groupObject.transform.position = entry.position;
  20. groupObject.transform.parent = monsterParent;
  21. MonsterFormationGroup group = groupObject.AddComponent<MonsterFormationGroup>();
  22. group.monsterData = entry.monsterData;
  23. group.anchorPosition = entry.position;
  24. group.Spawn(); // 👈 c'est là que tout se passe
  25. }
  26. }
  27. private void Start()
  28. {
  29. SpawnAll();
  30. }
  31. }