166 lines
3.5 KiB
C#
166 lines
3.5 KiB
C#
![]() |
// ***********************************************************************
|
|||
|
// Assembly : Game
|
|||
|
// Author : Kimch
|
|||
|
// Created : 2021-11-30
|
|||
|
// Description :
|
|||
|
// Last Modified By :
|
|||
|
// Last Modified On :
|
|||
|
// ***********************************************************************
|
|||
|
// <copyright file= "SmartCostWidget" company="Kunpo"></copyright>
|
|||
|
// <summary></summary>
|
|||
|
// ***********************************************************************
|
|||
|
|
|||
|
using TMPro;
|
|||
|
using UnityEngine;
|
|||
|
using UnityEngine.Events;
|
|||
|
using UnityEngine.UI;
|
|||
|
|
|||
|
namespace G.UI
|
|||
|
{
|
|||
|
/// <summary>
|
|||
|
///
|
|||
|
/// </summary>
|
|||
|
public class SmartCostWidget : KUIWidget
|
|||
|
{
|
|||
|
#region Auto Generate
|
|||
|
|
|||
|
#pragma warning disable CS0649 // 从未对字段赋值,字段将一直保持其默认值 null
|
|||
|
[KUIFlag]
|
|||
|
KUIImage _imgType;
|
|||
|
[KUIFlag]
|
|||
|
TextMeshProUGUI _tmpTypeState;
|
|||
|
[KUIFlag]
|
|||
|
Image _imgAdTicket;
|
|||
|
[KUIFlag]
|
|||
|
TextMeshProUGUI _tmpAdTicketCount;
|
|||
|
[KUIFlag]
|
|||
|
KUIImage _imgPrivilege;
|
|||
|
#pragma warning restore CS0649 // 从未对字段赋值,字段将一直保持其默认值 null
|
|||
|
|
|||
|
#endregion
|
|||
|
|
|||
|
#region Field
|
|||
|
|
|||
|
#endregion
|
|||
|
|
|||
|
#region Method
|
|||
|
|
|||
|
public void AddListener(UnityAction call)
|
|||
|
{
|
|||
|
GetComponent<Button>().onClick.AddListener(call);
|
|||
|
}
|
|||
|
|
|||
|
public void SetTextState(string state)
|
|||
|
{
|
|||
|
_tmpTypeState.text = state;
|
|||
|
}
|
|||
|
|
|||
|
public void SetFree()
|
|||
|
{
|
|||
|
_imgType.ShowSprite(1);
|
|||
|
_imgAdTicket.gameObject.SetActive(false);
|
|||
|
_tmpAdTicketCount.gameObject.SetActive(false);
|
|||
|
_imgPrivilege.gameObject.SetActive(false);
|
|||
|
}
|
|||
|
|
|||
|
public void SetAd()
|
|||
|
{
|
|||
|
_imgType.ShowSprite(1);
|
|||
|
_imgAdTicket.gameObject.SetActive(false);
|
|||
|
_tmpAdTicketCount.gameObject.SetActive(false);
|
|||
|
_imgPrivilege.gameObject.SetActive(false);
|
|||
|
}
|
|||
|
|
|||
|
public void SetShare()
|
|||
|
{
|
|||
|
_imgType.ShowSprite(2);
|
|||
|
_imgAdTicket.gameObject.SetActive(false);
|
|||
|
_tmpAdTicketCount.gameObject.SetActive(false);
|
|||
|
_imgPrivilege.gameObject.SetActive(false);
|
|||
|
}
|
|||
|
|
|||
|
public void SetAdTicket(int count)
|
|||
|
{
|
|||
|
var card = RmbShopProxy.Instance.IsActivitionCard();
|
|||
|
if (card ==3)
|
|||
|
{
|
|||
|
if (_imgType)
|
|||
|
{
|
|||
|
_imgType.ShowSprite(1);
|
|||
|
}
|
|||
|
_imgPrivilege.gameObject.SetActive(true);
|
|||
|
_imgPrivilege.ShowSprite(1);
|
|||
|
if (_imgAdTicket)
|
|||
|
{
|
|||
|
_imgAdTicket.gameObject.SetActive(false);
|
|||
|
_tmpAdTicketCount.gameObject.SetActive(false);
|
|||
|
}
|
|||
|
|
|||
|
}
|
|||
|
else if (card ==4)
|
|||
|
{
|
|||
|
if (_imgType)
|
|||
|
{
|
|||
|
_imgType.ShowSprite(1);
|
|||
|
}
|
|||
|
_imgPrivilege.gameObject.SetActive(true);
|
|||
|
_imgPrivilege.ShowSprite(0);
|
|||
|
if (_imgAdTicket)
|
|||
|
{
|
|||
|
_imgAdTicket.gameObject.SetActive(false);
|
|||
|
_tmpAdTicketCount.gameObject.SetActive(false);
|
|||
|
}
|
|||
|
|
|||
|
}
|
|||
|
else if (count > 0)
|
|||
|
{
|
|||
|
_imgPrivilege.gameObject.SetActive(false);
|
|||
|
if (_imgAdTicket)
|
|||
|
{
|
|||
|
if (_imgType)
|
|||
|
{
|
|||
|
_imgType.ShowSprite(1);
|
|||
|
}
|
|||
|
_imgAdTicket.gameObject.SetActive(true);
|
|||
|
_tmpAdTicketCount.gameObject.SetActive(true);
|
|||
|
_tmpAdTicketCount.text = "x" + count.ToString();
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
if (_imgType)
|
|||
|
{
|
|||
|
_imgType.ShowSprite(0);
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
if (_imgType)
|
|||
|
{
|
|||
|
_imgType.ShowSprite(0);
|
|||
|
}
|
|||
|
_imgPrivilege.gameObject.SetActive(false);
|
|||
|
if (_imgAdTicket)
|
|||
|
{
|
|||
|
_imgAdTicket.gameObject.SetActive(false);
|
|||
|
_tmpAdTicketCount.gameObject.SetActive(false);
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
#endregion
|
|||
|
|
|||
|
#region Unity
|
|||
|
|
|||
|
/// <summary>
|
|||
|
///
|
|||
|
/// </summary>
|
|||
|
private void Awake()
|
|||
|
{
|
|||
|
SetViewData();
|
|||
|
}
|
|||
|
|
|||
|
#endregion
|
|||
|
}
|
|||
|
}
|