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-indian.ogg"

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

	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.load_stream("data\\sound\\quest\\q_night_les.ogg",0)
	api_game.set_local_vol("data\\sound\\quest\\q_night_les.ogg",0.4)
	api_game.play_sound("data\\sound\\quest\\q_night_les.ogg",1)

	api_game.enable_visibility(0,"2", 0)
	api_game.enable_visibility(0,"1", 0)
#	api_game.enable_visibility(0,"3", 0)
	api_game.enable_visibility(0,"4", 0)
#	api_game.enable_visibility(0,"5", 0)
	api_game.enable_visibility(0,"item5_4", 0)

	p_part = api_game.get_child(0,"part_layer0")
	api_game.enable_visibility(p_part,"fire1_flame",0)
	api_game.enable_visibility(p_part,"fire1_light",0)

	str_icons_menu=[str_path_icon+"item1_1.gif",str_path_icon+"item1_2.gif",str_path_icon+"item1_3.gif",str_path_icon+"item1_4.gif",str_path_icon+"item1_5.gif","","",""]
	str_icon_mouse=[str_path_m_icon+"item1_1m.gif",str_path_m_icon+"item1_2m.gif",str_path_m_icon+"item1_3m.gif",str_path_m_icon+"item1_4m.gif",str_path_m_icon+"item1_5m.gif","","",""]
	str_objects_on_loc=["item1_1","item1_2","item1_3","item1_4","item1_5","","",""]
	quest_game.add_of("first_object", str_img_menu, str_icons_menu, str_icon_mouse, str_objects_on_loc, 3.14,0,0)

	str_icons_menu=[str_path_icon+"item5_1.gif",str_path_icon+"item5_2.gif",str_path_icon+"item5_3.gif",str_path_icon+"item5_4.gif",str_path_icon+"item5_5.gif","","",""]
	str_icon_mouse=[str_path_m_icon+"item5_1m.gif",str_path_m_icon+"item5_2m.gif",str_path_m_icon+"item5_3m.gif",str_path_m_icon+"item5_4m.gif",str_path_m_icon+"item5_5m.gif","","",""]
	str_objects_on_loc=["item5_1","item5_2","item5_3","item5_4","item5_5","","",""]
	quest_game.add_of("fifth_object", str_img_menu, str_icons_menu, str_icon_mouse, str_objects_on_loc, 3.14,0,0)

	str_icons_menu=[str_path_icon+"item3_1.gif",str_path_icon+"item3_2.gif",str_path_icon+"item3_3.gif",str_path_icon+"item3_4.gif",str_path_icon+"item3_5.gif","","",""]
	str_icon_mouse=[str_path_m_icon+"item3_1m.gif",str_path_m_icon+"item3_2m.gif",str_path_m_icon+"item3_3m.gif",str_path_m_icon+"item3_4m.gif",str_path_m_icon+"item3_5m.gif","","",""]
	str_objects_on_loc=["item3_1","item3_2","item3_3","item3_4","item3_5","","",""]
	quest_game.add_of("three_object", str_img_menu, str_icons_menu, str_icon_mouse, str_objects_on_loc, 3.5,20,-40)

	str_icons_menu=[str_path_icon+"item2_1.gif",str_path_icon+"item2_2.gif",str_path_icon+"item2_3.gif",str_path_icon+"item2_4.gif",str_path_icon+"item2_5.gif","","",""]
	str_icon_mouse=[str_path_m_icon+"item2_1m.gif",str_path_m_icon+"item2_2m.gif",str_path_m_icon+"item2_3m.gif",str_path_m_icon+"item2_4m.gif",str_path_m_icon+"item2_5m.gif","","",""]
	str_objects_on_loc=["item2_1","item2_2","item2_3","item2_4","item2_5","","",""]
	quest_game.add_of("second_object", str_img_menu, str_icons_menu, str_icon_mouse, str_objects_on_loc, 3.14,0,0)

	str_icons_menu=[str_path_icon+"item4_1.gif",str_path_icon+"item4_2.gif",str_path_icon+"item4_3.gif",str_path_icon+"item4_4.gif",str_path_icon+"item4_5.gif","","",""]
	str_icon_mouse=[str_path_m_icon+"item4_1m.gif",str_path_m_icon+"item4_2m.gif",str_path_m_icon+"item4_3m.gif",str_path_m_icon+"item4_4m.gif",str_path_m_icon+"item4_5m.gif","","",""]
	str_objects_on_loc=["item4_1","item4_2","item4_3","item4_4","item4_5","item4_6","item4_7","item4_8"]
	quest_game.add_of("fourth_object", str_img_menu, str_icons_menu, str_icon_mouse, str_objects_on_loc, 1.41,0,0)

	quest_game.set_collect_sound("fourth_object","data\\sound\\quest\\q_explosion.ogg")

        api_game.attach_game("data\\menu\\levels\\loc_10_2")
	api_game.activate_game("loc_10_2",1)
	api_game.set_goal("tut_10_1")
	p_mini_game = api_game.get_child(0,"loc_10_2")
	api_game.enable_visibility(p_mini_game,"opened_door", 0)

	api_game.play_anim(0,"anim_1","q_kuvshin_loc_4", 6, 0)		
	api_game.play_anim(0,"anim_2","q_kuvshin_loc_4", 8, 1)		

def on_mouse_down_of(object_name, p_object, state):
	if object_name == "first_object" and state == 3:
		api_game.set_goal("goal_10_2")
		quest_game.set_state_of("three_object", 2)
		quest_game.set_state_of("fifth_object", 2)
		quest_game.show_object("2","quest_anim",0.3,0,0)
	elif object_name == "three_object" and state == 3:
		quest_game.show_object("item5_4","quest_anim",0.3,0,0)
	elif object_name == "fifth_object" and state == 3:
		api_game.set_goal("goal_10_4")
		quest_game.show_object("4","quest_anim",0.3,0,0)          
		quest_game.set_state_of("second_object", 2)
	elif object_name == "second_object" and state == 3:
		api_game.set_goal("goal_10_5")
		quest_game.show_object("1","quest_anim",0.3,0,0)						
		quest_game.set_state_of("fourth_object", 2)
		p_part = api_game.get_child(0,"part_layer0")
		api_game.enable_visibility(p_part,"fire1_flame",1)
		api_game.enable_visibility(p_part,"fire1_light",1)
	elif object_name == "fourth_object" and state == 3:		
		api_game.play_anim(0,"fourth_object","quest_anim",0.5,1)
		 
def on_event(object_name, p_object, event):
	if event == 11000 and object_name == "loc_10_2":
		api_game.play_anim(p_object,"opened_door","quest_anim",0.5,0)
		api_game.set_goal("goal_10_1")

def on_stop_anim(object_name, anim_name, p_object, i_track):	
	if object_name == "opened_door":
		api_game.activate_game("loc_10_2",0)
		quest_game.set_state_of("first_object", 2)
	elif object_name == "fourth_object":
		api_game.game_win()
