extend(GameOver, createjs.Container);

function GameOver()
{	
	this.initialize();
//--------------------------------//
	var cont = new createjs.Container()
	var crown = new createjs.Sprite(jsons["JSON2"]);
	crown.gotoAndStop("window_crown")
	setCoor(crown, 19, 600)

	var t = new createjs.Sprite(jsons["JSON2"]);
	t.gotoAndStop("window")
	t.x = WIDTHGAME/2 - t.getBounds().width/2
	t.y = HEIGHTGAME/2 - t.getBounds().height/2

	var title1 = new createjs.Sprite(jsons["JSON2"]);			/// Заголовок
	setCoor(title1, 212, 5)

	var board = new createjs.Sprite(jsons["JSON2"]);
	board.gotoAndStop('text_hit_rate')
	setCoor(board, 127, 464)
	// dragAndDrop(board)
	var btnback = new Arrow("left")
	setCoor(btnback, 54, 19)

	var btnReplay = new Button({i: "btn_reset"})
	setCoor(btnReplay, 522, 19)
	// dragAndDrop(btnReplay)

	var cac = new createjs.Sprite(jsons["JSON2"]);
	cac.gotoAndStop("text_cash") 
	setCoor(cac, 209, 348)

	var mon = new createjs.Sprite(jsons["JSON1"]);
	mon.gotoAndStop("icon_money") 
	setCoor(mon, 114, 320)

	var reason = new createjs.Sprite(jsons["JSON2"]);
	// reason.gotoAndStop("text_fleet_sunk")
	var opo = new createjs.Sprite(jsons["JSON2"]);
	opo.gotoAndStop("text_opponents");
	setCoor(reason, 183, 160);
	setCoor(opo, 174, 189);
	// dragAndDrop(reason)
	// dragAndDrop(opo)

	btnback.addEventListener("click", function(){v_choiseLocation("menu")})
	btnReplay.addEventListener("click", function(){v_choiseLocation("choise");})

	var changed = new createjs.Container()

	var frame = new FloatFrame()
	frame.addToTopPlatform(cont, 0)
	frame.addToTopPlatform(title1)
	frame.addToTopPlatform(crown)
	frame.addToTopPlatform(btnback)
	frame.addToTopPlatform(btnReplay)
	frame.addToTopPlatform(cac)
	frame.addToTopPlatform(mon)

	cont.addChild(t)
	cont.addChild(board)
	cont.addChild(changed)
	cont.addChild(reason)
	// cont.addChild(opo)
	// dragAndDrop(t)
	// dragAndDrop(board)
	// dragAndDrop(changed)
	// dragAndDrop(reason)
	// dragAndDrop(cac)
	// dragAndDrop(mon)
	// dragAndDrop(title1)

	this.addChild(frame)

	this.update = function(par){
		// console.log(par)
		FB_GO()
		var u = ""
		if(par && par.title == "text_red_victory")
			u = "_opponents"
		else
			u = ""
		if(par.reason == "sunk")
			reason.gotoAndStop("text" + u + "_fleet_sunk")
		else
			reason.gotoAndStop("text" + u + "_lives_lost")

		title1.gotoAndStop(par.title);
		title1.x = WIDTHGAME/2 - title1.getBounds().width/2
		// console.log(par.hit_rate_bot, par.treasures_bot)

		changed.removeAllChildren()
		var user_ships = new Text(jsons["JSON2"], "numbers_green_",null, 33)
		user_ships.setText(par.hit_rate_user + "%")
		setCoor(user_ships, 485-85 - 45, 223+118 + 14 + 114)

		var user_money = new Text(jsons["JSON2"], "numbers_green_",null, 33)
		// console.log(par.num_money)
		user_money.setText(par.num_money)
		setCoor(user_money, 376 - 35, 348)

		// var bot_ships = new Text(jsons["JSON2"], "text_green_",null, 33)
		// bot_ships.setText(par.hit_rate_bot + "%")
		// setCoor(bot_ships, 478-85, 460)

		var user_tre = new Text(jsons["JSON2"], "numbers_green_",null, 33)
		user_tre.setText(par.treasures_user)
		setCoor(user_tre, 509-55+9 - 45, 283+120 + 14 + 114)

		// var bot_tre = new Text(jsons["JSON2"], "text_green_",null, 33)
		// bot_tre.setText(par.treasures_bot)
		// setCoor(bot_tre, 484-35, 518)

		changed.addChild(user_ships)
		changed.addChild(user_tre)
		changed.addChild(user_money)
	}
}