import GamesHallController from "../view/GamesHallController"
cc.Class({
    extends: cc.Component,

    properties: {
    },

    ctor: function () {

    },

    onLoad () {
    },

    start () {

    },
   
    onDestroy()
    {

    },

    initScene(gameid)
    {
        this.gameid = gameid
        this.SceneLevel = 1
    },

    playShow()
    {
        this.node.active = true
        var actionTo = cc.moveBy(0.3, cc.v2(-this.node.parent.width, 0));
        this.node.width = this.node.parent.width
        this.node.runAction(actionTo)
        // this.setShowingHall(this)
        if (this.parentScene.setShowingHall) {
            this.parentScene.setShowingHall(this)
        }
    },

    playEnd(nextScense)
    {
        var finished = cc.callFunc(function() {
            this.node.active = false;
            if (this.parentScene) {
                if(nextScense && nextScense.playShow)
                {
                    nextScense.playShow()
                    if (this.parentScene.setShowingHall) {
                        this.parentScene.setShowingHall(nextScense)
                    }
                }else if (this.parentScene && this.parentScene.playShow) {
                    this.parentScene.playShow()
                    if (this.parentScene.setShowingHall) {
                        this.parentScene.setShowingHall(this.parentScene)
                    }
                // if (this.parentScene.parentScene && this.parentScene.parentScene.setHalllistDisplay) {
                //     this.parentScene.parentScene.setHalllistDisplay(true)
                // }
            }
            }
             
            if (this.extraPlay) {
                this.extraPlay()
            }
        }, this, null);
        var actionTo = cc.sequence(cc.moveBy(0.3, cc.v2(this.node.parent.width, 0)),finished);
        this.node.runAction(actionTo)
    },

    setShowingHall(hall){
        if (this.parentScene && this.parentScene.setShowingHall) {
            this.parentScene.setShowingHall(hall)
        }
    },
    
});
