using asap.core; using cfg; using GameCore; using TMPro; using UnityEngine; using UnityEngine.UI; public class FishCardUI : MonoBehaviour { public Image bg_card; public TMP_Text text_name; public TMP_Text text_map; public GameObject mask_fish; public Image img_icon_hd; public Image icon_tag; public Image bar; public GameObject up; public GameObject bg_bar; public TMP_Text text_bar; public TMP_Text text_level; public GameObject bg_num; public TMP_Text text_num; public GameObject text_empty; public GameObject mask_empty; public GameObject newGo; public RewardItem transfer; public FishData data; cfg.FishCard fishCard; public int curProficiency; public int curShowNum = 0; ShowImageData imageData = null; public void Init() { transfer.gameObject.SetActive(false); text_map.gameObject.SetActive(false); if (data != null) { IUIService uiService = GContext.container.Resolve(); curProficiency = curShowNum > 0 ? curShowNum : GContext.container.Resolve().GetCardDataProficiency(data.FishCardID); text_name.text = LocalizationMgr.GetText(data.Name_l10n_key); fishCard = GContext.container.Resolve().TbFishCard[data.FishCardID]; string spriteName = "fishiconhd_empty_02"; if (data.Quality < 3) { spriteName = "fishiconhd_empty_01"; } else if (data.Quality > 3) { spriteName = "fishiconhd_empty_03"; } img_icon_hd.sprite = uiService.GetSprite(spriteName); if (imageData == null) { imageData = new ShowImageData(img_icon_hd); } imageData.SetName(fishCard.Icon); uiService.SetImageSprite(imageData, BasePanel.PanelName); //设置img_icon颜色为纯白色 img_icon_hd.color = curProficiency > 0 ? Color.white : //设置img_icon颜色为纯黑色60%透明度 new Color(0, 0, 0, 0.6f); mask_fish.gameObject.SetActive(false); img_icon_hd.gameObject.SetActive(true); uiService.SetImageSprite(bg_card, $"bg_fishcard_{data.Quality}", BasePanel.PanelName); uiService.SetImageSprite(icon_tag, $"icon_fish_rate_tag_{data.Quality}", BasePanel.PanelName); SetProficiency(); } } public void SetProficiency() { curProficiency = curShowNum > 0 ? curShowNum : GContext.container.Resolve().GetCardDataProficiency(data.FishCardID); //显示锁头 newGo.SetActive(GContext.container.Resolve().GetDataNewFish(data.ID) && curProficiency > 0); mask_empty.SetActive(curProficiency == 0); text_empty.SetActive(curProficiency == 0); bg_bar.gameObject.SetActive(curProficiency > 0); text_level.gameObject.SetActive(curProficiency > 0); icon_tag.gameObject.SetActive(curProficiency > 0); up.SetActive(false); int level = GContext.container.Resolve().GetDataLevel(data.ID); text_level.text = level.ToString(); bg_num.gameObject.SetActive(false); if (curProficiency > 0) { if (level < fishCard.MaxLevel) { int endWeight = fishCard.CardsRequiredList[level]; int startWeight = level > 0 ? fishCard.CardsRequiredList[level - 1] : 0; bar.fillAmount = (curProficiency - startWeight) / (float)(endWeight - startWeight); if (curProficiency >= endWeight) { up.SetActive(true); newGo.SetActive(false); } text_bar.text = $"{curProficiency - startWeight}/{endWeight - startWeight}"; } else if (level >= fishCard.MaxLevel) { bar.fillAmount = 1; text_bar.text = LocalizationMgr.GetText("UI_FishingPanel_101007"); } } else { bar.fillAmount = 0; } } public void SetNum(int count) { text_map.gameObject.SetActive(true); var mapData = GContext.container.Resolve().TbMapData.GetOrDefault(data.AreaID); text_map.text = LocalizationMgr.GetText(mapData.Name_l10n_key); up.SetActive(false); //text_level.gameObject.SetActive(false); //if (count > 1) { bg_num.gameObject.SetActive(true); text_num.text = $"x{count}"; } } }