RichRewardPanel.ts 3.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. import AdM from "../manager/AdM";
  2. import GameM, { AUDIO_TYPE, VIDEO_TYPE } from "../manager/GameM";
  3. import GuideMng from "../manager/GuideMng";
  4. import RoadItem from "../other/item/RoadItem";
  5. import BasePanel from "../uiFrames/BasePanel";
  6. import Sciencen_M from "../utils/Sciencen_M";
  7. const { ccclass, property } = cc._decorator;
  8. @ccclass
  9. export default class RichRewardPanel extends BasePanel {
  10. @property(cc.Node)
  11. panelNode: cc.Node = null;
  12. @property(cc.Sprite)
  13. rewardImg: cc.Sprite = null;
  14. @property(cc.Label)
  15. txtNum: cc.Label = null;
  16. /**界面类型 10001 金币 10002 红包币 10004 武将宝盒 20001 加速卡 20002 转盘卡 20003 夺宝券 20006 天赋石 30001 骰子 30002 遥控卡 30003 传送阵 30004 经书 30005 双倍卡*/
  17. panelType: number = 1;
  18. roadItem: RoadItem = null;
  19. /*
  20. */
  21. OnEnter(roaditem: RoadItem) {
  22. this.roadItem = roaditem;
  23. this.panelType = roaditem.propType;
  24. this.panelNode.scale = 0;
  25. this.node.active = true;
  26. cc.tween(this.panelNode).to(0.2, { scale: 1 }, { easing: "backOut" })
  27. .call(() => {
  28. })
  29. .start();
  30. let url = "xiyou/icon/reward" + roaditem.propType;
  31. if (roaditem.propType == 10001) {
  32. if (roaditem.num <= 49) {
  33. url = "xiyou/icon/reward10001";
  34. } else if (roaditem.num <= 99) {
  35. url = "xiyou/icon/reward10001_2";
  36. } else {
  37. url = "xiyou/icon/reward10001_3";
  38. }
  39. }
  40. else if (roaditem.propType == 10002) {
  41. if (roaditem.num <= 49) {
  42. url = "xiyou/icon/reward10002";
  43. } else if (roaditem.num <= 99) {
  44. url = "xiyou/icon/reward10002_2";
  45. } else {
  46. url = "xiyou/icon/reward10002_3";
  47. }
  48. }
  49. cc.loader.loadRes(url, cc.SpriteFrame, (error, assets) => {
  50. if (error != null) {
  51. return;
  52. }
  53. this.rewardImg.spriteFrame = assets;
  54. });
  55. if (roaditem.propType != 10001) {
  56. this.txtNum.string = roaditem.num * roaditem.dispalyTimes + "";
  57. } else {
  58. this.txtNum.string = Sciencen_M.instance.format(Sciencen_M.instance.accMul(GameM.commonData.goldSecond.toString(), (roaditem.num * roaditem.dispalyTimes * 60).toString()));
  59. //this.txtNum.string = roaditem.num * roaditem.dispalyTimes + "分钟";
  60. }
  61. AdM.showNative();
  62. }
  63. OnExit() {
  64. this.node.active = false;
  65. AdM.destroyNative()
  66. }
  67. Click_GetBtn() {
  68. if (this.roadItem != null)
  69. this.roadItem.GetReward();
  70. this.OnExit();
  71. GameM.audioM.playEffect(AUDIO_TYPE.button);
  72. }
  73. Click_CloseBtn() {
  74. if (this.roadItem != null)
  75. this.roadItem.GetReward();
  76. this.OnExit();
  77. GameM.audioM.playEffect(AUDIO_TYPE.button);
  78. }
  79. }