Gold.ts 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  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, { EventLabel, PopType } from "../EventName/EventName";
  8. import { Global } from "../Global";
  9. import LocalData from "../LocalData";
  10. import SDKManager from "../SDKManager";
  11. import MyComponent, { ButtonLock } from "../Template/MyComponent";
  12. const { ccclass, property } = cc._decorator;
  13. @ccclass
  14. export default class Gold extends MyComponent {
  15. Label: cc.Label = null
  16. onLoad(): void {
  17. this.Label = this.node.getComponentInChildren(cc.Label)
  18. }
  19. start() {
  20. this.regEvent(EventName.changeGold, this.UpdataGold, this)
  21. }
  22. UpdataGold() {
  23. this.Label.string = LocalData.getInstance().getGold().toString()
  24. }
  25. @ButtonLock(1, null)
  26. ClickGold() {
  27. let temp: PopType = new PopType()
  28. temp.string = EventLabel.OpenVideo
  29. temp.Title = '提示'
  30. temp.OK = () => {
  31. let OPenVideo: PopType = new PopType()
  32. OPenVideo.OK = () => {
  33. LocalData.getInstance().setGold(Global.adReward, '+')
  34. }
  35. SDKManager.instance.OPenVideo(OPenVideo)
  36. }
  37. temp.Fail = () => {
  38. }
  39. this.Pop(temp)
  40. }
  41. // update (dt) {}
  42. }