


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";


const { ccclass, property } = _decorator;

/** 角色信息界面 */
@ccclass('CheckpointLevelPassComp')
@ecs.register('CheckpointLevelPassView', false)
export class CheckpointLevelPassViewComp extends CCComp {

    private btnRestart
    private timer

    onAdded(args: any) {
        console.log(args);
    }

    onLoad() {
        this.btnRestart = this.node.getChildByPath("btn_start")
        this.btnRestart.on(Node.EventType.TOUCH_END, this.onTouchEnd, this);
        this.timer = setTimeout(() => {
            this.passLevel()
            clearTimeout(this.timer)
        },1000)
    }

    private onTouchEnd(event: EventTouch) {
        switch (event.target.name) {
            case "btn_start":
                this.passLevel()
                break;
        }

        event.propagationStopped = true;
    }

    passLevel() {
        oops.gui.remove(UIID.LevelPass);
    }

    reset() {
        clearTimeout(this.timer)
        this.node.destroy();
    }
}