2025-05-18 01:04:31 +08:00

418 lines
10 KiB
C#

// ***********************************************************************
// Assembly : Game
// Author : Kimch
// Created : 2022-03-21
// Description :
// Last Modified By :
// Last Modified On :
// ***********************************************************************
// <copyright file= "QingMingWindow.View" company="Kunpo"></copyright>
// <summary></summary>
// ***********************************************************************
namespace G.UI
{
using TMPro;
using UnityEngine;
using UnityEngine.UI;
/// <summary>
///
/// </summary>
partial class QingMingWindow
{
class MissionWidget : KUIWidget
{
#region Field
#pragma warning disable CS0649 // 从未对字段赋值,字段将一直保持其默认值 null
[KUIFlag]
TextMeshProUGUI _tmpDescription;
[KUIFlag]
Slider _slidProgress;
[KUIFlag]
TextMeshProUGUI _tmpProgress;
[KUIFlag]
Button _btnReceive;
[KUIFlag]
TextMeshProUGUI _tmpReceive;
[KUIFlag]
KUIList __listRewards;
#pragma warning restore CS0649 // 从未对字段赋值,字段将一直保持其默认值 null
#endregion
#region Method
public override void Refresh()
{
if (this.data is Mission mission)
{
_tmpDescription.text = mission.description;
_slidProgress.value = mission.curValue / Mathf.Max(1f, mission.maxValue);
_tmpProgress.text = $"{mission.curValue}/{mission.maxValue}";
__listRewards.Clear();
foreach (var itemInfo in mission.rewards)
{
__listRewards.GetItem<PropWidget>().SetItem(itemInfo);
}
if (mission.isRewarded)
{
_tmpReceive.text = "已领取";
_btnReceive.interactable = false;
}
else if (mission.isCompleted)
{
_tmpReceive.text = "领取";
_btnReceive.interactable = true;
}
else
{
_tmpReceive.text = "领取";
_btnReceive.interactable = false;
}
}
}
private void OnReceiveBtnClick() //领取任务按钮
{
if (this.data is Mission mission)
{
MissionProxy.Instance.GainReward(mission.id, (error, message) =>
{
if (error == 0)
{
GetWindow<QingMingWindow>().RefreshConversionPanle();
GetWindow<QingMingWindow>().RefreshMission();
}
});
}
SoundProxy.PlayFxAsync(GlobalDefine.BUTTON_CLICK_SOUND);
}
#endregion
#region Unity
private void Awake()
{
SetViewData();
_btnReceive.onClick.AddListener(this.OnReceiveBtnClick);
__listRewards.AddTemplate<PropWidget>(true);
}
#endregion
}
#region Field
#pragma warning disable CS0649 // 从未对字段赋值,字段将一直保持其默认值 null
[KUIFlag]
Button _btnTips;
[KUIFlag]
KUIToggleGroup __goToggles;
[KUIFlag]
GameObject __goPanel1;
[KUIFlag]
GameObject __goPanel2;
[KUIFlag]
GameObject __goPanel3;
[KUIFlag]
GameObject __goPanel4;
[KUIFlag]
Button _btnClose;
[KUIFlag]
GameObject _goGetPath;
[KUIFlag]
Button _btnClosePath;//关闭获取路径
[KUIFlag]
Button _btnGotoMission;//打开任务
[KUIFlag]
Button _btnGotoGift;//打开礼包
[KUIFlag]
Button _btnGotoLevel;//打开副本
[KUIFlag]
GameObject _goMission;
[KUIFlag]
KUIList __listMissions;
[KUIFlag]
Button _btnCloseMission;//关闭任务
[KUIFlag]
GameObject _goGetMoneyPath;
[KUIFlag]
Button _btnClosePath_1;
[KUIFlag]
Button _btnGotoGift_1;
[KUIFlag]
Button _btnGotoShop;
[KUIFlag]
GameObject _goCopy;
#pragma warning restore CS0649 // 从未对字段赋值,字段将一直保持其默认值 null
private SignIn _signInPanle;
private Conversion _conversionPanle;
private GiftBag _giftBagPanle;
private Recharge _rechargePanle;
private Toggle[] _toggles;
private bool isCheckEnd = true;
#endregion
#region Method
public void InitView()
{
SetViewData();
_btnClose.onClick.AddListener(this.OnCloseBtnClick);
_btnTips.onClick.AddListener(this.OnTipBtnClick);
_signInPanle = __goPanel1.AddComponent<SignIn>();
_conversionPanle = __goPanel2.AddComponent<Conversion>();
_giftBagPanle = __goPanel3.AddComponent<GiftBag>();
_rechargePanle = __goPanel4.AddComponent<Recharge>();
__listMissions.AddTemplate<MissionWidget>(true);
_btnClosePath.onClick.AddListener(this.OnCloesPathBtnClick);
_btnCloseMission.onClick.AddListener(this.OnCloseMissionBtnClick);
_btnGotoMission.onClick.AddListener(this.OnGotoMissionBtnClick);
_btnGotoGift.onClick.AddListener(this.OnGotoGiftBtnClick);
_btnGotoLevel.onClick.AddListener(this.OnGotoLevelBtnClick);
_btnClosePath_1.onClick.AddListener(this.OnClosePathMoneyBtnClick);
_btnGotoGift_1.onClick.AddListener(this.OnGotoGiftBtnClick);
_btnGotoShop.onClick.AddListener(this.OnGotoShopBtnClick);
if (!QingMingActivity.Instance.isSigeInActivityEnd)
{
__goToggles.onToggleSelected.AddListener(this.OnToggleSelected);
this.OnToggleSelected(0);
}
else
{
__goToggles.onToggleSelected.AddListener(this.OnToggleSelectedEnd);
}
_toggles = __goToggles.GetComponentsInChildren<Toggle>();
if (!KPlatform.Instance.QueryPay()) //非支付平台给关闭
{
_toggles[_toggles.Length - 1].gameObject.SetActive(false);
_toggles[_toggles.Length - 2].gameObject.SetActive(false);
}
}
public void RefreshView()
{
var openArg = this.data as string;
if (!string.IsNullOrEmpty(openArg))
{
if (openArg == "copy")
{
this.OpenPanle(1);
return;
}
}
if (QingMingActivity.Instance.isSigeInActivityEnd)
{
this.OpenPanle(1);
}
}
private void RefreshViewSecond() //检测活动进行阶段
{
if (QingMingActivity.Instance.isEndActivity)
{
CloseWindow(this);
}
else if (QingMingActivity.Instance.isSigeInActivityEnd && isCheckEnd)
{
this.OpenPanle(1);
__goToggles.onToggleSelected.RemoveAllListeners();
__goToggles.onToggleSelected.AddListener(this.OnToggleSelectedEnd);
if (KPlatform.Instance.QueryPay())
{
_toggles[0].transform.GetChild(0).GetComponent<Image>().color = new Color32(85, 85, 85, 255);
_toggles[2].transform.GetChild(0).GetComponent<Image>().color = new Color32(85, 85, 85, 255);
_toggles[3].transform.GetChild(0).GetComponent<Image>().color = new Color32(85, 85, 85, 255);
}
else
{
_toggles[0].transform.GetChild(0).GetComponent<Image>().color = new Color32(85, 85, 85, 255);
}
_conversionPanle.CloseGetPropBtn();
isCheckEnd = false;
}
}
/// <summary>
/// 刷新任务
/// </summary>
public void RefreshMission()
{
__listMissions.Clear();
var missions = QingMingActivity.Instance.missions;
for (int i = 0, c = missions.Count; i < c; i++)
{
var mission = missions[i];
__listMissions.GetItem().SetData(mission);
}
}
public void RefreshConversionPanle()//刷新兑换界面
{
_conversionPanle.RefreshView();
}
public void RefreshGiftBagPanle()//刷新礼包界面
{
_giftBagPanle.RefreshView();
}
public void RefreshRechargePanle()//刷新充值界面
{
_rechargePanle.RefreshView();
}
public void RefreshTimer()
{
if (QingMingActivity.Instance.isSigeInActivityEnd)
{
_conversionPanle.RefreshTimer();
}
else
{
if (__goPanel1.activeSelf)
{
_signInPanle.RefreshTimer();
}
else if (__goPanel2.activeSelf)
{
_conversionPanle.RefreshTimer();
}
else if (__goPanel3.activeSelf)
{
_giftBagPanle.RefreshTimer();
}
else if (__goPanel4.activeSelf)
{
_rechargePanle.RefreshTimer();
}
}
}
private void OnCloesPathBtnClick()//关闭获取路径
{
_goGetPath.SetActive(false);
}
private void OnCloseMissionBtnClick()//关闭任务窗
{
_goMission.SetActive(false);
}
private void OnGotoMissionBtnClick()//打开任务窗
{
_goGetPath.SetActive(false);
_goMission.SetActive(true);
RefreshMission();
}
private void OnGotoGiftBtnClick()//打开礼包界面
{
_goGetPath.SetActive(false);
_goGetMoneyPath.SetActive(false);
this.OpenPanle(2);
}
private void OnGotoLevelBtnClick()//打开副本
{
if (TimeProxy.Instance.CostTimes(TimeProxy.))
{
_goGetPath.SetActive(false);
CloseWindow(this);
GameScene.Instance.EnterCopyScene(QingMingActivity.Instance.copyId);
}
else
{
ToastBox.ShowText("今日剩余挑战次数不足");
}
}
private void OnClosePathMoneyBtnClick()
{
_goGetMoneyPath.SetActive(false);
}
private void OnGotoShopBtnClick()
{
_goGetMoneyPath.SetActive(false);
CloseWindow(this);
OpenWindow<RmbShopWindow>();
}
void OnToggleSelected(int index) //页面切换按钮
{
if (index == 0)
{
__goPanel1.SetActive(true);
__goPanel2.SetActive(false);
__goPanel3.SetActive(false);
__goPanel4.SetActive(false);
}
else if (index == 1)
{
__goPanel1.SetActive(false);
__goPanel2.SetActive(true);
__goPanel3.SetActive(false);
__goPanel4.SetActive(false);
}
else if(index == 2)
{
__goPanel1.SetActive(false);
__goPanel2.SetActive(false);
__goPanel3.SetActive(true);
__goPanel4.SetActive(false);
}
else
{
__goPanel1.SetActive(false);
__goPanel2.SetActive(false);
__goPanel3.SetActive(false);
__goPanel4.SetActive(true);
}
}
void OnToggleSelectedEnd(int index)//签到结束后页面切换按钮
{
if (index != 1)
{
this.OpenPanle(1);
ToastBox.ShowText("活动已经结束");
}
}
private void OpenPanle(int index) //打开界面
{
_toggles[index].isOn = true;
}
private void OnTipBtnClick() //提示按钮
{
MessageBox.ShowMessage(KLocalization.GetLocalString(611), KLocalization.GetLocalString(612));
SoundProxy.PlayFxAsync(GlobalDefine.BUTTON_CLICK_SOUND);
}
private void OnCloseBtnClick()
{
CloseWindow(this);
}
public void OpenGetPathPanle()//打开获取路径页面
{
_goGetPath.SetActive(true);
_goCopy.SetActive(QingMingActivity.Instance.isCopyOpen);
}
public void OpenMissionPanle()//打开任务界面
{
_goMission.SetActive(true);
RefreshMission();
}
public void OpenGetMoneyPathPanle()
{
_goGetMoneyPath.SetActive(true);
}
#endregion
}
}