CoinStorePanel.ts 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. /**
  2. * 代码描述
  3. */
  4. import { Audio } from "../../common/src/Audio";
  5. import { GameDataCenter } from "../../common/src/GameDataCenter";
  6. import { UIManager } from "../../common/src/UIManager";
  7. import { Utils } from "../../common/src/Utils";
  8. const { ccclass, property } = cc._decorator;
  9. @ccclass
  10. export class CoinStorePanel extends cc.Component {
  11. @property({ type: cc.Node, tooltip: '任务节点' })
  12. task: cc.Node = null;
  13. onEnable() {
  14. this.node.getChildByName('panel').getChildByName('closeButton').on('click', this.onClose, this);
  15. this.task.getChildByName('video').getChildByName('btn').on('click', this.onVideo, this);
  16. Utils.openPanel(this.node.getChildByName('panel'));
  17. }
  18. /**关闭 */
  19. private onClose(): void {
  20. Audio.playSoundByPath('coinStore:res/snd/click');
  21. UIManager.close('coinStore:CoinStorePanel', true);
  22. }
  23. /**看视频 */
  24. private onVideo(button): void {
  25. Audio.playSoundByPath('coinStore:res/snd/click');
  26. let num = +this.task.getChildByName('video').getChildByName('coin').getChildByName('num').getComponent(cc.Label).string;
  27. GameDataCenter.rewarded = [`4:${num}`];
  28. UIManager.open('rewarded:RewardedPanel');
  29. }
  30. }