using IVDataFormat; using System.Numerics; using TMPro; using UnityEngine; using UnityEngine.UI; public class GoodsEfcItem : GoodsItem { static readonly int _rarityParam = Animator.StringToHash("Rarity"); [SerializeField] private Animator rarityEffectAnimator; protected override void Init() { imgBg = GetComponent(); imgIcon = transform.Find("icon").GetComponent(); imgRarity = transform.Find("rarity").GetComponent(); imgStars = transform.Find("stars").GetComponentsInChildren(); txtRarity = transform.Find("txtRarity").GetComponent(); txtCount = transform.Find("txtCount").GetComponent(); } public override void SetGoods(int itype, int icode, BigInteger icount, bool bpvp = false) { if (imgIcon == null) Init(); imgIcon.sprite = AddressableMgr.GetIcon(itype, icode); rarityEffectAnimator?.SetInteger(_rarityParam, 0); switch (itype) { case cGoods.TCurrency: case cGoods.TExp: case cGoods.TBagTreasure: imgIcon.enabled = true; //imgBg.color = new Color(1f, 1f, 1f); imgBg.sprite = AddressableMgr.GetGradeIcon(8);// Global.CLR_RarityBack[]; imgRarity.enabled = false; for (int i = 0; i < imgStars.Length; i++) imgStars[i].enabled = false; txtRarity.enabled = false; if (icount == 1) { txtCount.enabled = false; } else { txtCount.enabled = true; txtCount.text = icount.ToString(); } 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(itype, icode); imgIcon.enabled = true; imgRarity.enabled = true; for (int i = 0; i < imgStars.Length; ++i) imgStars[i].enabled = i < gear.grade; txtRarity.text = Global.STR_Rarity[gear.rarity]; txtRarity.enabled = true; rarityEffectAnimator?.SetInteger(_rarityParam, gear.rarity); if (icount == 1) { txtCount.enabled = false; } else { txtCount.enabled = true; txtCount.text = icount.ToString(); } imgBg.sprite = AddressableMgr.GetGradeIcon(gear.rarity); imgRarity.sprite = AddressableMgr.GetGradeLatterIcon(gear.rarity); break; case cGoods.TPet: int ipetrarity = DataHandler.GetPetRarity(icode); imgBg.color = Global.CLR_RarityBack[ipetrarity]; imgRarity.color = Global.CLR_RarityFront[ipetrarity]; imgRarity.enabled = true; for (int i = 0; i < imgStars.Length; i++) imgStars[i].enabled = false; txtRarity.text = Global.STR_Rarity[ipetrarity]; txtRarity.enabled = true; if (icount == 1) { txtCount.enabled = false; } else { txtCount.enabled = true; txtCount.text = icount.ToString(); } break; case cGoods.TPetSpirit: imgIcon.enabled = true; if (icode < 0) { imgBg.color = Global.CLR_BackPetSpirit; imgRarity.enabled = false; for (int i = 0; i < imgStars.Length; i++) imgStars[i].enabled = false; txtRarity.enabled = false; } else { int ispiritrarity = DataHandler.GetPetRarity(icode); imgBg.color = Global.CLR_RarityBack[ispiritrarity]; imgRarity.color = Global.CLR_RarityFront[ispiritrarity]; imgRarity.enabled = true; for (int i = 0; i < imgStars.Length; i++) imgStars[i].enabled = false; txtRarity.text = Global.STR_Rarity[ispiritrarity]; txtRarity.enabled = true; } if (icount == 1) { txtCount.enabled = false; } else { txtCount.enabled = true; txtCount.text = icount.ToString(); } break; case cGoods.TSkillActive: case cGoods.TSkillPassive: imgIcon.enabled = true; int iskillrarity = DataHandler.GetSkillRarity(itype, icode); imgBg.color = Global.CLR_RarityBack[iskillrarity]; imgRarity.color = Global.CLR_RarityFront[iskillrarity]; imgRarity.enabled = true; for (int i = 0; i < imgStars.Length; i++) imgStars[i].enabled = false; txtRarity.text = Global.STR_Rarity[iskillrarity]; txtRarity.enabled = true; if (icount == 1) { txtCount.enabled = false; } else { txtCount.enabled = true; txtCount.text = icount.ToString(); } break; case cGoods.TCosClrHair: case cGoods.TCosClrTop: case cGoods.TCosClrEye: imgIcon.enabled = false; imgBg.color = DataHandler.GetColor(icode); imgRarity.enabled = false; for (int i = 0; i < imgStars.Length; i++) imgStars[i].enabled = false; txtRarity.enabled = false; if (icount == 1) { txtCount.enabled = false; } else { txtCount.enabled = true; txtCount.text = icount.ToString(); } break; case cGoods.TCosCloth: case cGoods.TCosWeapon: imgIcon.enabled = true; //imgBg.color = Global.CLR_BackCos; imgRarity.enabled = false; for (int i = 0; i < imgStars.Length; i++) imgStars[i].enabled = false; txtRarity.enabled = false; if (icount == 1) { txtCount.enabled = false; } else { txtCount.enabled = true; txtCount.text = icount.ToString(); } break; case cGoods.TBox: dBox box = DataHandler.SysBoxes[icode]; imgIcon.enabled = true; imgBg.color = Global.CLR_RarityBack[box.rarity]; // 희귀도 없음. if (box.rarity <= cGoods.RNone) { imgRarity.enabled = false; for (int i = 0; i < imgStars.Length; i++) imgStars[i].enabled = false; txtRarity.enabled = false; } else { imgRarity.color = Global.CLR_RarityFront[box.rarity]; imgRarity.enabled = true; for (int i = 0; i < imgStars.Length; i++) imgStars[i].enabled = i < box.grade; txtRarity.text = Global.STR_Rarity[box.rarity]; txtRarity.enabled = true; rarityEffectAnimator?.SetInteger(_rarityParam, box.rarity); } if (icount == 1) { txtCount.enabled = false; } else { txtCount.enabled = true; txtCount.text = icount.ToString(); } break; default: imgIcon.enabled = true; imgBg.color = Global.CLR_RarityBack[cGoods.RNone]; imgRarity.enabled = false; for (int i = 0; i < imgStars.Length; i++) imgStars[i].enabled = false; txtRarity.enabled = false; if (icount == 1) { txtCount.enabled = false; } else { txtCount.enabled = true; txtCount.text = icount.ToString(); } break; } if (bpvp) imgBg.color = Color.clear; } }