296 lines
7.3 KiB
C#
296 lines
7.3 KiB
C#
![]() |
// ***********************************************************************
|
|||
|
// Assembly : Game
|
|||
|
// Author : Kimch
|
|||
|
// Created : 2022-01-11
|
|||
|
// Description :
|
|||
|
// Last Modified By :
|
|||
|
// Last Modified On :
|
|||
|
// ***********************************************************************
|
|||
|
// <copyright file= "FirstPayBox.View" company="Kunpo"></copyright>
|
|||
|
// <summary></summary>
|
|||
|
// ***********************************************************************
|
|||
|
namespace G.UI
|
|||
|
{
|
|||
|
using TMPro;
|
|||
|
using UnityEngine;
|
|||
|
using UnityEngine.UI;
|
|||
|
|
|||
|
/// <summary>
|
|||
|
///
|
|||
|
/// </summary>
|
|||
|
partial class FirstPayBox
|
|||
|
{
|
|||
|
class PayCellWidget : KUIWidget
|
|||
|
{
|
|||
|
[KUIFlag]
|
|||
|
Button _btnBuy;
|
|||
|
[KUIFlag]
|
|||
|
TextMeshProUGUI _tmpBuy;
|
|||
|
[KUIFlag]
|
|||
|
GameObject _imgAd;
|
|||
|
[KUIFlag]
|
|||
|
KUIImage _imgPrivilege;
|
|||
|
[KUIFlag]
|
|||
|
Image _imgAdTicket;
|
|||
|
[KUIFlag]
|
|||
|
TextMeshProUGUI _tmpAdTicketCount;
|
|||
|
|
|||
|
public override void Refresh()
|
|||
|
{
|
|||
|
if (this.data is ItemActivityParent activity)
|
|||
|
{
|
|||
|
if (FirstPayProxy.Instance.IsActivation(activity))
|
|||
|
{
|
|||
|
gameObject.SetActive(true);
|
|||
|
if (!KPlatform.Instance.QueryPay())
|
|||
|
{
|
|||
|
if (activity.id == 2)
|
|||
|
{
|
|||
|
gameObject.SetActive(false);
|
|||
|
}
|
|||
|
}
|
|||
|
if (activity.type == 1)
|
|||
|
{
|
|||
|
var mission = MissionProxy.Instance.GetMission(activity.activationMission);
|
|||
|
if (_tmpBuy)
|
|||
|
{
|
|||
|
if (mission.isRewarded)
|
|||
|
{
|
|||
|
_btnBuy.interactable = false;
|
|||
|
_tmpBuy.text = "已领取";
|
|||
|
if (_imgAd)
|
|||
|
_imgAd.SetActive(false);
|
|||
|
}
|
|||
|
else if (mission.isCompleted)
|
|||
|
{
|
|||
|
_btnBuy.interactable = true;
|
|||
|
_tmpBuy.text = "领取";
|
|||
|
if (_imgAd)
|
|||
|
_imgAd.SetActive(false);
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
_btnBuy.interactable = true;
|
|||
|
_tmpBuy.text = "前往";
|
|||
|
if (_imgAd)
|
|||
|
_imgAd.SetActive(true);
|
|||
|
}
|
|||
|
}
|
|||
|
if (_imgPrivilege)
|
|||
|
{
|
|||
|
if (!mission.isCompleted)
|
|||
|
{
|
|||
|
var card = RmbShopProxy.Instance.IsActivitionCard();
|
|||
|
var adTickets = MoneyProxy.Instance.GetMoney(Item.Id.kAdTicket);
|
|||
|
if (card ==3)
|
|||
|
{
|
|||
|
_imgPrivilege.gameObject.SetActive(true);
|
|||
|
_imgPrivilege.ShowSprite(1);
|
|||
|
_imgAdTicket.gameObject.SetActive(false);
|
|||
|
_tmpAdTicketCount.gameObject.SetActive(false);
|
|||
|
}
|
|||
|
else if (card == 4)
|
|||
|
{
|
|||
|
_imgPrivilege.gameObject.SetActive(true);
|
|||
|
_imgPrivilege.ShowSprite(0);
|
|||
|
_imgAdTicket.gameObject.SetActive(false);
|
|||
|
_tmpAdTicketCount.gameObject.SetActive(false);
|
|||
|
}
|
|||
|
else if (adTickets > 0)
|
|||
|
{
|
|||
|
_imgAdTicket.gameObject.SetActive(true);
|
|||
|
_tmpAdTicketCount.gameObject.SetActive(true);
|
|||
|
_tmpAdTicketCount.text = "x" + adTickets.ToString();
|
|||
|
_imgPrivilege.gameObject.SetActive(false);
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
_imgPrivilege.gameObject.SetActive(false);
|
|||
|
_imgAdTicket.gameObject.SetActive(false);
|
|||
|
_tmpAdTicketCount.gameObject.SetActive(false);
|
|||
|
}
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
_imgPrivilege.gameObject.SetActive(false);
|
|||
|
_imgAdTicket.gameObject.SetActive(false);
|
|||
|
_tmpAdTicketCount.gameObject.SetActive(false);
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
gameObject.SetActive(false);
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
System.Collections.IEnumerator DelayRefresh()
|
|||
|
{
|
|||
|
yield return null;
|
|||
|
yield return null;
|
|||
|
yield return null;
|
|||
|
Refresh();
|
|||
|
}
|
|||
|
|
|||
|
void OnBuyBtnClick()
|
|||
|
{
|
|||
|
if (this.data is ItemActivityParent activity)
|
|||
|
{
|
|||
|
if (activity.type == 1)
|
|||
|
{
|
|||
|
var mission = MissionProxy.Instance.GetMission(activity.activationMission);
|
|||
|
if (mission.isRewarded)
|
|||
|
{
|
|||
|
}
|
|||
|
else if (mission.isCompleted)
|
|||
|
{
|
|||
|
MissionProxy.Instance.GainReward(mission.id, (error, message) =>
|
|||
|
{
|
|||
|
if (error == 0)
|
|||
|
Refresh();
|
|||
|
});
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
if (mission.id == 2206)
|
|||
|
{
|
|||
|
AdProxy.Instance.PlayAd("activity", "first_ad", (error, message) =>
|
|||
|
{
|
|||
|
if (error == 0)
|
|||
|
StartCoroutine(DelayRefresh());
|
|||
|
});
|
|||
|
}
|
|||
|
else if (mission.id == 2207)
|
|||
|
{
|
|||
|
if (KPlatform.Instance.QueryPay())
|
|||
|
{
|
|||
|
CloseWindow<FirstPayBox>();
|
|||
|
OpenWindow<RmbShopWindow>();
|
|||
|
}
|
|||
|
else
|
|||
|
ToastBox.ShowText(mission.description);
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
else if (activity.type == 2)
|
|||
|
{
|
|||
|
if (activity.id == 1)
|
|||
|
{
|
|||
|
if (WomenActivity.Instance.isStartWomanActivity)
|
|||
|
{
|
|||
|
OpenWindow<WomanWindow>();
|
|||
|
CloseWindow<FirstPayBox>();
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
ToastBox.ShowText("活动暂未开启");
|
|||
|
}
|
|||
|
}
|
|||
|
if (activity.id == 4)
|
|||
|
{
|
|||
|
if (QingMingActivity.Instance.isStartActivity)
|
|||
|
{
|
|||
|
OpenWindow<QingMingWindow>();
|
|||
|
CloseWindow<FirstPayBox>();
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
ToastBox.ShowText("活动暂未开启");
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
private void Awake()
|
|||
|
{
|
|||
|
SetViewData();
|
|||
|
if(_btnBuy)
|
|||
|
_btnBuy.onClick.AddListener(this.OnBuyBtnClick);
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
#region Auto Generate
|
|||
|
|
|||
|
#pragma warning disable CS0649 // 从未对字段赋值,字段将一直保持其默认值 null
|
|||
|
[KUIFlag]
|
|||
|
Button _btnBack;
|
|||
|
[KUIFlag]
|
|||
|
Button _btnClose;
|
|||
|
[KUIFlag]
|
|||
|
KUIList __listActivties;
|
|||
|
|
|||
|
#pragma warning restore CS0649 // 从未对字段赋值,字段将一直保持其默认值 null
|
|||
|
|
|||
|
#endregion
|
|||
|
|
|||
|
#region Field
|
|||
|
|
|||
|
PayCellWidget[] _payCellWidgets;
|
|||
|
#endregion
|
|||
|
|
|||
|
#region Method
|
|||
|
|
|||
|
/// <summary>
|
|||
|
///
|
|||
|
/// </summary>
|
|||
|
public void InitView()
|
|||
|
{
|
|||
|
SetViewData();
|
|||
|
_btnBack.onClick.AddListener(this.OnCloseBtnClick);
|
|||
|
_btnClose.onClick.AddListener(this.OnCloseBtnClick);
|
|||
|
|
|||
|
//var activties = ItemProxy.Instance.GetStaticItems<ItemActivityParent>();
|
|||
|
//_payCellWidgets = new PayCellWidget[activties.Count];
|
|||
|
var tr = __listActivties.transform;
|
|||
|
_payCellWidgets = new PayCellWidget[tr.childCount];
|
|||
|
for (int i = 0; i < tr.childCount; i++)
|
|||
|
{
|
|||
|
var activtie = ItemProxy.Instance.GetStaticItem<ItemActivityParent>(int.Parse(tr.GetChild(i).name));
|
|||
|
var child = tr.GetChild(i);
|
|||
|
if (FirstPayProxy.Instance.IsActivation(activtie))
|
|||
|
{
|
|||
|
child.gameObject.SetActive(true);
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
child.gameObject.SetActive(false);
|
|||
|
}
|
|||
|
_payCellWidgets[i] = child.gameObject.AddComponent<PayCellWidget>();
|
|||
|
_payCellWidgets[i].SetData(activtie);
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
/// <summary>
|
|||
|
///
|
|||
|
/// </summary>
|
|||
|
public void RefreshView()
|
|||
|
{
|
|||
|
foreach (var item in _payCellWidgets)
|
|||
|
{
|
|||
|
item.Refresh();
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
/// <summary>
|
|||
|
///
|
|||
|
/// </summary>
|
|||
|
public void UpdateView()
|
|||
|
{
|
|||
|
}
|
|||
|
|
|||
|
void OnCloseBtnClick()
|
|||
|
{
|
|||
|
CloseWindow(this);
|
|||
|
}
|
|||
|
|
|||
|
#endregion
|
|||
|
}
|
|||
|
}
|