import api_game as api_game
import game_1 as quest_game

str_path_img="data\\img\\"
str_img_menu=str_path_img+"menu\\game\\object_select.jpg"

music_location="data\\sound\\lost-night-beach.ogg"

def on_create():
	global music_location
	api_game.load_stream(music_location,1)
	api_game.fade_music(music_location,0,3)

	api_game.load_stream("data\\sound\\quest\\amb_les_water.ogg",0)
	api_game.set_local_vol("data\\sound\\quest\\amb_les_water.ogg",0.3)
	api_game.play_sound("data\\sound\\quest\\amb_les_water.ogg",1)

	str_path_icon=str_path_img+"lev\\"+__name__+"\\objects_icon\\"
	str_path_m_icon=str_path_img+"lev\\"+__name__+"\\items\\"
	quest_game.set_path_small_icon(str_path_img+"lev\\"+__name__+"\\icons\\")

	api_game.enable_update(0,"vkl_1", 0)
	api_game.enable_visibility(0,"vkl_1", 0)
        api_game.enable_visibility(0,"obj_1_zapl", 0)
	api_game.enable_visibility(0,"obj_2_zapl", 0)
	api_game.enable_visibility(0,"obj_3_zapl", 0)
	api_game.enable_visibility(0,"obj_4_zapl", 0)

	api_game.enable_visibility(0,"puzzle_back", 0)
	api_game.enable_visibility(0,"puzzle", 0)
	api_game.enable_visibility(0,"puzzle_glow", 0)

	str_icons_menu=[str_path_icon+"small_icon13.jpg",str_path_icon+"small_icon11.jpg",str_path_icon+"small_icon11.jpg",str_path_icon+"small_icon11.jpg",str_path_icon+"small_icon12.jpg","","",""]
	str_icon_mouse=[str_path_m_icon+"normal_object13.jpg",str_path_m_icon+"normal_object11.jpg",str_path_m_icon+"normal_object11.jpg",str_path_m_icon+"normal_object11.jpg",str_path_m_icon+"normal_object12.jpg","","",""]
	str_objects_on_loc=["it4","it10","it11","it12","it19","","",""]
	quest_game.add_of("1", str_img_menu, str_icons_menu, str_icon_mouse, str_objects_on_loc, -1.5,0,0)

	str_icons_menu=[str_path_icon+"small_icon14.jpg",str_path_icon+"small_icon18.jpg",str_path_icon+"small_icon15.jpg",str_path_icon+"small_icon17.jpg",str_path_icon+"small_icon16.jpg","","",""]
	str_icon_mouse=[str_path_m_icon+"normal_object14.jpg",str_path_m_icon+"normal_object18.jpg",str_path_m_icon+"normal_object15.jpg",str_path_m_icon+"normal_object17.jpg",str_path_m_icon+"normal_object16.jpg","","",""]
	str_objects_on_loc=["it3","it5","it14","it20","it18","","",""]
	quest_game.add_of("2", str_img_menu, str_icons_menu, str_icon_mouse, str_objects_on_loc, 1.5,0,0)

	str_icons_menu=[str_path_icon+"small_icon7.jpg",str_path_icon+"small_icon6.jpg",str_path_icon+"small_icon9.jpg",str_path_icon+"small_icon10.jpg",str_path_icon+"small_icon8.jpg","","",""]
	str_icon_mouse=[str_path_m_icon+"normal_object7.jpg",str_path_m_icon+"normal_object6.jpg",str_path_m_icon+"normal_object9.jpg",str_path_m_icon+"normal_object10.jpg",str_path_m_icon+"normal_object8.jpg","","",""]
	str_objects_on_loc=["it6","it7","it8","it9","it13","","",""]
	quest_game.add_of("5", str_img_menu, str_icons_menu, str_icon_mouse, str_objects_on_loc, -2.72,0,-10)

	str_icons_menu=[str_path_icon+"small_icon21.jpg",str_path_icon+"small_icon22.jpg",str_path_icon+"small_icon23.jpg",str_path_icon+"small_icon20.jpg",str_path_icon+"small_icon19.jpg","","",""]
	str_icon_mouse=[str_path_m_icon+"normal_object21.jpg",str_path_m_icon+"normal_object22.jpg",str_path_m_icon+"normal_object23.jpg",str_path_m_icon+"normal_object20.jpg",str_path_m_icon+"normal_object19.jpg","","",""]
	str_objects_on_loc=["it1","it2","it15","it25","it23","","",""]
	quest_game.add_of("3", str_img_menu, str_icons_menu, str_icon_mouse, str_objects_on_loc, 2.5,0,0)

	str_icons_menu=[str_path_icon+"small_icon4.jpg",str_path_icon+"small_icon2.jpg",str_path_icon+"small_icon3.jpg",str_path_icon+"small_icon1.jpg",str_path_icon+"small_icon5.jpg","","",""]
	str_icon_mouse=[str_path_m_icon+"normal_object4.jpg",str_path_m_icon+"normal_object2.jpg",str_path_m_icon+"normal_object3.jpg",str_path_m_icon+"normal_object1.jpg",str_path_m_icon+"normal_object5.jpg","","",""]
	str_objects_on_loc=["it17","it21","it22","it24","it16","","",""]
	quest_game.add_of("4", str_img_menu, str_icons_menu, str_icon_mouse, str_objects_on_loc, 1.5,0,43)

	quest_game.set_state_of("1", 2)
	#api_game.play_anim(0,"anim","q_kuvshin_loc_4", 5, 0)		
	api_game.set_goal("goal_4_1")

