SuitFosterView.cs 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. using FairyGUI;
  2. using UI.ClothingFoster;
  3. using UI.CommonGame;
  4. namespace GFGGame
  5. {
  6. public class SuitFosterView : BaseWindow
  7. {
  8. private UI_SuitFosterUI _ui;
  9. private int _suitId;
  10. private int _index;
  11. private bool _canFoster;
  12. public override void Dispose()
  13. {
  14. base.Dispose();
  15. }
  16. protected override void OnInit()
  17. {
  18. base.OnInit();
  19. packageName = UI_SuitFosterUI.PACKAGE_NAME;
  20. _ui = UI_SuitFosterUI.Create();
  21. this.viewCom = _ui.target;
  22. this.viewCom.Center();
  23. // this.modal = true;
  24. // viewAnimationType = EnumViewAnimationType.ZOOM_CENTER;
  25. _ui.m_listMaterials.itemRenderer = ListMaterialItemRender;
  26. _ui.m_listPropertyAdd.itemRenderer = ListPropertyItemRender;
  27. _ui.m_btnFoster.onClick.Add(OnClickBtnFoster);
  28. }
  29. protected override void OnShown()
  30. {
  31. base.OnShown();
  32. _suitId = (int)(this.viewData as object[])[0];
  33. _index = (int)(this.viewData as object[])[1];
  34. _canFoster = true;
  35. SuitFosterCfg cfg = SuitFosterCfgArray.Instance.GetCfgs(_suitId)[_index];
  36. _ui.m_listMaterials.numItems = cfg.materialsArr.Length;
  37. int has = ItemDataManager.GetItemNum(cfg.costId);
  38. int need = cfg.costNum;
  39. UI_ComConsumeCurrency comConsume = UI_ComConsumeCurrency.Proxy(_ui.m_ComConsume);
  40. comConsume.m_txtHas.text = has.ToString();
  41. comConsume.m_txtNeed.text = need.ToString();
  42. if (_canFoster && has < need) _canFoster = false;
  43. }
  44. protected override void OnHide()
  45. {
  46. base.OnHide();
  47. }
  48. private void ListMaterialItemRender(int index, GObject obj)
  49. {
  50. UI_ListMaterialsItem item = UI_ListMaterialsItem.Proxy(obj);
  51. int[][] materialsArr = SuitFosterCfgArray.Instance.GetCfgs(_suitId)[_index].materialsArr;
  52. ItemCfg itemCfg = ItemCfgArray.Instance.GetCfg(materialsArr[index][0]);
  53. item.m_loaIcon.url = ResPathUtil.GetIconPath(itemCfg);
  54. int has = ItemDataManager.GetItemNum(itemCfg.id);
  55. item.m_txtHas.text = has.ToString();
  56. int need = materialsArr[index][1];
  57. item.m_txtNeed.text = StringUtil.GetColorText(need.ToString(), has >= need ? "#DD994A" : "#DD994A");
  58. if (_canFoster && has < need) _canFoster = false;
  59. }
  60. private void ListPropertyItemRender(int index, GObject obj)
  61. {
  62. UI_ListPropertyAddItem item = UI_ListPropertyAddItem.Proxy(obj);
  63. }
  64. private void OnClickBtnFoster()
  65. {
  66. if (!_canFoster)
  67. {
  68. PromptController.Instance.ShowFloatTextPrompt("材料不足");
  69. return;
  70. }
  71. }
  72. }
  73. }