// *********************************************************************** // Assembly : Game // Author : Kimch // Created : 2021-03-28 // Description : // Last Modified By : // Last Modified On : // *********************************************************************** // // // *********************************************************************** namespace G.UI { using TMPro; using UnityEngine; using UnityEngine.UI; /// /// /// partial class SwordWindow { /// /// 广告奖励 /// class SwordAdRewardBox : KUIWidget { [KUIFlag] Button _btnClose; [KUIFlag] Button _btnAdGet; [KUIFlag] GameObject __goGains; [KUIFlag] TextMeshProUGUI _tmpRemain; PropWidget _gainsPropWidget; SmartCostWidget _smartCostWidget; public override void Refresh() { _gainsPropWidget.SetItem(SwordProxy.Instance.adRewards); var timeInfo = TimeProxy.Instance.GetTimeInfo2(TimeProxy.剑阁广告次数); if (timeInfo.remain == timeInfo.max) { _smartCostWidget.SetFree(); _tmpRemain.text = "每日首次免费"; } else { _smartCostWidget.SetAdTicket(MoneyProxy.Instance.GetMoney(Item.Id.kAdTicket)); _tmpRemain.text = $"剩余次数:{timeInfo.remain}/{timeInfo.max - 1}"; } } void OnCloseBtnClick() { Close(); } void OnAdGetBtnClick() { SwordProxy.Instance.GetAdGains((error, message) => { if (error == 0) { Refresh(); } else { PostNotification(GlobalDefine.EVENT_SHOW_TOAST, message); } }); SoundProxy.PlayFxAsync(GlobalDefine.BUTTON_CLICK_SOUND); } private void Awake() { SetViewData(); _btnClose.onClick.AddListener(this.OnCloseBtnClick); _btnAdGet.onClick.AddListener(this.OnAdGetBtnClick); _smartCostWidget = _btnAdGet.gameObject.AddComponent(); _gainsPropWidget = __goGains.AddComponent(); } private void OnEnable() { Refresh(); } } } }