using System.Collections.Generic; using GameCore; using TMPro; using UnityEngine; using UnityEngine.UI; public class EventPartnerRewardTip : MonoBehaviour { [SerializeField] private GameObject rewardEmptyGo1, rewardEmptyGo2; [SerializeField] private GameObject[] rewardGos; [SerializeField] private RewardItemNew[] rewards; [SerializeField] private TMP_Text textTarget, textOwned; [SerializeField] private Button btnClose; [SerializeField] private GameObject tipGo; public void Awake() { tipGo.SetActive(false); btnClose.onClick.AddListener(() => UIManager.Instance.DestroyUI(UITypes.EventPartnerTip)); } /// /// Init this tip. /// /// Items to be shown in this tip. /// Current Score. /// Target Score. /// The position where this tip shows up. public void Init(List items, int score = 0, int targetScore = 0, Transform btnTransform = null) { if (items.Count == 1) { rewardEmptyGo1.SetActive(true); rewardEmptyGo2.SetActive(true); rewardGos[0].SetActive(true) ; for (int i = 1; i < rewardGos.Length; i++) { rewardGos[i].SetActive(false); } rewards[0].SetData(items[0]); } else if (items.Count > 1) { rewardEmptyGo1.SetActive(false); rewardEmptyGo2.SetActive(false); for (int i = 0; i < rewardGos.Length; i++) { rewardGos[i].SetActive(i < items.Count); if (i < items.Count) rewards[i].SetData(items[i]); } } // textPoint.text = LocalizationMgr.GetFormatTextValue("UI_EventPartnerFishbowlPanel_7", score, targetScore); if (textOwned) textOwned.text = LocalizationMgr.GetFormatTextValue("UI_item_tips_1", score); if (textTarget) textTarget.text = LocalizationMgr.GetFormatTextValue("UI_EventRankPopupPanel_16", targetScore); if (btnTransform) tipGo.transform.position = btnTransform.position; tipGo.SetActive(true); } }