PrizeInitUI.ts 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. import { _decorator, Component, Node, EventHandler, Sprite, SpriteFrame, Label } from 'cc';
  2. import { ResourcesUtils } from '../core/resourceManager/ResourcesUtils';
  3. import { ConfigData } from '../Data/ConfigData';
  4. import { g } from '../Data/g';
  5. const { ccclass, property } = _decorator;
  6. @ccclass('PrizeInitUI')
  7. export class PrizeInitUI extends Component {
  8. @property({ tooltip: "奖品展示图片1", type: Node })
  9. public prize1: Node;
  10. @property({ tooltip: "奖品展示图片2", type: Node })
  11. public prize2: Node;
  12. @property({ tooltip: "奖品展示图片3", type: Node })
  13. public prize3: Node;
  14. @property({ tooltip: "奖品展示图片4", type: Node })
  15. public prize4: Node;
  16. @property({ tooltip: "奖品展示图片5", type: Node })
  17. public prize5: Node;
  18. @property({ tooltip: "奖品展示图片6", type: Node })
  19. public prize6: Node;
  20. @property({ tooltip: "奖品展示图片7", type: Node })
  21. public prize7: Node;
  22. @property({ tooltip: "奖品展示图片8", type: Node })
  23. public prize8: Node;
  24. @property({ tooltip: "奖品展示文本1", type: Node })
  25. public prizeTxt1: Node;
  26. @property({ tooltip: "奖品展示文本2", type: Node })
  27. public prizeTxt2: Node;
  28. @property({ tooltip: "奖品展示文本3", type: Node })
  29. public prizeTxt3: Node;
  30. @property({ tooltip: "奖品展示文本4", type: Node })
  31. public prizeTxt4: Node;
  32. @property({ tooltip: "奖品展示文本5", type: Node })
  33. public prizeTxt5: Node;
  34. @property({ tooltip: "奖品展示文本6", type: Node })
  35. public prizeTxt6: Node;
  36. @property({ tooltip: "奖品展示文本7", type: Node })
  37. public prizeTxt7: Node;
  38. @property({ tooltip: "奖品展示文本8", type: Node })
  39. public prizeTxt8: Node;
  40. start() {
  41. this.initUI();
  42. }
  43. public async initUI() {
  44. let configData = ConfigData.configMap.get("turntable").prizeList;
  45. let _config: any = ConfigData.configMap.get("turntable").showOrder;
  46. for (let i = 0; i < _config.length; i++) {
  47. let type = i + 1;
  48. let _id = _config[i];
  49. for (let j = 0; j < configData.length; j++) {
  50. if (configData[j].id == _id) {
  51. let _data = configData[j];
  52. let img: SpriteFrame = await ResourcesUtils.load("Images/turnPrize/prize" + _data.icon + "/spriteFrame", SpriteFrame, this.node);
  53. this["prize" + type].getComponent(Sprite).spriteFrame = img;
  54. this["prizeTxt" + type].getComponent(Label).string = _data.title;
  55. break;
  56. }
  57. }
  58. }
  59. }
  60. }