import { _decorator, Component, Node } from 'cc';
import { gameManager } from '../gameManager';
const { ccclass, property } = _decorator;

@ccclass('fail')
export class fail extends Component {
    @property(Node) btn_close:Node = null;
    @property(Node) btn_fail_reLife:Node = null;
    @property(Node) btn_fail_reStart:Node = null;
    private m_call_relife = null;
    private m_call_restart = null;
    protected start(): void {
        this.btn_fail_reLife.off(Node.EventType.TOUCH_END)
        this.btn_fail_reLife.on(Node.EventType.TOUCH_END,()=>{
            if(this.m_call_relife!=null){
                this.m_call_relife()
            }
        })
        this.btn_fail_reStart.off(Node.EventType.TOUCH_END)
        this.btn_fail_reStart.on(Node.EventType.TOUCH_END,()=>{
            if(this.m_call_restart!=null){
                this.m_call_restart()
            }
        })
        this.btn_close.off(Node.EventType.TOUCH_END)
        this.btn_close.on(Node.EventType.TOUCH_END,()=>{
            this.node.active = false;
            if(gameManager.Singleton.getLevelData()!=null){
                gameManager.Singleton.backGameList()
            }
        })
    }

    public show(is_relife:boolean,call_relife,call_restart){
        this.node.active = true;
        this.m_call_relife = call_relife;
        this.m_call_restart = call_restart;
        if(is_relife){
            this.btn_fail_reLife.active = true;
        }else{
            this.btn_fail_reLife.active = false;
        }
        gameManager.Singleton.sys_fail_prompt_music()
    }


    // public show(is_relife:boolean,call_relife,call_restart){
    //     this.node.active = true;
    //     this.m_call_relife = call_relife;
    //     this.m_call_restart = call_restart;
    //     if(is_relife){
    //         this.btn_fail_reLife.active = true;
    //     }else{
    //         this.btn_fail_reLife.active = false;
    //     }
    //     this.btn_fail_reLife.off(Node.EventType.TOUCH_END)
    //     this.btn_fail_reStart.off(Node.EventType.TOUCH_END)
    //     this.btn_close.off(Node.EventType.TOUCH_END)
    //     this.btn_fail_reLife.on(Node.EventType.TOUCH_END,()=>{
    //         if(this.m_call_relife!=null){
    //             this.m_call_relife()
    //         }
    //     })
    //     this.btn_fail_reStart.on(Node.EventType.TOUCH_END,()=>{
    //         if(this.m_call_restart!=null){
    //             this.m_call_restart()
    //         }
    //     })
    //     this.btn_close.on(Node.EventType.TOUCH_END,()=>{
    //         this.node.active = false;
    //         if(gameManager.Singleton.getLevelData()!=null){
    //             gameManager.Singleton.backGameList()
    //         }
    //     })
    //     gameManager.Singleton.sys_fail_prompt_music()
    // }
}


