

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 { CheckpointSkinItemViewComp } from "./CheckpointSkinItem";


const { ccclass, property } = _decorator;

/** 角色换装界面 */
@ccclass('CheckpointSkinViewComp')
@ecs.register('CheckpointSkinView', false)
export class CheckpointSkinViewComp extends CCComp {

    @property({ type: [CheckpointSkinItemViewComp], visible: true, tooltip: '关卡item' })
    itemArr: Array<CheckpointSkinItemViewComp> = []


    private btnClose

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

    onLoad() {
        this.btnClose = this.node.getChildByPath("BG/btn_close")
        this.btnClose.on(Node.EventType.TOUCH_END, this.onTouchEnd, this);
    }

    private onTouchEnd(event: EventTouch) {
        switch (event.target.name) {
            case "btn_close":
                oops.gui.remove(UIID.Skin);
                break;
        }

        event.propagationStopped = true;
    }

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