| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869 |
- import { EventTouch, Node, Toggle, _decorator } from "cc";
- import { oops } from "../../../../../extensions/oops-plugin-framework/assets/core/Oops";
- import { ecs } from "../../../../../extensions/oops-plugin-framework/assets/libs/ecs/ECS";
- import { CCComp } from "../../../../../extensions/oops-plugin-framework/assets/module/common/CCComp";
- import { UIID } from "../../common/config/GameUIConfig";
- import { SingletonModuleComp } from "../../common/SingletonModuleComp";
- import { AdManager } from "../../../platform/ad/AdManager";
- import { ClearCellOperationComp } from "../bll/ClearCellOperation";
- const { ccclass, property } = _decorator;
- /** 角色信息界面 */
- @ccclass('CheckpointClearViewComp')
- @ecs.register('CheckpointClearView', false)
- export class CheckpointClearViewComp extends CCComp {
- private btnClose
- private btnGiveup
- private btnGet
- onAdded(args: any) {
- console.log(args);
- }
- onLoad() {
- this.btnClose = this.node.getChildByPath("BG/btn_close")
- this.btnGiveup = this.node.getChildByPath("BG/btn_giveup")
- this.btnGet = this.node.getChildByPath("BG/btn_get")
- this.btnClose.on(Node.EventType.TOUCH_END, this.onTouchEnd, this);
- this.btnGiveup.on(Node.EventType.TOUCH_END, this.onTouchEnd, this);
- this.btnGet.on(Node.EventType.TOUCH_END, this.onTouchEnd, this);
- }
- private onTouchEnd(event: EventTouch) {
- switch (event.target.name) {
- case "btn_close":
- oops.gui.remove(UIID.ClearCell);
- break;
- case "btn_giveup":
- oops.gui.remove(UIID.ClearCell);
- break;
- case "btn_get":
- const checkpoint = ecs.getSingleton(SingletonModuleComp).account.checkpoint
- if (checkpoint.CheckpointModelBase.vm.clearCount >= 3) {
- oops.gui.toast('该关卡使用次数已满')
- oops.gui.remove(UIID.ClearCell);
- return
- }
- // ecs.getSingleton(SingletonModuleComp).account.checkpoint.add(ClearCellOperationComp)
- // ecs.getSingleton(SingletonModuleComp).account.checkpoint.CheckpointModelBase.vm.clearCount+=1
- AdManager.getInstance().showRewardVideoAd(()=>{
- console.log('成功看完广告')
- ecs.getSingleton(SingletonModuleComp).account.checkpoint.add(ClearCellOperationComp)
- ecs.getSingleton(SingletonModuleComp).account.checkpoint.CheckpointModelBase.vm.clearCount+=1
- oops.gui.remove(UIID.ClearCell);
- })
- break;
- }
- event.propagationStopped = true;
- }
- reset() {
- this.node.destroy();
- }
- }
|