def on_mouse_down_of(object_name, p_object, state):
	if object_name == "1" and state == 3:
		quest_game.set_state_of("2", 2)
		quest_game.show_object("obj_2_zapl","quest_anim",0.5,0,0)
		api_game.set_goal("goal_4_2")
	elif object_name == "2" and state == 3:
		quest_game.set_state_of("5", 2)
		quest_game.show_object("obj_1_zapl","quest_anim",0.5,0,0)
		api_game.set_goal("goal_4_3")
	elif object_name == "5" and state == 3:
		quest_game.set_state_of("3", 2)
		quest_game.show_object("obj_3_zapl","quest_anim",0.5,0,0)
		quest_game.add_oc("sekret", "data\\img\\lev\\loc_4_1\\objects\\sekret_glow.gif", "vkl_1")
		api_game.set_goal("goal_4_4")
	elif object_name == "3" and state == 3:
		quest_game.set_state_of("4", 2)
		quest_game.show_object("obj_4_zapl","quest_anim",0.5,0,0)
		api_game.set_goal("goal_4_5")
	elif object_name == "4" and state == 3:
		quest_game.add_oc("zaglushka", "data\\img\\lev\\loc_4_1\\objects\\glow.gif", "")
		api_game.play_anim(0,"zaglushka","quest_anim", 0.5, 1)		
		quest_game.add_object_puzzle(0,"zaglushka")

def on_mouse_down_oc(object_name, p_object):
	if object_name == "zaglushka":
		quest_game.remove_object_puzzle(0,"zaglushka")
		quest_game.remove_oc("zaglushka")
		api_game.attach_game("data\\menu\\levels\\loc_4_3")
		api_game.activate_game("loc_4_3",1)
		api_game.set_goal("tut_4_2")

def on_event(object_name, p_object, event):	
	if event == 11000 and object_name == "loc_4_3":
		api_game.activate_game("loc_4_3",0)
#		api_game.game_win()
		api_game.enable_visibility(0,"puzzle_back", 1)
		api_game.enable_visibility(0,"puzzle", 1)
		api_game.enable_visibility(0,"puzzle_glow", 1)
		quest_game.add_object_check(0,"puzzle","puzzle_glow")
		api_game.set_goal("goal_4_6")
	if event == 11000 and object_name == "loc_4_4":
		api_game.game_win()

def on_mouse_down_simple(object_name,p_object):
	if object_name == "puzzle":
#		api_game.play_anim(0,"puzzle","quest_anim", 0.5, 1)
#		api_game.play_anim(0,"puzzle_back","quest_anim", 0.5, 1)
#		api_game.enable_visibility(0,"puzzle_glow", 0)
		api_game.attach_game("data\\menu\\levels\\loc_4_4")
		api_game.activate_game("loc_4_4",1)
		api_game.set_goal("tut_4_3")

def on_stop_anim(object_name, anim_name, p_object, i_track):	
	if object_name == "anim" and i_track == 0:
		api_game.play_anim(0,object_name,anim_name,10, 1)
	elif object_name == "anim" and i_track == 1:
		api_game.play_anim(0,object_name,anim_name,10, 0)

