/**
 * @description 互推界面
 * @author kaka
 */

const { ccclass, property } = cc._decorator;

@ccclass
export default class MoreGame extends cc.Component {

    @property(cc.Node)
    node_sv: cc.Node = null;

    @property(cc.Prefab)
    moreGameNormalNode: cc.Prefab = null

    private normalDatas = null


    start() {
        this.node.setContentSize(cc.winSize)
        gData.moreGame.init();
    }

    update() {
        if (gData.moreGame.init_moreGameList) {
            this.initView();
        }
    }

    lateUpdate() {
        gData.moreGame.init_moreGameList = false;
    }

    initView() {
        this.normalDatas = gData.moreGame.moreGameList.normal;
        let data = [];
        let len = this.normalDatas.length;
        for (var i = 0; i < len; i++) {
            let pfbType = 0;
            let obj = {
                item_data: this.normalDatas[i],
                pfbType: pfbType
            }
            data.push(obj);
            if (i == 1) {
                pfbType = 1;
                let obj = {
                    item_data: gData.moreGame.moreGameList.banner,
                    pfbType: pfbType
                }
                data.push(obj);
            }
        }
        this.node_sv.emit('srollview-init', data)
    }
    
    onClickClose() {
        mk.ad.checkShowInterByChance();
    }
}
