CasinoItemUI.cs 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  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.SPP)
  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);
  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. EventDelegate.Add(this.m_BuyButton.onClick, new EventDelegate.Callback(this.ItemBuy));
  69. this.UIUpdate();
  70. }
  71. public void UIUpdate()
  72. {
  73. this.m_BuyButton.isEnabled = !this.m_ItemData.IsSoldOut;
  74. this.m_PriceLabel.color = ((!this.m_ItemData.IsCanBuy && !this.m_ItemData.IsSoldOut) ? this.m_CannotBuyCol : this.m_CanBuyCol);
  75. this.m_BuyButtonIcon.spriteName = ((!this.m_ItemData.IsSoldOut) ? this.m_BuySprite : this.m_SoldSprite);
  76. }
  77. public void SwitchFrame()
  78. {
  79. this.m_IconFrame.SetActive(KasaSceneMgr<SceneCasinoShop>.Instance.SelectTrywear == this.m_ItemData);
  80. }
  81. private CasinoShopItem m_ItemData;
  82. [SerializeField]
  83. private UILabel m_NameLabel;
  84. [SerializeField]
  85. private UILabel m_PriceLabel;
  86. [SerializeField]
  87. private Color m_CanBuyCol = Color.white;
  88. [SerializeField]
  89. private Color m_CannotBuyCol = Color.red;
  90. [SerializeField]
  91. private GameObject m_BuyButtonObj;
  92. [SerializeField]
  93. private GameObject m_ItemIconObj;
  94. [SerializeField]
  95. private string m_BuySprite;
  96. [SerializeField]
  97. private string m_SoldSprite;
  98. private UIButton m_IconButton;
  99. private UI2DSprite m_ItemIcon;
  100. private UIEventTrigger m_IconEvent;
  101. private GameObject m_IconFrame;
  102. private UIButton m_BuyButton;
  103. private UISprite m_BuyButtonIcon;
  104. }