CasinoItemUI.cs 3.3 KB

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