EquipChoose.ts 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. import { _decorator, Label, Node, tween, UIOpacity } from 'cc';
  2. import { BaseView } from '../../../framework/layer/BaseView';
  3. import { EquipChooseItem } from './EquipChooseItem';
  4. import { StringUtil } from '../../../framework/util/StringUtil';
  5. import List from '../../../framework/list/List';
  6. import { EquipManager } from '../../manager/EquipManager';
  7. import { Framework } from '../../../framework/Framework';
  8. const { ccclass, property } = _decorator;
  9. @ccclass('EquipChoose')
  10. export class EquipChoose extends BaseView {
  11. @property({ type: Label, tooltip: "关闭提示" })
  12. closeTips: Label = null;
  13. @property({ type: Label, tooltip: "标题" })
  14. titieTx: Label = null;
  15. @property({ type: Node, tooltip: "穿戴装备节点" })
  16. wearNode: Node = null;
  17. @property({ type: Label, tooltip: "列表空提示" })
  18. equipListNoneTx: Label = null;
  19. @property({ type: List, tooltip: "列表" })
  20. equipList: List = null;
  21. @property({ type: Node, tooltip: "装备节点" })
  22. itemNode: Node = null;
  23. @property({ type: Label, tooltip: "装备名" })
  24. nameTx: Label = null;
  25. @property({ type: Label, tooltip: "战力标题" })
  26. fightTitie: Label = null;
  27. @property({ type: Label, tooltip: "战力文字" })
  28. fightTx: Label = null;
  29. @property({ type: Label, tooltip: "穿戴文字" })
  30. wearTx: Label = null;
  31. private _curRace: number = 0;
  32. private _curSlot: number = 0;
  33. private _equipsData: any[] = [];
  34. private _curEquip: any = null;
  35. start() {
  36. }
  37. protected onLoad() {
  38. super.onLoad();
  39. this.closeTips.string = StringUtil.getLanguageData('点击空白关闭');
  40. this.titieTx.string = StringUtil.getLanguageData('装备选择');
  41. this.wearTx.string = StringUtil.getLanguageData('当前穿戴');
  42. this.fightTitie.string = StringUtil.getLanguageData('战力') + ': ';
  43. this.equipListNoneTx.string = StringUtil.getLanguageData('暂无可用装备装备');
  44. this.closeTips.node.getComponent(UIOpacity).opacity = 0;
  45. this.wearNode.active = false;
  46. }
  47. protected onDestroy() {
  48. }
  49. //UI开打时会调用,如果有初始化代码应该放到此函数
  50. onOpen(data) {
  51. tween(this.closeTips.node.getComponent(UIOpacity))
  52. .to(1, { opacity: 255 })
  53. .to(1.2, { opacity: 10 })
  54. .union()
  55. .repeatForever()
  56. .start()
  57. this._curRace = data.race;
  58. this._curSlot = data.slot;
  59. if (data.equip) {
  60. this._curEquip = data.equip;
  61. this.wearNode.active = true;
  62. }
  63. this._equipsData = EquipManager.getEquipRaceSlotGroup(data.race)[data.slot];
  64. this.equipListNoneTx.node.active = this._equipsData.length == 0;
  65. this.equipList.numItems = this._equipsData.length;
  66. }
  67. //UI关闭时会调用,该函数在onDestroy前调用
  68. onClose() {
  69. }
  70. //框架管理UI层级时会调用,可根据UI情况修改
  71. onShow() {
  72. super.onShow();
  73. }
  74. //框架管理UI层级时会调用,可根据UI情况修改
  75. onHide() {
  76. super.onHide();
  77. }
  78. //UI事件处理
  79. private onTouchButton(event: Event) {
  80. //Framework.audio.playEffect(AudioID.Click);
  81. let target: any = event.target;
  82. if (target.name == 'mask') {
  83. Framework.layer.close(this);
  84. }
  85. }
  86. onEventList(item, idx) {
  87. item.getComponent(EquipChooseItem).refreshItem(this._equipsData[idx], this._curEquip);
  88. }
  89. }