using UnityEngine;
using UnityEngine.UI;

public class GameFinished3 : MonoBehaviour, IDataPresistence
{
    public Damageable NPClife1;
    public Damageable NPClife2;
    public Damageable NPClife3;

    public Test test;

    public GameData gameData;

    public Button pauseButtonUI;

    public DataPresistenceManager presistenceManager;

    public GameObject finishPanel;
    public GameObject movementBlock;

    int jawaban1;
    int jawaban2;
    int jawaban3;

    private void OnTriggerEnter2D(Collider2D collision)
    {
        Debug.Log("NPC Life: " + NPClife1.IsAlive + ", " + NPClife2.IsAlive + ", " + NPClife3.IsAlive);
        if (!NPClife1.IsAlive && !NPClife2.IsAlive && !NPClife3.IsAlive)
        {
            Debug.Log("NPC Life: " + NPClife1.IsAlive + ", " + NPClife2.IsAlive + ", " + NPClife3.IsAlive);
            for (int i = 0; i < test.collectedJawaban.Count; i++)
            {
                int item = test.collectedJawaban[i];
                if (i == 0)
                {
                    jawaban1 = item;
                    Debug.Log("Jawaban 1: " + jawaban1);
                }
                else if (i == 1)
                {
                    jawaban2 = item;
                    Debug.Log("Jawaban 2: " + jawaban2);
                }
                else if (i == 2)
                {
                    jawaban3 = item;
                    Debug.Log("Jawaban 3: " + jawaban3);
                }
            }
            presistenceManager.FinishQuitGame();
            pauseButtonUI.gameObject.SetActive(false);
            finishPanel.SetActive(true);
            movementBlock.SetActive(true);
        }
    }

    public void LoadData(GameData data) {}

    public void SaveData(ref GameData data)
    {
        data.jawaban1Game3 = jawaban1;
        data.jawaban2Game3 = jawaban2;
        data.jawaban3Game3 = jawaban3;
        data.game4 = true;
    }
}
