CheckpointLeaveViewComp.ts 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. import { EventTouch, Node, Toggle, _decorator } from "cc";
  2. import { oops } from "../../../../../extensions/oops-plugin-framework/assets/core/Oops";
  3. import { ecs } from "../../../../../extensions/oops-plugin-framework/assets/libs/ecs/ECS";
  4. import { CCComp } from "../../../../../extensions/oops-plugin-framework/assets/module/common/CCComp";
  5. import { UIID } from "../../common/config/GameUIConfig";
  6. import { SingletonModuleComp } from "../../common/SingletonModuleComp";
  7. import { AdManager } from "../../../platform/ad/AdManager";
  8. const { ccclass, property } = _decorator;
  9. /** 角色信息界面 */
  10. @ccclass('CheckpointLeaveViewComp')
  11. @ecs.register('CheckpointLeaveView', false)
  12. export class CheckpointLeaveViewComp extends CCComp {
  13. private btnClose
  14. private btnGiveup
  15. private btnGet
  16. onAdded(args: any) {
  17. console.log(args);
  18. }
  19. onLoad() {
  20. this.btnClose = this.node.getChildByPath("BG/btn_close")
  21. this.btnGiveup = this.node.getChildByPath("BG/btn_giveup")
  22. this.btnGet = this.node.getChildByPath("BG/btn_get")
  23. this.btnClose.on(Node.EventType.TOUCH_END, this.onTouchEnd, this);
  24. this.btnGiveup.on(Node.EventType.TOUCH_END, this.onTouchEnd, this);
  25. this.btnGet.on(Node.EventType.TOUCH_END, this.onTouchEnd, this);
  26. }
  27. private onTouchEnd(event: EventTouch) {
  28. switch (event.target.name) {
  29. case "btn_close":
  30. oops.gui.remove(UIID.VehicleLeave);
  31. break;
  32. case "btn_giveup":
  33. oops.gui.remove(UIID.VehicleLeave);
  34. break;
  35. case "btn_get":
  36. AdManager.getInstance().showRewardVideoAd(()=>{
  37. console.log('成功看完广告')
  38. ecs.getSingleton(SingletonModuleComp).account.checkpoint.CheckpointModelBase.vm.leaveCount+=1
  39. })
  40. break;
  41. }
  42. event.propagationStopped = true;
  43. }
  44. reset() {
  45. this.node.destroy();
  46. }
  47. }