using System.Collections;
using System.Collections.Generic;
using Unity.BossRoom.Gameplay.GameplayObjects.Character;
using Unity.Multiplayer.Samples.BossRoom;
using Unity.Netcode;
using UnityEngine;
using UnityEngine.UI;
using TMPro;
public class SwapConfirmationPanel : MonoBehaviour
{
    [SerializeField] private GameObject confirmationPanel;
    public TextMeshProUGUI swapwithname;
    private ServerCharacter associatedCharacter; // Reference to the correct ServerCharacter instance

    public void ShowPanel(ServerCharacter character)
    {
        associatedCharacter = character; // Set the associated character
        confirmationPanel.SetActive(true);
    }

    public void OnAcceptButtonPressed()
    {
        SendDecisionToServer(true);
    }

    public void OnDeclineButtonPressed()
    {
        SendDecisionToServer(false);
    }

    private void SendDecisionToServer(bool isAccepted)
    {
        if (associatedCharacter != null)
        {
            associatedCharacter.NotifySwapDecisionRpc(isAccepted);
        }
        else
        {
            Debug.LogError("No associated ServerCharacter found for this swap decision!");
        }
        confirmationPanel.SetActive(false);
    }
    
   
}