XuXian.ts 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. // Learn TypeScript:
  2. // - https://docs.cocos.com/creator/2.4/manual/en/scripting/typescript.html
  3. // Learn Attribute:
  4. // - https://docs.cocos.com/creator/2.4/manual/en/scripting/reference/attributes.html
  5. // Learn life-cycle callbacks:
  6. // - https://docs.cocos.com/creator/2.4/manual/en/scripting/life-cycle-callbacks.html
  7. import EventName, { GuideType } from "../EventName/EventName";
  8. import LocalData from "../LocalData";
  9. import { AwardType } from "../Pop/Award";
  10. import MyComponent from "../Template/MyComponent";
  11. import RewardMnr from "../Template/RewardMnr";
  12. const { ccclass, property } = cc._decorator;
  13. //抛物线的次数
  14. @ccclass
  15. export default class XuXian extends MyComponent {
  16. @property(cc.Label)
  17. Count: cc.Label = null;
  18. @property(cc.Sprite)
  19. CountBg_Video: cc.Sprite = null;
  20. @property(cc.SpriteFrame)
  21. CountBg: cc.SpriteFrame = null;
  22. @property(cc.SpriteFrame)
  23. Video: cc.SpriteFrame = null;
  24. // LIFE-CYCLE CALLBACKS:
  25. // onLoad () {}
  26. start() {
  27. this.regEvent(EventName.changeParabolaCount, this.changeParabolaCount, this)
  28. this.node.on(cc.Node.EventType.TOUCH_START, this.useParabola, this);//当手指在背景上移动时触发move事件
  29. cc.systemEvent.emit(EventName.changeParabolaCount)
  30. }
  31. useParabola() {
  32. if (!LocalData.getInstance().getGuide(GuideType.完整抛物线)) {
  33. cc.systemEvent.emit(EventName.ShowGuide, GuideType.完整抛物线)
  34. }
  35. if (LocalData.getInstance().getParabolaCount() > 0) {
  36. RewardMnr.getInstance().PropUseParabola(1)
  37. } else {
  38. // cc.systemEvent.emit(EventName.Tips, `完整抛物线去看广告一次的逻辑`)
  39. RewardMnr.getInstance().PopAward(AwardType.XuXian)
  40. LocalData.getInstance().setParabolaCount(3, '+')
  41. }
  42. }
  43. changeParabolaCount() {
  44. if (LocalData.getInstance().getParabolaCount() > 0) {
  45. this.CountBg_Video.spriteFrame = this.CountBg
  46. this.Count.string = LocalData.getInstance().getParabolaCount().toString()
  47. } else {
  48. this.CountBg_Video.spriteFrame = this.Video
  49. this.Count.string = ''
  50. }
  51. }
  52. // update (dt) {}
  53. }