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-sea.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_energy_up.ogg",0)

	api_game.load_stream("data\\sound\\quest\\amb_sea.ogg",0)
	api_game.set_local_vol("data\\sound\\quest\\amb_sea.ogg",0.3)
	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_update(0,"vkl_2", 0)
	api_game.enable_visibility(0,"vkl_1", 0)
	api_game.enable_visibility(0,"vkl_2", 0)
	api_game.enable_visibility(0,"globe_falled", 0)
	api_game.enable_visibility(0,"shkaf_object", 0)
	api_game.enable_visibility(0,"stekl_object", 1)

	p_stekl = api_game.get_child(0,"stekl_object")
	api_game.enable_visibility(p_stekl,"stekl_object1", 0)
	api_game.enable_visibility(p_stekl,"stekl_object2", 0)

	str_icons_menu=[str_path_icon+"shoes.jpg",str_path_icon+"bottle.jpg",str_path_icon+"parfume.jpg",str_path_icon+"spoon.jpg",str_path_icon+"foto.jpg","","",""]
	str_icon_mouse=[str_path_m_icon+"shoes_big.jpg",str_path_m_icon+"bottle_big.jpg",str_path_m_icon+"parfume_big.jpg",str_path_m_icon+"spoon_big.jpg",str_path_m_icon+"foto_big.jpg","","",""]
	str_objects_on_loc=["shoes","vine","parfume","spoon","foto","","",""]
	quest_game.add_of("stekl_object", str_img_menu, str_icons_menu, str_icon_mouse, str_objects_on_loc, 1.5,0,0)

	str_icons_menu=[str_path_icon+"gilet.jpg",str_path_icon+"neclace.jpg",str_path_icon+"compas.jpg",str_path_icon+"pasport.jpg",str_path_icon+"bag.jpg","","",""]
	str_icon_mouse=[str_path_m_icon+"gilet_big.jpg",str_path_m_icon+"necklace_big.jpg",str_path_m_icon+"compas_big.jpg",str_path_m_icon+"pasport_big.jpg",str_path_m_icon+"bag_big.jpg","","",""]
	str_objects_on_loc=["vkl_1_gilet","neklace","compas","pasport","bag","","",""]
	quest_game.add_of("rukzak_object", str_img_menu, str_icons_menu, str_icon_mouse, str_objects_on_loc, -1.5, 0, 0)

	str_icons_menu=[str_path_icon+"fork.jpg",str_path_icon+"shtopor.jpg",str_path_icon+"scuisors.jpg",str_path_icon+"water.jpg",str_path_icon+"fonarik.jpg","","",""]
	str_icon_mouse=[str_path_m_icon+"fork_big.jpg",str_path_m_icon+"shtopor_big.jpg",str_path_m_icon+"scuisor_big.jpg",str_path_m_icon+"water_big.jpg",str_path_m_icon+"fonarik_big.jpg","","",""]
	str_objects_on_loc=["fork","shtopor","scuisor","bottle","light","","",""]
	quest_game.add_of("jashik_object", str_img_menu, str_icons_menu, str_icon_mouse, str_objects_on_loc, -1.5,0,0)

	str_icons_menu=[str_path_icon+"key.jpg","","","","","","",""]
	str_icon_mouse=[str_path_m_icon+"key_big.jpg","","","","","","",""]
	str_objects_on_loc=["vkl_2_key","","","","","","",""]
	quest_game.add_of("door_object", str_img_menu, str_icons_menu, str_icon_mouse, str_objects_on_loc, 0,0,0)

	str_icons_menu=[str_path_icon+"shlang.jpg",str_path_icon+"rope.jpg",str_path_icon+"chulki.jpg",str_path_icon+"polotence.jpg",str_path_icon+"shvabra.jpg","","",""]
	str_icon_mouse=[str_path_m_icon+"shlang_big.jpg",str_path_m_icon+"rope_big.jpg",str_path_m_icon+"chulki_big.jpg",str_path_m_icon+"platok.jpg",str_path_m_icon+"shvabra_big.jpg","","",""]
	str_objects_on_loc=["vkl_1_shlang","rope","chulki","platok","shvabra","","",""]
	quest_game.add_of("shkaf_object", str_img_menu, str_icons_menu, str_icon_mouse, str_objects_on_loc, 1.5, 30,-120)

	str_icons_menu=[str_path_icon+"izolenta.jpg",		str_path_icon+"ploskogubci.jpg",	str_path_icon+"provod.jpg",		str_path_icon+"knife.jpg",		str_path_icon+"headphones.jpg","","",""]
	str_icon_mouse=[str_path_m_icon+"izolenta_big.jpg",	str_path_m_icon+"ploskogubci_big.jpg",	str_path_m_icon+"provod_big.jpg",	str_path_m_icon+"knife_big.jpg",	str_path_m_icon+"headphones_big.jpg","","",""]
	str_objects_on_loc=["izolenta",				"shipcy",				"provod",				"knife",				"phones","","",""]
	quest_game.add_of("shitok_object", str_img_menu, str_icons_menu, str_icon_mouse, str_objects_on_loc, 1.5,0,0)

	quest_game.set_collect_sound("stekl_object","data\\sound\\quest\\q_jashik.ogg")
	quest_game.set_collect_sound("rukzak_object","data\\sound\\quest\\q_chemodan.ogg")
	quest_game.set_collect_sound("jashik_object","data\\sound\\quest\\q_jashik_stola.ogg")
	quest_game.set_collect_sound("door_object","data\\sound\\quest\\q_bum.ogg")

	quest_game.set_state_of("rukzak_object", 2)
	quest_game.set_state_of("stekl_object", 2)
	quest_game.set_state_of("jashik_object", 0)
	quest_game.set_state_of("door_object", 0)
	quest_game.set_state_of("shkaf_object", 0)
	quest_game.set_state_of("shitok_object", 0)

	if api_game.get_tutorial_phase() == 0:
		api_game.enable_visibility(0,"tutText0", 1)
		api_game.enable_visibility(0,"tutArrow0", 1)
		api_game.enable_visibility(0,"tutPlate0", 1)
		api_game.loop_anim(0,"tutArrow0","tutorial",2.0,0) 
		api_game.enable_visibility(0,"tutText1", 0)
		api_game.enable_visibility(0,"tutArrow1", 0)
		api_game.enable_visibility(0,"tutPlate1", 0)
	else:
		api_game.enable_visibility(0,"tutText0", 0)
		api_game.enable_visibility(0,"tutPlate0", 0)
		api_game.enable_visibility(0,"tutArrow0", 0)
		api_game.enable_visibility(0,"tutText1", 0)
		api_game.enable_visibility(0,"tutArrow1",0) 
		api_game.enable_visibility(0,"tutPlate1",0)
