ShopWindow.cs 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. using UnityEngine;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. public class ShopWindow : UIWindowBase
  5. {
  6. ReusingScrollRect m_ShopItem;
  7. //UI的初始化请放在这里
  8. public override void OnOpen()
  9. {
  10. m_ShopItem = GetReusingScrollRect("Items");
  11. m_ShopItem.SetItem("ShopWindow_Item");
  12. m_ShopItem.Init(UIEventKey,0);
  13. m_ShopItem.SetData(GetShopData());
  14. AddOnClickListener("Button_Close", OnClickCLose);
  15. }
  16. //请在这里写UI的更新逻辑,当该UI监听的事件触发时,该函数会被调用
  17. public override void OnRefresh()
  18. {
  19. }
  20. //UI的进入动画
  21. public override IEnumerator EnterAnim(UIAnimCallBack l_animComplete, UICallBack l_callBack, params object[] objs)
  22. {
  23. AnimSystem.UguiAlpha(gameObject, 0, 1, callBack:(object[] obj)=>
  24. {
  25. StartCoroutine(base.EnterAnim(l_animComplete, l_callBack, objs));
  26. });
  27. AnimSystem.UguiMove(m_uiRoot, new Vector3(1000, 0, 0), Vector3.zero, time: 1, interp: InterpType.InOutBack);
  28. yield return new WaitForEndOfFrame();
  29. }
  30. //UI的退出动画
  31. public override IEnumerator ExitAnim(UIAnimCallBack l_animComplete, UICallBack l_callBack, params object[] objs)
  32. {
  33. AnimSystem.UguiAlpha(gameObject , null, 0, callBack:(object[] obj) =>
  34. {
  35. StartCoroutine(base.ExitAnim(l_animComplete, l_callBack, objs));
  36. });
  37. AnimSystem.UguiMove(m_uiRoot,Vector3.zero, new Vector3(1000, 0, 0),time:1,interp:InterpType.InOutBack);
  38. yield return new WaitForEndOfFrame();
  39. }
  40. List<Dictionary<string,object>> GetShopData()
  41. {
  42. List<Dictionary<string, object>> data = new List<Dictionary<string, object>>();
  43. DataTable itemData = DataManager.GetData("item");
  44. for (int i = 0; i < itemData.TableIDs.Count; i++)
  45. {
  46. //SingleData singleData = itemData.GetLineFromKey(itemData.TableIDs[i]);
  47. //string itemName = singleData.GetString("ItemName");
  48. //int cost = singleData.GetInt("Cost");
  49. Dictionary<string, object> tmp = new Dictionary<string, object>();
  50. tmp.Add("Name", DataGenerateManager<itemGenerate>.GetData(itemData.TableIDs[i]).m_ItemName);
  51. tmp.Add("Cost", DataGenerateManager<itemGenerate>.GetData(itemData.TableIDs[i]).m_key);
  52. data.Add(tmp);
  53. }
  54. //itemGenerate data = DataGenerateManager<itemGenerate>.GetData("1");
  55. //string itemName = data.m_ItemName;
  56. //int cost = data.m_Cost;
  57. return data;
  58. }
  59. void OnClickCLose(InputUIOnClickEvent e)
  60. {
  61. UIManager.CloseUIWindow(this);
  62. }
  63. }