using Photon.Pun;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class RiftSpawner : MonoBehaviour
{
    [Header("Rifts:")]
    [SerializeField] private List<GameObject> riftPrefabs = new List<GameObject>();

    [Header("Listeners:")]
    [SerializeField] private GameEventListener_RiftSettings onSpawnRiftRequest;

    GameObject spawnedRiftGO;
    Rift spawnedRift;

    private void Awake()
    {
        DontDestroyOnLoad(this);

        onSpawnRiftRequest.Response.AddListener(SpawnRiftOnRequest);
    }

    private void SpawnRiftOnRequest(RiftSettings riftSettings)
    {
        spawnedRiftGO = PhotonNetwork.Instantiate("Rifts/" + riftPrefabs[riftSettings.riftIndex].name, riftSettings.zoneData.spawnPoints[0].position, Quaternion.identity);

        spawnedRift = spawnedRiftGO.GetComponent<Rift>();

        spawnedRift.InitializeRift(riftSettings);

        spawnedRift.StartSpawning();
    }
}

[System.Serializable]
public class RiftSettings
{
    public int riftIndex;
    public Dictionary<int,int> enemyIndexes_Quantity;
    public int numberOfWaves;
    public int bossIndex;
    public ZoneData zoneData;
}
