using System; using System.Collections.Generic; using Continentis.MainGame.UI; using DG.Tweening; using Lean.Pool; using SoulliesFramework.General; using Unity.VisualScripting; using UnityEngine; using UnityEngine.UI; namespace Continentis.MainGame.Card { public class CardViewKeywordList : UIElementBase { public CanvasGroup canvasGroup; public ScrollRect scrollRect; public RectTransform keywordsContainer; public Tweener enableTweener, disableTweener; private bool HasAnyKeyword() => keywordsContainer.childCount > 0; protected override void Awake() { base.Awake(); GetComponent().sortingLayerName = "UI"; enableTweener = canvasGroup.DOFade(1f, 0.2f).SetEase(Ease.OutQuad).SetAutoKill(false); disableTweener = canvasGroup.DOFade(0f, 0.2f).SetEase(Ease.OutQuad).SetAutoKill(false); } public void SetUp(List keywords) { keywordsContainer.DespawnAllChildren(); foreach (string keyword in keywords) { string desc = CombatMainManager.Instance.keywordCollection.GetKeywordDescription(keyword); InformationBox keywordBox = LeanPool.Spawn(MainGameManager.Instance.basePrefabs.informationBox, keywordsContainer).GetComponent(); keywordBox.Initialize(keyword, desc); } } public void Scroll(float scrollAmount) { if(!HasAnyKeyword()) { return; } float step = scrollAmount * 50f; float height = scrollRect.content.rect.height; float delta = step / height; scrollRect.verticalNormalizedPosition += delta; } public void Enable(List keywords) { SetUp(keywords); if(!HasAnyKeyword()) { return; } disableTweener.Complete(); if (!enableTweener.IsPlaying()) { enableTweener.Restart(); } } public void Disable() { if(!HasAnyKeyword()) { return; } enableTweener.Complete(); if (!disableTweener.IsPlaying()) { disableTweener.Restart(); } } } }