// *********************************************************************** // Assembly : Game // Author : Kimch // Created : 2021-04-12 // Description : // Last Modified By : // Last Modified On : // *********************************************************************** // // // *********************************************************************** using DG.Tweening; using TMPro; using UnityEngine; using UnityEngine.UI; namespace G.UI { /// /// /// public class BeautySkinPanel : KUIWidget { class BeautySkinItemWidget : KUIWidget { #pragma warning disable CS0649 // 从未对字段赋值,字段将一直保持其默认值 null [KUIFlag] TextMeshProUGUI _tmpName; [KUIFlag] TextMeshProUGUI _tmpLabel; [KUIFlag] Image _imgIcon; [KUIFlag] Button _btnState; [KUIFlag] TextMeshProUGUI _tmpState; [KUIFlag] Image _imgCostIcon; [KUIFlag] TextMeshProUGUI _tmpCostCount; #pragma warning restore CS0649 // 从未对字段赋值,字段将一直保持其默认值 null public override void Refresh() { if (this.data is BeautyProxy.BeautyInfo beautyInfo) { ItemBeautySkin skin = beautyInfo.skins[this.index]; //_tmpLabel.text = skin.label; _tmpName.text = skin.name; if (skin.icon != null && skin.icon.Length > 0) IconProxy.Instance.SetSpriteAsync(_imgIcon, skin.icon[0]); if (skin.isHave) { if (beautyInfo.IsSetSkin(skin)) { _btnState.gameObject.SetActive(false); } else { _btnState.gameObject.SetActive(true); _tmpState.text = "穿戴"; } RefreshCost(0, 0); } else { _btnState.gameObject.SetActive(true); _tmpState.text = "兑换"; RefreshCost(skin.cost[0], skin.cost[1]); } //StartCoroutine(BeautyWindow.LoadBeautySkin(skin, _imgPicture, _skeleton)); } } void RefreshCost(int id, int count) { if (id == 0) { _imgCostIcon.gameObject.SetActive(false); _tmpCostCount.gameObject.SetActive(false); } else { _imgCostIcon.gameObject.SetActive(true); _tmpCostCount.gameObject.SetActive(true); var propItem = ItemProxy.Instance.GetStaticItem(id); if (propItem != null) IconProxy.Instance.SetSprite(_imgCostIcon, propItem.icon); _tmpCostCount.text = "x" + count.ToString(); } } private void OnBtnClick() { if (this.data is BeautyProxy.BeautyInfo beautyInfo) { ItemBeautySkin skin = beautyInfo.skins[this.index]; PostNotification(GlobalDefine.EVENT_BEAUTY_SKIN, skin); } } private void OnStateBtnClick() { if (this.data is BeautyProxy.BeautyInfo beautyInfo) { ItemBeautySkin skin = beautyInfo.skins[this.index]; if (skin.isHave) { if (!beautyInfo.IsSetSkin(skin)) { if (BeautyProxy.Instance.SetSkin(beautyInfo, skin)) { PostNotification(GlobalDefine.EVENT_BEAUTY_SKIN, skin); _Instance.Refresh(); } } } else { var costInfo = skin.costInfo; if (MoneyProxy.Instance.CheckAndCostMoney(costInfo)) { if (BeautyProxy.Instance.BuySkin(beautyInfo, skin)) PostNotification(GlobalDefine.EVENT_SHOW_TOAST, "兑换成功"); Refresh(); } else { PostNotification(GlobalDefine.EVENT_SHOW_TOAST, KLocalization.GetLocalString(36)); } } } SoundProxy.PlayFxAsync(GlobalDefine.BUTTON_CLICK_SOUND); } private void Awake() { SetViewData(); GetComponent