371 lines
11 KiB
C#
371 lines
11 KiB
C#
using System.Collections;
|
|
using Cute;
|
|
using UnityEngine;
|
|
|
|
namespace Wizard;
|
|
|
|
public class PurchaseConfirm : MonoBehaviour
|
|
{
|
|
|
|
[SerializeField]
|
|
private UISprite _spriteConfirmItemIcon;
|
|
|
|
[SerializeField]
|
|
private UISprite _spriteHaveItemIcon;
|
|
|
|
[SerializeField]
|
|
private UITexture m_TextureConfirmTicket;
|
|
|
|
[SerializeField]
|
|
private UITexture m_TextureHaveTicket;
|
|
|
|
[SerializeField]
|
|
private UILabel m_LabelUseItemCnt;
|
|
|
|
[SerializeField]
|
|
private UILabel m_LabelBuyPack;
|
|
|
|
[SerializeField]
|
|
private UILabel m_LabelItemName;
|
|
|
|
[SerializeField]
|
|
private UILabel _premiumCardWarning;
|
|
|
|
[SerializeField]
|
|
private UILabel m_LabelBeforeItemCnt;
|
|
|
|
[SerializeField]
|
|
private UILabel m_LabelAfterItemCnt;
|
|
|
|
[SerializeField]
|
|
private UILabel m_LabelAfterItemUnit;
|
|
|
|
[SerializeField]
|
|
private GameObject _confirmObj;
|
|
|
|
[SerializeField]
|
|
private GameObject _haveObj;
|
|
|
|
[SerializeField]
|
|
private UITable _tablePackPoint;
|
|
|
|
[SerializeField]
|
|
private UILabel _labelBeforPackPoint;
|
|
|
|
[SerializeField]
|
|
private UILabel _labelAfterPackPoint;
|
|
|
|
[SerializeField]
|
|
private UITable _preReleasePointTable;
|
|
|
|
[SerializeField]
|
|
private UILabel _preReleasePointBeforeLabel;
|
|
|
|
[SerializeField]
|
|
private UILabel _preReleasePointAfterlabel;
|
|
|
|
[SerializeField]
|
|
private GameObject _preReleasePointArleadyMax;
|
|
|
|
[SerializeField]
|
|
private Transform _nonItemRoot;
|
|
|
|
[SerializeField]
|
|
private CenteringUIWidget _nonItemCentering;
|
|
|
|
[SerializeField]
|
|
private UILabel _nonItemBeforeCountLabel;
|
|
|
|
[SerializeField]
|
|
private UILabel _nonItemAfterCountLabel;
|
|
|
|
[SerializeField]
|
|
private UILabel _nonItemRemainingLabel;
|
|
|
|
[SerializeField]
|
|
private UILabel _nonItemUnitLabel;
|
|
|
|
[SerializeField]
|
|
private UILabel _campaignNameLabel;
|
|
|
|
[SerializeField]
|
|
private GameObject _rootObj;
|
|
|
|
[SerializeField]
|
|
private GameObject _jpnLawRoot;
|
|
|
|
[SerializeField]
|
|
private GameObject _saleTimeExistLayout;
|
|
|
|
[SerializeField]
|
|
private GameObject _saleTimeNoneLayout;
|
|
|
|
[SerializeField]
|
|
private UILabel _expiryTimeLabel;
|
|
|
|
private void UpdateJpnLawObj()
|
|
{
|
|
_ = _rootObj == null;
|
|
}
|
|
|
|
private void HideJpnLawObj()
|
|
{
|
|
if (!(_jpnLawRoot == null))
|
|
{
|
|
_jpnLawRoot.SetActive(value: false);
|
|
}
|
|
}
|
|
|
|
public void SetClystalConfirmDialog(int useItemNum, string purchaseText, int haveItemCnt, ShopExpirtyInfo expirtyInfo)
|
|
{
|
|
SetIconImage(UserGoods.Type.Crystal);
|
|
int afterItemNum = haveItemCnt - useItemNum;
|
|
string unit = Data.SystemText.Get("Common_0116");
|
|
string useItemNumText = Data.SystemText.Get("Shop_0091", useItemNum.ToString());
|
|
SetLabelText(Data.SystemText.Get("Common_0201"), useItemNumText, afterItemNum, unit, purchaseText, haveItemCnt);
|
|
UpdateJpnLawObj();
|
|
_expiryTimeLabel.gameObject.SetActive(expirtyInfo.IsEnableText);
|
|
_expiryTimeLabel.text = expirtyInfo.GetText();
|
|
if (_saleTimeExistLayout != null && _saleTimeNoneLayout != null)
|
|
{
|
|
_saleTimeExistLayout.SetActive(expirtyInfo.IsEnableText);
|
|
_saleTimeNoneLayout.SetActive(!expirtyInfo.IsEnableText);
|
|
}
|
|
HideJpnLawObj();
|
|
}
|
|
|
|
public void SetRupyConfirmDialog(int useItemNum, string purchaseText, int haveItemCnt)
|
|
{
|
|
SetIconImage(UserGoods.Type.Rupy);
|
|
int afterItemNum = haveItemCnt - useItemNum;
|
|
string unit = Data.SystemText.Get("Common_0120");
|
|
string useItemNumText = Data.SystemText.Get("Shop_0090", useItemNum.ToString());
|
|
SetLabelText(Data.SystemText.Get("Common_0115"), useItemNumText, afterItemNum, unit, purchaseText, haveItemCnt);
|
|
HideJpnLawObj();
|
|
}
|
|
|
|
public void SetLeaderSkinTicketConfirmDialog(int cost, string purchaseText, int haveItem, long itemId)
|
|
{
|
|
int afterItemNum = haveItem - cost;
|
|
string unit = Data.SystemText.Get("Common_0117");
|
|
string useItemNumText = Data.SystemText.Get("Shop_0042", cost.ToString());
|
|
SetLabelText(Data.SystemText.Get("Common_0114"), useItemNumText, afterItemNum, unit, purchaseText, haveItem);
|
|
SetIconImage(UserGoods.Type.Item, Item.Type.LeaderSkinTicket, Toolbox.ResourcesManager.LoadObject<Texture>(ShopCommonUtility.GetTicketIconRightDownPath(itemId.ToString(), isFetch: true)));
|
|
HideJpnLawObj();
|
|
}
|
|
|
|
private void SetIconImage(UserGoods.Type type, Item.Type ticket = (Item.Type)0, Texture packIcon = null)
|
|
{
|
|
switch (type)
|
|
{
|
|
case UserGoods.Type.Crystal:
|
|
ViewIconSprite("icon_crystal_s");
|
|
break;
|
|
case UserGoods.Type.Rupy:
|
|
ViewIconSprite("icon_rupy_s");
|
|
break;
|
|
case UserGoods.Type.Item:
|
|
switch (ticket)
|
|
{
|
|
case Item.Type.TwoPickTicket:
|
|
ViewIconSprite("icon_2pick_s");
|
|
break;
|
|
case Item.Type.CardPackTicket:
|
|
case Item.Type.LeaderSkinTicket:
|
|
_spriteConfirmItemIcon.gameObject.SetActive(value: false);
|
|
_spriteHaveItemIcon.gameObject.SetActive(value: false);
|
|
m_TextureConfirmTicket.gameObject.SetActive(value: true);
|
|
m_TextureHaveTicket.gameObject.SetActive(value: true);
|
|
m_TextureConfirmTicket.mainTexture = packIcon;
|
|
m_TextureHaveTicket.mainTexture = packIcon;
|
|
break;
|
|
case Item.Type.Orb:
|
|
ViewIconSprite("icon_orb_s");
|
|
break;
|
|
case Item.Type.OrbPiece:
|
|
ViewIconSprite("icon_orb_piece_s");
|
|
break;
|
|
}
|
|
break;
|
|
case UserGoods.Type.RedEther:
|
|
ViewIconSprite("icon_liquid_s");
|
|
break;
|
|
case UserGoods.Type.SpotCardPoint:
|
|
ViewIconSprite("icon_spotpoint_s");
|
|
break;
|
|
}
|
|
}
|
|
|
|
private void ViewIconSprite(string spriteName)
|
|
{
|
|
_spriteConfirmItemIcon.gameObject.SetActive(value: true);
|
|
_spriteHaveItemIcon.gameObject.SetActive(value: true);
|
|
m_TextureConfirmTicket.gameObject.SetActive(value: false);
|
|
m_TextureHaveTicket.gameObject.SetActive(value: false);
|
|
_spriteConfirmItemIcon.spriteName = spriteName;
|
|
_spriteHaveItemIcon.spriteName = spriteName;
|
|
}
|
|
|
|
private void HideIcon()
|
|
{
|
|
_spriteConfirmItemIcon.gameObject.SetActive(value: false);
|
|
_spriteHaveItemIcon.gameObject.SetActive(value: false);
|
|
m_TextureConfirmTicket.gameObject.SetActive(value: false);
|
|
m_TextureHaveTicket.gameObject.SetActive(value: false);
|
|
}
|
|
|
|
private void SetLabelText(string itemName, string useItemNumText, int afterItemNum, string unit, string purchaseText, int haveItemCnt)
|
|
{
|
|
m_LabelUseItemCnt.text = useItemNumText;
|
|
m_LabelBuyPack.text = purchaseText;
|
|
m_LabelItemName.text = itemName;
|
|
m_LabelBeforeItemCnt.text = haveItemCnt.ToString();
|
|
m_LabelAfterItemCnt.text = afterItemNum.ToString();
|
|
m_LabelAfterItemUnit.text = unit;
|
|
}
|
|
|
|
public void SetCardBuy(string moneyKindName, int moneyHave, int moneyUse, CardParameter cardData)
|
|
{
|
|
SystemText systemText = Data.SystemText;
|
|
m_LabelUseItemCnt.text = systemText.Get("Card_0064", moneyUse.ToString());
|
|
m_LabelBuyPack.text = systemText.Get("Card_0077", cardData.CardName);
|
|
string text = CheckMyRotationCardBuyCheck(cardData);
|
|
if (cardData.IsResurgentCard)
|
|
{
|
|
SetWarningTextId("Card_0300");
|
|
}
|
|
else if (!cardData.IsAvailableFormat(Format.Unlimited, ClassType.None))
|
|
{
|
|
SetWarningTextId("Card_0204");
|
|
}
|
|
else if (cardData.SameKindNumMaxInUnlimited == 1)
|
|
{
|
|
SetWarningTextId("Card_0205");
|
|
}
|
|
else if (cardData.SameKindNumMaxInUnlimited == 2)
|
|
{
|
|
SetWarningTextId("Card_0206");
|
|
}
|
|
else if (text != null)
|
|
{
|
|
SetWarningText(text);
|
|
}
|
|
else if (Data.Crossover.IsWithinPracticePeriod)
|
|
{
|
|
int num = Mathf.Min(cardData.SameKindNumMaxInCrossoverMainClass, cardData.SameKindNumMaxInCrossoverSubClass);
|
|
if (num == 0)
|
|
{
|
|
SetWarningText(systemText.Get("Card_0277"));
|
|
}
|
|
else if (num < FormatBehaviorManager.GetDefaultBehaviour(Format.Crossover).DeckSameKindCardNumMax)
|
|
{
|
|
SetWarningText(systemText.Get("Card_0278", num.ToString()));
|
|
}
|
|
}
|
|
m_LabelItemName.text = systemText.Get("Common_0113");
|
|
int moneyAfter = moneyHave - moneyUse;
|
|
SetCardCommon(moneyHave, moneyAfter);
|
|
HideJpnLawObj();
|
|
}
|
|
|
|
private string CheckMyRotationCardBuyCheck(CardParameter cardParameter)
|
|
{
|
|
if (!Data.MyRotationAllInfo.IsMyRotationEnable)
|
|
{
|
|
return null;
|
|
}
|
|
int num = 0;
|
|
int num2 = 0;
|
|
int num3 = 0;
|
|
IFormatBehavior defaultBehaviour = FormatBehaviorManager.GetDefaultBehaviour(Format.MyRotation);
|
|
foreach (MyRotationInfo myRotationInfo in Data.MyRotationAllInfo.MyRotationInfoList)
|
|
{
|
|
int sameCardCount = myRotationInfo.GetSameCardCount(cardParameter.BaseCardId);
|
|
if (sameCardCount != defaultBehaviour.DeckSameKindCardNumMax)
|
|
{
|
|
if (sameCardCount == 0)
|
|
{
|
|
num2++;
|
|
}
|
|
else
|
|
{
|
|
num++;
|
|
}
|
|
num3 = sameCardCount;
|
|
}
|
|
}
|
|
if (num == 0 && num2 == 0)
|
|
{
|
|
return null;
|
|
}
|
|
int count = Data.MyRotationAllInfo.MyRotationInfoList.Count;
|
|
if (num2 == count)
|
|
{
|
|
return Data.SystemText.Get("MyRotation_ID_19");
|
|
}
|
|
if (num2 > 0)
|
|
{
|
|
return Data.SystemText.Get("MyRotation_ID_20");
|
|
}
|
|
if (num == count)
|
|
{
|
|
return Data.SystemText.Get("MyRotation_ID_21", num3.ToString());
|
|
}
|
|
return Data.SystemText.Get("MyRotation_ID_22", num3.ToString());
|
|
}
|
|
|
|
public void SetCardSell(string moneyKindName, int moneyHave, int moneyGet, string cardName, bool inIsPremiumCard)
|
|
{
|
|
SystemText systemText = Data.SystemText;
|
|
m_LabelUseItemCnt.text = systemText.Get("Card_0079", moneyGet.ToString());
|
|
m_LabelBuyPack.text = systemText.Get("Card_0078", cardName);
|
|
m_LabelItemName.text = systemText.Get("Card_0097");
|
|
if (inIsPremiumCard)
|
|
{
|
|
_premiumCardWarning.gameObject.SetActive(value: true);
|
|
_premiumCardWarning.text = systemText.Get("Card_0144");
|
|
_confirmObj.transform.localPosition = new Vector3(0f, -40f, 0f);
|
|
_haveObj.transform.localPosition = new Vector3(0f, -40f, 0f);
|
|
}
|
|
else
|
|
{
|
|
_premiumCardWarning.gameObject.SetActive(value: false);
|
|
}
|
|
int moneyAfter = moneyHave + moneyGet;
|
|
SetCardCommon(moneyHave, moneyAfter);
|
|
HideJpnLawObj();
|
|
}
|
|
|
|
private void SetCardCommon(int moneyHave, int moneyAfter)
|
|
{
|
|
SetIconImage(UserGoods.Type.RedEther);
|
|
SystemText systemText = Data.SystemText;
|
|
m_LabelBeforeItemCnt.text = moneyHave.ToString();
|
|
m_LabelAfterItemCnt.text = systemText.Get("Shop_0045", moneyAfter.ToString());
|
|
m_LabelAfterItemUnit.text = systemText.Get("Card_0100");
|
|
}
|
|
|
|
public void SetWarningTextId(string warningTextId)
|
|
{
|
|
SystemText systemText = Data.SystemText;
|
|
SetWarningText(systemText.Get(warningTextId));
|
|
}
|
|
|
|
public void SetWarningText(string warningText)
|
|
{
|
|
_premiumCardWarning.gameObject.SetActive(value: true);
|
|
_premiumCardWarning.text = warningText;
|
|
_confirmObj.transform.localPosition = new Vector3(0f, -40f, 0f);
|
|
_haveObj.transform.localPosition = new Vector3(0f, -40f, 0f);
|
|
}
|
|
|
|
private void SetCampaignName(string name)
|
|
{
|
|
if (!(_campaignNameLabel == null))
|
|
{
|
|
_campaignNameLabel.gameObject.SetActive(value: true);
|
|
_campaignNameLabel.text = name;
|
|
}
|
|
}
|
|
}
|