200 lines
6.9 KiB
C#
200 lines
6.9 KiB
C#
![]() |
// ***********************************************************************
|
|||
|
// Assembly : Game
|
|||
|
// Author : Kimch
|
|||
|
// Created : 2021-10-26
|
|||
|
// Description :
|
|||
|
// Last Modified By :
|
|||
|
// Last Modified On :
|
|||
|
// ***********************************************************************
|
|||
|
// <copyright file= "ShopWindow.SpecialPanel" company="Kunpo"></copyright>
|
|||
|
// <summary></summary>
|
|||
|
// ***********************************************************************
|
|||
|
namespace G.UI
|
|||
|
{
|
|||
|
using System.Collections.Generic;
|
|||
|
using TMPro;
|
|||
|
using UnityEngine;
|
|||
|
using UnityEngine.UI;
|
|||
|
/// <summary>
|
|||
|
///
|
|||
|
/// </summary>
|
|||
|
partial class RmbShopWindow
|
|||
|
{
|
|||
|
class SpecialItemWidget : KUIWidget
|
|||
|
{
|
|||
|
[KUIFlag]
|
|||
|
KUIList __listProps;
|
|||
|
[KUIFlag]
|
|||
|
TextMeshProUGUI _tmpRights;
|
|||
|
[KUIFlag]
|
|||
|
KUIImage _imgIcon;
|
|||
|
[KUIFlag]
|
|||
|
Button _btnBuy;
|
|||
|
[KUIFlag]
|
|||
|
TextMeshProUGUI _tmpBuy;
|
|||
|
[KUIFlag]
|
|||
|
TextMeshProUGUI _tmpGetCount;
|
|||
|
[KUIFlag]
|
|||
|
TextMeshProUGUI _tmpTime;
|
|||
|
[KUIFlag]
|
|||
|
GameObject _imgMoneyIcon;
|
|||
|
[KUIFlag]
|
|||
|
KUIImage _imgPricePointer;
|
|||
|
|
|||
|
|
|||
|
System.Text.StringBuilder _stringBuilder = new System.Text.StringBuilder();
|
|||
|
|
|||
|
public override void Refresh()
|
|||
|
{
|
|||
|
if (this.data is RmbShopProxy.SpecialInfo specialInfo)
|
|||
|
{
|
|||
|
int specialType = specialInfo.item.type;
|
|||
|
if (specialType == 4)
|
|||
|
{
|
|||
|
_imgIcon.ShowSprite(2);
|
|||
|
}
|
|||
|
else if (specialType == 2)
|
|||
|
{
|
|||
|
_imgIcon.ShowSprite(0);
|
|||
|
}
|
|||
|
else if (specialType == 3)
|
|||
|
{
|
|||
|
_imgIcon.ShowSprite(1);
|
|||
|
}
|
|||
|
|
|||
|
//
|
|||
|
if (specialInfo.remainDay > 0)
|
|||
|
{
|
|||
|
_imgMoneyIcon.SetActive(false);
|
|||
|
_imgPricePointer.gameObject.SetActive(false);
|
|||
|
|
|||
|
if (specialInfo.rewardTimes > 0)
|
|||
|
{
|
|||
|
_btnBuy.interactable = true;
|
|||
|
_tmpBuy.text = "领取";
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
_btnBuy.interactable = false;
|
|||
|
_tmpBuy.text = "今日已领";
|
|||
|
}
|
|||
|
|
|||
|
_tmpTime.text = specialInfo.remainDayText;
|
|||
|
if (specialInfo.validityDay > 0)
|
|||
|
{
|
|||
|
_btnBuy.interactable = false;
|
|||
|
_tmpBuy.text = "邮件已发放";
|
|||
|
}
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
_btnBuy.interactable = true;
|
|||
|
_imgMoneyIcon.SetActive(true);
|
|||
|
_tmpBuy.text = specialInfo.rmbPrice.ToString();
|
|||
|
_tmpTime.text = "";
|
|||
|
|
|||
|
if (!string.IsNullOrEmpty(specialInfo.item.discount))
|
|||
|
{
|
|||
|
_imgPricePointer.gameObject.SetActive(true);
|
|||
|
_imgPricePointer.ShowSprite(specialInfo.item.discount);
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
_imgPricePointer.gameObject.SetActive(false);
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
_tmpGetCount.text = "" + specialInfo.exchange.count;
|
|||
|
__listProps.Clear();
|
|||
|
var exchangeProps = specialInfo.dailyExchange;
|
|||
|
if (exchangeProps != null)
|
|||
|
for (int i = 0; i < exchangeProps.Length; i++)
|
|||
|
{
|
|||
|
__listProps.GetItem<PropWidget>().SetItem(exchangeProps[i]);
|
|||
|
}
|
|||
|
|
|||
|
var vipItem = ItemProxy.Instance.GetStaticItem<ItemVip>(specialInfo.item.vip);
|
|||
|
if (vipItem != null)
|
|||
|
{
|
|||
|
_stringBuilder.Clear();
|
|||
|
for (int i = 0; i < vipItem.rights.Length; i++)
|
|||
|
{
|
|||
|
VipProxy.Instance.GetRightsInfo(vipItem.rights[i], out var rightName, out var rightValue);
|
|||
|
_stringBuilder.Append(rightName);
|
|||
|
_stringBuilder.Append(' ');
|
|||
|
_stringBuilder.Append(rightValue);
|
|||
|
_stringBuilder.AppendLine();
|
|||
|
}
|
|||
|
_tmpRights.text = _stringBuilder.ToString();
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
void OnBuyBtnClick()
|
|||
|
{
|
|||
|
if (this.data is RmbShopProxy.SpecialInfo specialInfo)
|
|||
|
{
|
|||
|
if (specialInfo.remainDay > 0)
|
|||
|
{
|
|||
|
RmbShopProxy.Instance.DailyGetSpecial(specialInfo.id,
|
|||
|
(error, message) =>
|
|||
|
{
|
|||
|
if (error == 0)
|
|||
|
Refresh();
|
|||
|
});
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
RmbShopProxy.Instance.BuySpecial(specialInfo.id,
|
|||
|
(error, message) =>
|
|||
|
{
|
|||
|
if (error == 0)
|
|||
|
Refresh();
|
|||
|
});
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
private void Awake()
|
|||
|
{
|
|||
|
SetViewData();
|
|||
|
__listProps.AddTemplate<PropWidget>(true);
|
|||
|
_btnBuy.onClick.AddListener(this.OnBuyBtnClick);
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
class SpecialPanel : KUIWidget
|
|||
|
{
|
|||
|
[KUIFlag]
|
|||
|
KUIList __listSpecials;
|
|||
|
|
|||
|
public override void Refresh()
|
|||
|
{
|
|||
|
__listSpecials.Clear();
|
|||
|
var specialInfos = RmbShopProxy.Instance.GetSpecialInfos();
|
|||
|
int index = 0;
|
|||
|
foreach (var item in specialInfos)
|
|||
|
{
|
|||
|
var widget = __listSpecials.GetItem();
|
|||
|
widget.index = index++;
|
|||
|
widget.SetData(item);
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
private void Awake()
|
|||
|
{
|
|||
|
SetViewData();
|
|||
|
__listSpecials.AddTemplate<SpecialItemWidget>(true);
|
|||
|
var specialInfos = RmbShopProxy.Instance.GetSpecialInfos();
|
|||
|
if (specialInfos != null)
|
|||
|
__listSpecials.PreCreate(specialInfos.Count - 1);
|
|||
|
}
|
|||
|
|
|||
|
private void OnEnable()
|
|||
|
{
|
|||
|
Refresh();
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
}
|