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

@ccclass('win')
export class win extends Component {
    @property(Node) btn_close:Node = null;
    @property(Node) btn_share:Node = null;
    @property(Node) btn_next:Node = null;
    @property(Node) icon:Node = null;
    private m_call_share = null;
    private m_call_next = null;
    public show(call_share,call_next){
        this.node.active = true;
        this.m_call_next = call_next;
        this.m_call_share = call_share;
        this.btn_share.off(Node.EventType.TOUCH_END)
        this.btn_next.off(Node.EventType.TOUCH_END)
        this.btn_close.off(Node.EventType.TOUCH_END)

        this.btn_share.on(Node.EventType.TOUCH_END,()=>{
            if(this.m_call_share!=null){
                this.m_call_share()
            }
        })
        this.btn_next.on(Node.EventType.TOUCH_END,()=>{
            if(this.m_call_next!=null){
                this.m_call_next()
            }
        })
        this.btn_close.on(Node.EventType.TOUCH_END,()=>{
            this.node.active = false;
            gameManager.Singleton.backGameList()
        })
        if(gameManager.Singleton.getLevelData()!=null){
            tools.loadUrl(gameManager.Singleton.getLevelData().complete_img,this.icon.getComponent(Sprite))
        }
        gameManager.Singleton.sys_success_complete_music()
    }
}


