using IVDataFormat; using TMPro; using UnityEngine; public class ObjectIndicator : MonoBehaviour { [SerializeField] ExtendImage iconImage; public ExtendImage IconImage => iconImage; [SerializeField] RectTransform[] starImages; [SerializeField] ExtendImage gradeBGImage; public ExtendImage GradeBGImage => gradeBGImage; [SerializeField] ExtendImage gradeLetterImage; public ExtendImage GradeLetterImage => gradeLetterImage; [SerializeField] TextMeshProUGUI countText; [SerializeField] bool isShowCountText = true; public bool IsShowCountText { get => isShowCountText; set { if(isShowCountText != value) { isShowCountText = value; countText.gameObject.SetActive(isShowCountText); } } } [SerializeField] TextMeshProUGUI levelText; [SerializeField] bool isShowLevelText = true; private void OnEnable() { countText.gameObject.SetActive(isShowCountText); levelText.gameObject.SetActive(isShowLevelText); } public void SetStar(int starCount) { for (int i = 0; i < starImages.Length; ++i) starImages[i].gameObject.SetActive(i < starCount); } public void SetLevelText(uint level) { if (isShowLevelText) { levelText.text = FormatString.StringFormat("Lv. {0}", level); levelText.gameObject.SetActive(true); } } public void SetCountText(string countStr) { if (isShowCountText) { countText.text = countStr; countText.gameObject.SetActive(true); } } } public static class ObjectIndicatorSetter { public static void SetWith(ObjectIndicator indicator, MateData mateData) { if (indicator is null || mateData is null) return; indicator.IconImage.SetImageInAtlasAsync(mateData.SDImgAtlasPath, mateData.SDImgNameInAtlas); indicator.IconImage.gameObject.SetActive(true); indicator.SetStar(0); indicator.GradeBGImage.SetImageInAtlasAsync(mateData.GradeImgAtlasPath, mateData.GradeImgNameInAtlas); indicator.GradeLetterImage.SetImageInAtlasAsync(mateData.GradeLetterImgAtlasPath, mateData.GradeLetterImgNameInAtlas); indicator.GradeLetterImage.gameObject.SetActive(true); indicator.SetLevelText(mateData.Level); } public static void SetWith(ObjectIndicator indicator, nGoods goods) { indicator.IconImage.ImageComponent.sprite = AddressableMgr.GetIcon(goods.propertyType, goods.propertyId); indicator.IconImage.gameObject.SetActive(true); indicator.SetCountText(goods.propertyCount > 0 ? goods.propertyCount.ToString() : string.Empty); indicator.SetStar(0); indicator.GradeLetterImage.gameObject.SetActive(false); switch (goods.propertyType) { case cGoods.TCurrency: indicator.GradeBGImage.SetImageInAtlasAsync(GameProperty.Instance.GradeIconAtlasName, "9"); indicator.GradeBGImage.gameObject.SetActive(true); break; case cGoods.TBagWeapon: case cGoods.TBagArmorCape: case cGoods.TBagArmorHat: case cGoods.TBagArmorShoes: case cGoods.TBagAcceEar: case cGoods.TBagAcceNeck: case cGoods.TBagAcceRing: dGear gear = DataHandler.GetGearEquip(goods.propertyType, goods.propertyId); indicator.GradeBGImage.SetImageInAtlasAsync(GameProperty.Instance.GradeIconAtlasName, gear.rarity.ToString()); indicator.GradeBGImage.gameObject.SetActive(true); indicator.GradeLetterImage.SetImageInAtlasAsync(GameProperty.Instance.GradeLetterIconDefaultName, gear.rarity.ToString()); indicator.GradeLetterImage.gameObject.SetActive(true); indicator.SetStar(gear.grade); break; case cGoods.TPet: //TODO : set indicator for pet //int rarity = DataHandler.GetPetRarity(goods.propertyId); break; case cGoods.TPetSpirit: //TODO : set indicator for pet spirit //int rarity = DataHandler.GetPetRarity(goods.propertyId); break; case cGoods.TSkillActive: case cGoods.TSkillPassive: //TODO : set indicator for skill //int rarity = DataHandler.GetSkillRarity(goods.propertyType, goods.propertyId); break; case cGoods.TBox: dBox box = DataHandler.SysBoxes[goods.propertyId]; indicator.SetStar(box.grade); break; } } public static void SetWith(ObjectIndicator indicator, SkillData mateSkillData) { if (indicator is null || mateSkillData is null) return; indicator.IconImage.SetImageInAtlasAsync(mateSkillData.IconImgAtlasName, mateSkillData.IconImgNameInAtlas); indicator.IconImage.gameObject.SetActive(true); indicator.SetStar(0); indicator.GradeLetterImage.gameObject.SetActive(false); } }