import { _decorator, Component, Label, Node } from 'cc';
const { ccclass, property } = _decorator;

@ccclass('unlock_play_dialog')
export class unlock_play_dialog extends Component {

    @property(Node) lab_name:Node = null
    @property(Node) btn_coin:Node = null
    @property(Node) btn_look_video:Node = null
    @property(Node) btn_close:Node = null

    initView(title: string, coin_number:number, look_video_string:string, coin_callback:any, look_video_callback:any) {
        this.lab_name.getComponent(Label).string = title
        this.setupCoinNumber(coin_number)
        this.setupLookVideo(look_video_string)
        this.btn_coin.on(Node.EventType.TOUCH_END, ()=> {
            if(coin_callback != null) {
                coin_callback(this)
            }
        },this)
        this.btn_look_video.on(Node.EventType.TOUCH_END, ()=> {
            if(look_video_callback != null) {
                look_video_callback(this)
            }
        },this)
        this.btn_close.on(Node.EventType.TOUCH_END, ()=> {
            this.close()
        },this)
    }

    setupCoinNumber(number:number) {
        this.btn_coin.children[0].getComponent(Label).string = number + ''
    }

    public setupLookVideo(string:string) {
        this.btn_look_video.children[0].getComponent(Label).string = string
    }

    public close() {
        this.node.removeFromParent()
    }
}