#	api_game.set_goal("goal_1_1")

def on_mouse_down_of(object_name, p_object, state):
	if object_name == "stekl_object" and state == 3:
		quest_game.add_oc("stekl_object", "data\\img\\lev\\loc_1_1\\objects\\glow_5.gif", "vkl_1")
	elif object_name == "rukzak_object" and state == 3:
		quest_game.set_state_of("jashik_object", 2)
		quest_game.set_state_of("door_object", 2)
		api_game.set_goal("goal_1_3")
	elif object_name == "jashik_object" and state == 3:
		quest_game.add_oc("jashik_object", "data\\img\\lev\\loc_1_1\\objects\\glow_6.gif", "vkl_2")
		api_game.set_goal("goal_1_4")
	elif object_name == "door_object" and state == 3:
		api_game.play_anim(-1,"","quake",0.5,0) 
		api_game.play_anim(0,"back_2","quest_anim",0.2,1) 
		api_game.play_anim(0,"globe","quest_anim",0.2, 1)
		quest_game.show_object("globe_falled","quest_anim",0.2,0,0)
		quest_game.show_object("shkaf_object","quest_anim",0.2,0,0)
		quest_game.set_state_of("shkaf_object", 2)
		api_game.set_goal("goal_1_5")
	elif object_name == "shkaf_object" and state == 3:
		api_game.play_anim(0,"back_2","quest_anim",0.2, 0)
		api_game.play_anim(0,"shkaf_object","quest_anim", 0.1, 1) 
		quest_game.set_state_of("shitok_object", 2)
		api_game.set_goal("goal_1_6")
	elif object_name == "shitok_object" and state == 3:
		api_game.attach_game("data\\menu\\levels\\loc_1_2")
		api_game.activate_game("loc_1_2",1)
		api_game.set_goal("tut_1_2")
	elif object_name == "rukzak_object" and state == 2 and api_game.get_tutorial_phase() == 0:
		api_game.enable_visibility(0,"tutText0", 0)
		api_game.enable_visibility(0,"tutArrow0", 0)
		api_game.enable_visibility(0,"tutPlate0", 0)
		api_game.loop_anim(0,"tutArrow1","tutorial",2.0,1) 
		api_game.enable_visibility(0,"tutText1", 1)
		api_game.enable_visibility(0,"tutArrow1", 1)
		api_game.enable_visibility(0,"tutPlate1", 1)
		api_game.set_tutorial_phase(1)
		 
