import { _decorator, Component, Label, Node, Sprite, SpriteFrame, Vec3 } from 'cc';
import { server_han_zi_zhao_bu_tong_data_item, server_mei_nv_zhao_xi_jie_data_item, server_shuang_tu_zhao_bu_tong_data_item } from '../data/server_play_list_data';
import { Util } from '../framework/util';
import { gameManager } from '../gameManager';
import { config } from '../config';
const { ccclass, property } = _decorator;

@ccclass('win')
export class win extends Component {
    @property(Node) btn_back:Node;
    @property(Node) btn_ordinary:Node;
    @property(Node) btn_double:Node;
    @property(Node) lab_reward_number:Node;
    @property(Node) lab_title:Node;
    @property(Node) img_emote:Node;
    @property(Node) btn_next_level:Node;
    @property(Node) lab_title_1:Node;
    @property(Node) bg:Node;
    @property(SpriteFrame) spr_reward_sf:SpriteFrame;
    private m_reward_number:number;
    private m_ordinary_call:any = null;
    private m_double_call:any = null;
    start() {
        let self = this;
        this.btn_back.on(Node.EventType.TOUCH_START,()=>{
            self.close();
        },this);
        this.btn_ordinary.on(Node.EventType.TOUCH_START,()=>{
            if(this.m_ordinary_call!=null){
                this.m_ordinary_call(this)
            }
        },this);
        this.btn_double.on(Node.EventType.TOUCH_START,()=>{
            if(this.m_double_call!=null){
                this.m_double_call(this)
            }
        },this);   
        this.btn_next_level.on(Node.EventType.TOUCH_START,()=>{
            if(this.m_ordinary_call!=null){
                this.m_ordinary_call(this)
            }
        },this);   
    }
    public close(){
        this.node.removeFromParent();
    }

    public hideAllBtn(){
        this.btn_ordinary.active = false;
        this.btn_double.active = false;
    }

    public showDoubleCoin(doubel_reward,call_back){
        let reward = this.m_reward_number
        let obj = new Component
        gameManager.instance.addCoinNumber(obj,doubel_reward,this.lab_reward_number.getComponent(Label),reward,()=>{
            call_back()
        },"+ ")
        this.hideAllBtn()
    }

    public showView(reward:number,data:server_mei_nv_zhao_xi_jie_data_item,ordinary_call,double_call){
        this.m_double_call = double_call;
        this.m_ordinary_call = ordinary_call;
        this.m_reward_number = reward;
        this.lab_reward_number.getComponent(Label).string = "+ " +reward+"";
    }

    public showJYLView(ordinary_call,categoryid){
        if(categoryid===config.PLAY_TYPE.DOU_DI_ZHU){
            this.bg.angle = -90;
            this.bg.position = new Vec3(this.bg.position.x-40,this.bg.position.y,this.bg.position.z)
        }else{

        }
        this.hideAllBtn()
        this.m_ordinary_call = ordinary_call;
        this.btn_next_level.active = true;
        this.lab_reward_number.active = false;
        this.lab_title_1.active = false;
    }

    public showVideoAddCoinView(reward:number,data:server_mei_nv_zhao_xi_jie_data_item,ordinary_call,double_call){
        this.m_double_call = double_call;
        this.m_ordinary_call = ordinary_call;
        this.lab_title.active = false;
        this.m_reward_number = reward;
        this.img_emote.getComponent(Sprite).spriteFrame = this.spr_reward_sf;
        this.lab_reward_number.getComponent(Label).string = "+ " +reward+"";
    }
}


