// *********************************************************************** // Assembly : Game // Author : Kimch // Created : 2022-03-21 // Description : // Last Modified By : // Last Modified On : // *********************************************************************** // // // *********************************************************************** using TMPro; using UnityEngine; using UnityEngine.UI; namespace G.UI { partial class QingMingWindow { /// /// 兑换栏 /// class ConversionWidget : KUIWidget { #region Fide #pragma warning disable CS0649 // 从未对字段赋值,字段将一直保持其默认值 null [KUIFlag] Image _imgIcon; [KUIFlag] TextMeshProUGUI _tmpPrice; [KUIFlag] KUIList __listRewards; [KUIFlag] Button _btnExchange; [KUIFlag] TextMeshProUGUI _tmpDescription; #pragma warning restore CS0649 // 从未对字段赋值,字段将一直保持其默认值 null #endregion #region Method public override void Refresh() { if (this.data is ActivitySubInfo subInfo) { _tmpDescription.text = $"本期兑换{subInfo.curValue}/{subInfo.maxValue}"; if (subInfo.curValue >= subInfo.maxValue) { _tmpDescription.color = new Color32(255, 182, 91, 255); _tmpPrice.text = "已兑换"; _tmpPrice.color = Color.white; _btnExchange.interactable = false; } else { _tmpDescription.color = Color.white; _btnExchange.interactable = true; var propCostCount = subInfo.item.typeArgs[1]; var propCount = ItemProxy.Instance.GetPropCount(3001); _tmpPrice.text = propCostCount.ToString(); if (propCostCount <= propCount) { _tmpPrice.color = Color.white; } else { _tmpPrice.color = Color.red; } } if (_imgIcon) { var prop = ItemProxy.Instance.GetStaticItem(subInfo.item.typeArgs[0]); var icon = ItemProxy.Instance.GetStaticItem(prop.iconId); IconProxy.Instance.SetSprite(_imgIcon, icon.spriteInfo); } __listRewards.Clear(); foreach (var itemInfo in subInfo.rewardInfos) { __listRewards.GetItem().SetItem(itemInfo); } } } private void OnExchangeBtnCilck() //兑换 { if (this.data is ActivitySubInfo subInfo) { QingMingActivity.Instance.Exchange(subInfo.id, (error, message) => { if (error == 0) { GetWindow().RefreshConversionPanle(); PostNotification(GlobalDefine.EVENT_MONEY_CHANGED, "Exchange", "QingMing_w_Btn"); KStatistics.Instance.ReportEvent_Activity("qingming", 4,subInfo.id, "", "", 1, "", 0, 0);//埋点 } else { ToastBox.ShowText(message); } }); } } #endregion #region Unity private void Awake() { SetViewData(); _btnExchange.onClick.AddListener(this.OnExchangeBtnCilck); __listRewards.AddTemplate(true); } #endregion } /// /// 兑换界面 /// class Conversion : KUIWidget { #region Auto Generate #pragma warning disable CS0649 // 从未对字段赋值,字段将一直保持其默认值 null [KUIFlag] Button _btnSignMission;//打开任务 [KUIFlag] KUIList __listConversion; [KUIFlag] Button _btnGetPath;//打开获取路径 [KUIFlag] TextMeshProUGUI _tmpPropNumber; [KUIFlag] Button _btnIntoLevel;//进入副本 [KUIFlag] TextMeshProUGUI _tmpLastTime; [KUIFlag] TextMeshProUGUI _tmpTime2; [KUIFlag] TextMeshProUGUI _tmpLastDay; #pragma warning restore CS0649 // 从未对字段赋值,字段将一直保持其默认值 null #endregion #region Method /// /// 刷新兑换界面 /// public void RefreshView() { RefreshExchange(); var propCount = ItemProxy.Instance.GetPropCount(3001); _tmpPropNumber.text = propCount.ToString(); _tmpTime2.text = QingMingActivity.Instance.exchangeSurplusTime; if (QingMingActivity.Instance.isCopyOpen) { _btnIntoLevel.gameObject.SetActive(true); var infoTime = TimeProxy.Instance.GetTimes(TimeProxy.女神节副本挑战次数); _tmpLastTime.text = "今日剩余次数:" + infoTime; _tmpLastDay.text = QingMingActivity.Instance.copySurplusDay; if (infoTime > 0) { _tmpLastTime.color = Color.white; } else { _tmpLastTime.color = Color.red; } } else { _btnIntoLevel.gameObject.SetActive(false); } } public void RefreshTimer()//刷新时间 { if (_tmpTime2) { _tmpTime2.text = QingMingActivity.Instance.exchangeSurplusTime; } } public void RefreshExchange()//兑换栏 { __listConversion.Clear(); var exchange = QingMingActivity.Instance.exchangeActivityInfo.subInfos; foreach (var subInfo in exchange)//未兑换为 { if (subInfo.curValue < subInfo.maxValue) { __listConversion.GetItem().SetData(subInfo); } } foreach (var subInfo in exchange)//已兑换完 { if (subInfo.curValue >= subInfo.maxValue) { __listConversion.GetItem().SetData(subInfo); } } } private void OnSignMissionBtnClick()//打开任务 { if (QingMingActivity.Instance.isSigeInActivityEnd) { ToastBox.ShowText("活动已结束"); } else { GetWindow().OpenMissionPanle(); } } private void OnGetPathBtnClick()//打开获取路径 { GetWindow().OpenGetPathPanle(); } private void OnIntoLevelBtnClick()//挑战副本 { if (TimeProxy.Instance.GetTimes(TimeProxy.女神节副本挑战次数) > 0) { CloseWindow(); //LevelProxy.Instance.StartActicityLevel(40000); GameScene.Instance.EnterCopyScene(QingMingActivity.Instance.copyId); TimeProxy.Instance.CostTimes(TimeProxy.女神节副本挑战次数); } else { #if UNITY_EDITOR CloseWindow(); GameScene.Instance.EnterCopyScene(QingMingActivity.Instance.copyId); #else #endif ToastBox.ShowText("今日剩余挑战次数不足"); } } public void CloseGetPropBtn()//关闭打开任务和获取途径的按钮 { _btnGetPath.gameObject.SetActive(false); _btnSignMission.gameObject.SetActive(false); _btnIntoLevel.gameObject.SetActive(false); } #endregion #region Unity private void Awake() { SetViewData(); __listConversion.AddTemplate(true); _btnSignMission.onClick.AddListener(this.OnSignMissionBtnClick); _btnGetPath.onClick.AddListener(this.OnGetPathBtnClick); _btnIntoLevel.onClick.AddListener(this.OnIntoLevelBtnClick); } private void OnEnable() { RefreshView(); } #endregion } } }