using UnityEngine;
using UnityEngine.UI;
using TMPro;
using System.Collections.Generic;
namespace Watermelon.SquadShooter
{
///
/// Manages the behavior of weapon card drops, including setting card data and applying rewards.
///
public class WeaponCardDropBehavior : BaseDropBehavior
{
[SerializeField] Image itemImage;
[SerializeField] Image backImage;
[SerializeField] TextMeshProUGUI titleText;
[SerializeField] GameObject particleObject;
[SerializeField] List rarityParticles = new List();
private TweenCase scaleTweenCase;
///
/// Sets the data for the weapon card, including visuals and particle effects.
///
/// The weapon data to set.
public void SetCardData(WeaponData weapon)
{
if (weapon == null)
{
Debug.LogError("Weapon data is null!");
return;
}
itemImage.sprite = weapon.Icon;
backImage.color = weapon.RarityData.MainColor;
titleText.text = weapon.WeaponName;
if (rarityParticles != null && rarityParticles.Count > 0)
{
foreach (ParticleSystem particle in rarityParticles)
{
if (particle != null)
{
ParticleSystem.MainModule main = particle.main;
main.startColor = weapon.RarityData.MainColor.SetAlpha(main.startColor.color.a);
}
}
}
}
///
/// Applies the reward for picking up the weapon card drop.
///
/// Whether to automatically reward the player.
public override void ApplyReward(bool autoReward = false)
{
}
///
/// Unloads the weapon card drop, stopping any active tweens and destroying the game object.
///
public override void Unload()
{
scaleTweenCase.KillActive();
// Destroy game object
base.Unload();
}
///
/// Called when the weapon card drop lands, triggering particle effects.
///
public override void OnItemLanded()
{
if (particleObject != null)
{
scaleTweenCase = particleObject.transform.DOScale(7f, 0.2f).SetEasing(Ease.Type.SineOut);
}
}
}
}