class LegalLimit extends Phaser.Scene
{
    preload ()
    {
        this.load.image('legallimit', '../common/assets/legal_limit.png?ver=' + VERSION);
    }

    create (data)
    {
        this.parent = data.scene;
        this.vDelta = data.vDelta;
        
        this.llImg = this.add.image(640, 360 + this.vDelta, 'legallimit');

        this.llWin = this.add.bitmapText(640, 390 + this.vDelta, data.fontBet, '');

        this.llWin.setOrigin(0.5);

		this.llWin.letterSpacing = -5;

        this.llTime = 2500;
        this.llTimer = -1;

		this.enabled = false;

        this.scene.sleep();
    }

    update (time, delta) 
    {
        if(this.llTimer >= 0)
        {
            this.llTimer -= delta;
        }

        if(this.llTimer < 0)
        {
			this.enabled = false;
			this.scene.sleep();
        }
    }

    onOrientationChange (v)
    {
        this.vDelta = v;
        this.llImg.setPosition(640, 360 + this.vDelta);
        this.llWin.setPosition(640, 390 + this.vDelta);
    }

	enable()
	{
		this.enabled = true;
	}
    
	show(totalWin)
    {
        if(!this.enabled)
		{
			return;
		}

		this.llWin.setText(totalWin);
        this.llTimer = this.llTime;
        this.scene.wake();
        this.scene.bringToTop();
    }
}
