| 12345678910111213141516171819202122232425262728293031323334353637 |
- using UnityEngine;
- using System.Collections;
- using System.Collections.Generic;
- [System.Serializable]
- public class SpawnEntry
- {
- public MonsterData monsterData;
- public Vector3 position;
- }
- public class MonsterSpawner : MonoBehaviour
- {
- public List<SpawnEntry> spawnList;
- public Transform monsterParent;
- public void SpawnAll()
- {
- foreach (var entry in spawnList)
- {
- GameObject groupObject = new GameObject("MonsterGroup_" + entry.monsterData.monsterName);
- groupObject.transform.position = entry.position;
- groupObject.transform.parent = monsterParent;
- MonsterFormationGroup group = groupObject.AddComponent<MonsterFormationGroup>();
- group.monsterData = entry.monsterData;
- group.anchorPosition = entry.position;
- group.Spawn(); // 👈 c'est là que tout se passe
- }
- }
- private void Start()
- {
- SpawnAll();
- }
- }
|