def on_mouse_down_oc(object_name, p_object):
	if object_name == "door_object":
		api_game.play_sound("data\\sound\\quest\\q_open_door.ogg",0)
		api_game.play_anim(0,"door_object","quest_anim", 0.1, 1) 
		quest_game.remove_oc("door_object")
	elif object_name == "stekl_object" or object_name == "jashik_object":
		api_game.play_sound("data\\sound\\quest\\q_jashik.ogg",0)

def on_event(object_name, p_object, event):
	if event == 22 and object_name == "door_object":
		api_game.game_win()
	elif event == 11000 and object_name == "loc_1_2":
		api_game.play_sound("data\\sound\\quest\\q_energy_up.ogg",0)
		api_game.play_anim(p_object,"1_arrow","energy_arrow", 2, 0)
		api_game.play_anim(p_object,"2_arrow","energy_arrow", 2, 0)
	elif event == 11004 and object_name == "loc_1_2":
		api_game.game_win()
	elif event == 22 and object_name == "1_arrow":
		quest_game.add_oc("door_object", "data\\img\\lev\\loc_1_1\\objects\\glow_2.gif", "")
		api_game.activate_game("loc_1_2",0)

def on_take_object(object_name):
	if object_name == "vkl_1_gilet":
		p_stekl = api_game.get_child(0,"stekl_object")
		api_game.play_anim(p_stekl,"stekl_object1","quest_anim",0.5,0)
	if object_name == "vkl_1_shlang":
		p_stekl = api_game.get_child(0,"stekl_object")
		api_game.play_anim(p_stekl,"stekl_object2","quest_anim",0.5,0)
	elif object_name == "compas":
		if api_game.get_tutorial_phase() == 1:
			api_game.enable_visibility(0,"tutText0", 0)
			api_game.enable_visibility(0,"tutArrow0", 0)
			api_game.enable_visibility(0,"tutPlate0", 0)
			api_game.enable_visibility(0,"tutText1", 0)
			api_game.enable_visibility(0,"tutArrow1",0)
			api_game.enable_visibility(0,"tutPlate1",0)
			api_game.set_goal("goal_1_1")
			api_game.set_tutorial_phase(2)
		elif api_game.get_tutorial_phase() == 0:
			api_game.enable_visibility(0,"tutText0", 0)
			api_game.enable_visibility(0,"tutArrow0", 0)
			api_game.enable_visibility(0,"tutPlate0", 0)
			api_game.enable_visibility(0,"tutText1", 0)
			api_game.enable_visibility(0,"tutArrow1",0)
			api_game.enable_visibility(0,"tutPlate1",0)
			api_game.set_tutorial_phase(2)

def on_drop_object(object_name):
	if object_name == "vkl_1_gilet":
		p_stekl = api_game.get_child(0,"stekl_object")
		api_game.play_anim(p_stekl,"stekl_object1","quest_anim",0.5,1)
	if object_name == "vkl_1_shlang":
		p_stekl = api_game.get_child(0,"stekl_object")
		api_game.play_anim(p_stekl,"stekl_object2","quest_anim",0.5,1)

