using TMPro;
using UnityEngine;
using UnityEngine.UI;
namespace BulletHellTemplate
{
public class RewardEntry : MonoBehaviour
{
public Image icon; // Reward icon
public TextMeshProUGUI title; // Reward title
public TextMeshProUGUI description; // Reward description
public Button claimButton; // Button to claim the reward
public Image claimedIcon; // Icon indicating if the reward has been claimed
public TextMeshProUGUI day; // Text component to display the day number
private string rewardId;
///
/// Sets up the reward entry UI.
///
/// Icon to display
/// Title of the reward
/// Description of the reward
/// Unique ID of the reward
/// Day number of the reward
public void Setup(Sprite _icon, string _title, string _description, string _rewardId, int _dayNumber)
{
icon.sprite = _icon;
title.text = _title;
description.text = _description;
day.text = $"Day {_dayNumber}"; // Set the day text
rewardId = _rewardId;
claimedIcon.gameObject.SetActive(false); // Hide claimed icon initially
claimButton.onClick.RemoveAllListeners();
// The claim action is assigned by the manager using EnableClaimButton
}
///
/// Marks the reward as claimed and updates the UI.
///
public void SetClaimed()
{
claimButton.interactable = false; // Disable claim button
claimedIcon.gameObject.SetActive(true); // Show claimed icon
}
///
/// Disables the claim button for unclaimable rewards.
///
public void SetLocked()
{
claimButton.interactable = false; // Disable claim button
claimedIcon.gameObject.SetActive(false); // Ensure claimed icon is hidden
}
///
/// Enables the claim button with a click action.
///
/// Action to perform when claimed
public void EnableClaimButton(UnityEngine.Events.UnityAction claimAction)
{
claimButton.onClick.RemoveAllListeners();
claimButton.onClick.AddListener(claimAction);
claimButton.interactable = true;
}
}
}