CasinoItemUI.cs 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  1. using System;
  2. using I2.Loc;
  3. using UnityEngine;
  4. using wf;
  5. public class CasinoItemUI : MonoBehaviour
  6. {
  7. private void IconHoverOver()
  8. {
  9. KasaSceneMgr<SceneCasinoShop>.Instance.ShowItenInfo(this.m_ItemData, base.transform);
  10. }
  11. private void IconHoverOut()
  12. {
  13. KasaSceneMgr<SceneCasinoShop>.Instance.HideItemInfo();
  14. }
  15. private void IconClick()
  16. {
  17. if (KasaSceneMgr<SceneCasinoShop>.Instance.SelectTrywear != this.m_ItemData)
  18. {
  19. KasaSceneMgr<SceneCasinoShop>.Instance.SetTrywearItem(this.m_ItemData);
  20. }
  21. else
  22. {
  23. KasaSceneMgr<SceneCasinoShop>.Instance.RecetTrywearItem();
  24. }
  25. }
  26. private void ItemBuy()
  27. {
  28. if (!this.m_ItemData.IsCanBuy)
  29. {
  30. GameMain.Instance.SysDlg.ShowFromLanguageTerm("SceneCasino/ダイアログ/カジノコインが不足しています。", null, SystemDialog.TYPE.OK, null, null);
  31. return;
  32. }
  33. string messageTerm = "SceneCasino/ダイアログ/{0}を購入しますか?";
  34. string[] array = new string[]
  35. {
  36. this.m_ItemData.Name,
  37. Utility.ConvertMoneyText(this.m_ItemData.Price)
  38. };
  39. if (Product.supportMultiLanguage)
  40. {
  41. array[0] = LocalizationManager.GetTranslation(this.m_ItemData.NameTerm, true, 0, true, false, null, null);
  42. }
  43. GameMain.Instance.SysDlg.ShowFromLanguageTerm(messageTerm, array, SystemDialog.TYPE.OK_CANCEL, delegate
  44. {
  45. KasaSceneMgr<SceneCasinoShop>.Instance.ItemBuy(this.m_ItemData);
  46. }, null);
  47. }
  48. public void Init(CasinoShopItem item_data)
  49. {
  50. this.m_ItemData = item_data;
  51. this.m_NameLabel.text = item_data.Name;
  52. Utility.SetLocalizeTerm(this.m_NameLabel, item_data.NameTerm, false);
  53. this.m_PriceLabel.text = Utility.ConvertMoneyText(item_data.Price);
  54. this.m_ItemIcon = this.m_ItemIconObj.GetComponent<UI2DSprite>();
  55. this.m_IconButton = this.m_ItemIconObj.GetComponent<UIButton>();
  56. this.m_IconButton.enabled = item_data.IsCategoryCostume;
  57. this.m_IconEvent = this.m_ItemIconObj.GetComponent<UIEventTrigger>();
  58. this.m_IconFrame = this.m_ItemIconObj.transform.GetChild(0).gameObject;
  59. this.m_ItemIcon.sprite2D = item_data.Icon;
  60. EventDelegate.Add(this.m_IconEvent.onHoverOut, new EventDelegate.Callback(this.IconHoverOut));
  61. EventDelegate.Add(this.m_IconEvent.onHoverOver, new EventDelegate.Callback(this.IconHoverOver));
  62. if (this.m_ItemData.IsCategoryCostume)
  63. {
  64. EventDelegate.Add(this.m_IconButton.onClick, new EventDelegate.Callback(this.IconClick));
  65. }
  66. this.m_BuyButton = this.m_BuyButtonObj.GetComponent<UIButton>();
  67. this.m_BuyButtonIcon = this.m_BuyButtonObj.GetComponent<UISprite>();
  68. this.m_BuyButtonIconLocalize = this.m_BuyButtonObj.GetComponent<Localize>();
  69. EventDelegate.Add(this.m_BuyButton.onClick, new EventDelegate.Callback(this.ItemBuy));
  70. this.UIUpdate();
  71. }
  72. public void UIUpdate()
  73. {
  74. this.m_BuyButton.isEnabled = !this.m_ItemData.IsSoldOut;
  75. this.m_PriceLabel.color = ((!this.m_ItemData.IsCanBuy && !this.m_ItemData.IsSoldOut) ? this.m_CannotBuyCol : this.m_CanBuyCol);
  76. Utility.SetLocalizeTerm(this.m_BuyButtonIconLocalize, (!this.m_ItemData.IsSoldOut) ? this.m_BuySprite : this.m_SoldSprite, false);
  77. }
  78. public void SwitchFrame()
  79. {
  80. this.m_IconFrame.SetActive(KasaSceneMgr<SceneCasinoShop>.Instance.SelectTrywear == this.m_ItemData);
  81. }
  82. private CasinoShopItem m_ItemData;
  83. [SerializeField]
  84. private UILabel m_NameLabel;
  85. [SerializeField]
  86. private UILabel m_PriceLabel;
  87. [SerializeField]
  88. private Color m_CanBuyCol = Color.white;
  89. [SerializeField]
  90. private Color m_CannotBuyCol = Color.red;
  91. [SerializeField]
  92. private GameObject m_BuyButtonObj;
  93. [SerializeField]
  94. private GameObject m_ItemIconObj;
  95. [SerializeField]
  96. private string m_BuySprite;
  97. [SerializeField]
  98. private string m_SoldSprite;
  99. private UIButton m_IconButton;
  100. private UI2DSprite m_ItemIcon;
  101. private UIEventTrigger m_IconEvent;
  102. private GameObject m_IconFrame;
  103. private UIButton m_BuyButton;
  104. private UISprite m_BuyButtonIcon;
  105. private Localize m_BuyButtonIconLocalize;
  106. }