KasizukiItemCtrl.cs 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. using System;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. namespace Kasizuki
  5. {
  6. public class KasizukiItemCtrl : NGUIWindow
  7. {
  8. private void Start()
  9. {
  10. UIToggle componentInChildren = this.listViewer.tempItem.GetComponentInChildren<UIToggle>();
  11. UISprite component = componentInChildren.GetComponent<UISprite>();
  12. this.m_ItemDefaultColor = component.color;
  13. this.m_ItemSelectColor = new Color(1f, 1f, 1f, 1f);
  14. }
  15. public void SetData()
  16. {
  17. this.UpdateUI();
  18. }
  19. private void UpdateUI()
  20. {
  21. List<ItemData.Data> itemList = ItemData.GetAllDatas(true);
  22. this.listViewer.Show<Transform>(itemList.Count, delegate(int index, Transform trans)
  23. {
  24. ItemData.Data data = itemList[index];
  25. UIToggle componentInChildren2 = trans.GetComponentInChildren<UIToggle>();
  26. UISprite componentInChildren3 = trans.GetComponentInChildren<UISprite>();
  27. EventDelegate.Add(componentInChildren2.onChange, new EventDelegate.Callback(this.OnClick));
  28. });
  29. UITable component = this.listViewer.parentItemArea.GetComponent<UITable>();
  30. component.repositionNow = true;
  31. UIScrollView componentInChildren = base.GetComponentInChildren<UIScrollView>();
  32. componentInChildren.UpdatePosition();
  33. componentInChildren.ResetPosition();
  34. }
  35. private void OnClick()
  36. {
  37. UIToggle current = UIToggle.current;
  38. UISprite component = current.GetComponent<UISprite>();
  39. component.color = ((!current.value) ? this.m_ItemDefaultColor : this.m_ItemSelectColor);
  40. if (this.CallbackOnClick != null)
  41. {
  42. this.CallbackOnClick();
  43. }
  44. }
  45. private uGUIListViewer listViewer
  46. {
  47. get
  48. {
  49. if (!this.m_ListViewer)
  50. {
  51. this.m_ListViewer = base.GetComponent<uGUIListViewer>();
  52. }
  53. return this.m_ListViewer;
  54. }
  55. }
  56. public Action CallbackOnClick { get; set; }
  57. private uGUIListViewer m_ListViewer;
  58. private Color m_ItemDefaultColor;
  59. private Color m_ItemSelectColor;
  60. }
  61. }