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-jungle.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\\q_cep_music.ogg",0)
	api_game.set_local_vol("data\\sound\\quest\\q_cep_music.ogg",0.1)

	api_game.load_stream("data\\sound\\quest\\amb_sea.ogg",0)
	api_game.set_local_vol("data\\sound\\quest\\amb_sea.ogg",0.4)
	api_game.play_sound("data\\sound\\quest\\amb_sea.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,"zaplatka", 0)
	api_game.enable_visibility(0,"cep2", 0)
	api_game.enable_visibility(0,"lodka_final", 0)
	api_game.enable_visibility(0,"ru4ka", 0)

	str_icons_menu=[str_path_icon+"item22.gif",str_path_icon+"item1.gif",str_path_icon+"item24.gif",str_path_icon+"item9.gif",str_path_icon+"item14.gif","","",""]
	str_icon_mouse=[str_path_m_icon+"doski1.gif",str_path_m_icon+"gvozd1.gif",str_path_m_icon+"stameska1.gif",str_path_m_icon+"molotok1.gif",str_path_m_icon+"klei1.gif","","",""]
	str_objects_on_loc=["doski","gvozdi","stamestka","molotok","kley","","",""]
	quest_game.add_of("dira", str_img_menu, str_icons_menu, str_icon_mouse, str_objects_on_loc, -1.5,0,0)

	str_icons_menu=[str_path_icon+"item25.gif",str_path_icon+"item15.gif",str_path_icon+"item20.gif",str_path_icon+"item13.gif",str_path_icon+"item5.gif","","",""]
	str_icon_mouse=[str_path_m_icon+"gaika1.gif",str_path_m_icon+"nosh1.gif",str_path_m_icon+"bulavka1.gif",str_path_m_icon+"bell1.gif",str_path_m_icon+"rule1.gif","","",""]
	str_objects_on_loc=["gaika","no","bulavka","bell","lineika","","",""]
	quest_game.add_of("cep", str_img_menu, str_icons_menu, str_icon_mouse, str_objects_on_loc, -1.5,-10,0)

	str_icons_menu=[str_path_icon+"item17.gif",str_path_icon+"item8.gif",str_path_icon+"item6.gif",str_path_icon+"item7.gif",str_path_icon+"item11.gif","","",""]
	str_icon_mouse=[str_path_m_icon+"ruchka1.gif",str_path_m_icon+"shest1.gif",str_path_m_icon+"lupa1.gif",str_path_m_icon+"fonar1.gif",str_path_m_icon+"prushina1.gif","","",""]
	str_objects_on_loc=["ru4ka2","chest","lupa","fonar","pruzina","","",""]
	quest_game.add_of("mehanizm", str_img_menu, str_icons_menu, str_icon_mouse, str_objects_on_loc, -1.5,0,0)

	str_icons_menu=[str_path_icon+"item3.gif",str_path_icon+"item12.gif",str_path_icon+"item18.gif",str_path_icon+"item4.gif",str_path_icon+"item10.gif","","",""]
	str_icon_mouse=[str_path_m_icon+"gir1.gif",str_path_m_icon+"last1.gif",str_path_m_icon+"mask1.gif",str_path_m_icon+"map1.gif",str_path_m_icon+"book1.gif","","",""]
	str_objects_on_loc=["giry","last","maska","karta","book","","",""]
	quest_game.add_of("ru4ka", str_img_menu, str_icons_menu, str_icon_mouse, str_objects_on_loc, 1.5,0,0)

	str_icons_menu=[str_path_icon+"item2.gif",str_path_icon+"item19.gif",str_path_icon+"item23.gif",str_path_icon+"item16.gif",str_path_icon+"item26.gif","","",""]
	str_icon_mouse=[str_path_m_icon+"lom1.gif",str_path_m_icon+"ploskagub1.gif",str_path_m_icon+"poplavok1.gif",str_path_m_icon+"topor1.gif",str_path_m_icon+"zashigalka1.gif","","",""]
	str_objects_on_loc=["lom","pasatii","poplavok","topor","zippo","","",""]
	quest_game.add_of("box", str_img_menu, str_icons_menu, str_icon_mouse, str_objects_on_loc, -1.5,0,0)

	quest_game.set_state_of("dira", 2)
	quest_game.add_oc("vedro", "data\\img\\lev\\loc_2_1\\objects\\vedro_glow.gif", "vkl_1")

	quest_game.set_collect_sound("dira","data\\sound\\quest\\q_molotok.ogg")
	quest_game.set_collect_sound("mehanizm","data\\sound\\quest\\q_cep.ogg")
	quest_game.set_collect_sound("ru4ka","data\\sound\\quest\\q_ruchka.ogg")
	quest_game.set_collect_sound("box","data\\sound\\quest\\q_open_door.ogg")

	api_game.attach_game("data\\menu\\levels\\loc_2_2")
	api_game.activate_game("loc_2_2",1)
	api_game.set_goal("tut_2_2")

def on_mouse_down_of(object_name, p_object, state):
	if object_name == "dira" and state == 3:
		api_game.play_anim(0,"zaplatka","quest_anim",0.1,0)
		quest_game.set_state_of("cep", 2)
		api_game.set_goal("goal_2_2")
	elif object_name == "cep" and state == 3:
		api_game.play_anim(0,"cep","quest_anim",0.1,1)
		api_game.play_anim(0,"cep2","quest_anim",0.1,0)
		quest_game.set_state_of("mehanizm", 2)
		api_game.set_goal("goal_2_3")
	elif object_name == "mehanizm" and state == 3:
		api_game.play_anim(0,"ru4ka","quest_anim",0.1,0)
		quest_game.set_state_of("ru4ka", 2)
		api_game.set_goal("goal_2_4")
	elif object_name == "ru4ka" and state == 3:
		api_game.set_goal("goal_2_5")
		api_game.play_anim(0,"dira","quest_anim",0.1,1)
		api_game.play_anim(0,"zaplatka","quest_anim",0.1,1)
		api_game.play_anim(0,"lodka_dira","quest_anim",0.1,1)
		api_game.play_anim(0,"lodka_final","quest_anim",0.1,0)
		quest_game.set_state_of("box", 2)
	elif object_name == "box" and state == 3:
		api_game.play_anim(0,"box","quest_anim",0.1,1)		
				 
def on_event(object_name, p_object, event):	
	if event == 22 and object_name == "box":	
		api_game.game_win()
	elif event == 11000 and object_name == "loc_2_2":
		api_game.activate_game("loc_2_2",0)
		api_game.play_sound("data\\sound\\quest\\q_cep_music.ogg",1)
	elif event == 11004 and object_name == "loc_2_2":
		api_game.fade_off(1,"")
		api_game.set_goal("goal_2_1")
