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)

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

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

	api_game.load_stream("data\\sound\\quest\\q_gorenie.ogg",0)
	api_game.set_local_vol("data\\sound\\quest\\q_gorenie.ogg",0.4)

	api_game.enable_update(0,"vkl_1", 0)
	api_game.enable_visibility(0,"vkl_1", 0)
	api_game.enable_visibility(0,"fakel_light", 0)
	api_game.enable_visibility(0,"fire_1", 0)
	api_game.enable_visibility(0,"fire_2", 0)
	api_game.enable_visibility(0,"fire_3", 0)
	api_game.enable_visibility(0,"fire_4", 0)
	api_game.enable_visibility(0,"fire_5", 0)
	api_game.enable_visibility(0,"Lampada_1", 0)
	api_game.enable_visibility(0,"Lampada_2", 0)
	api_game.enable_visibility(0,"Lampada_3", 0)
	api_game.enable_visibility(0,"Lampada_4", 0)
	api_game.enable_visibility(0,"all_light", 0)
	api_game.enable_visibility(0,"item_13", 0)
	api_game.enable_visibility(0,"opened_door", 0)
	api_game.enable_visibility(0,"kamni", 0)
	api_game.enable_visibility(0,"waterfall", 0)
	api_game.enable_visibility(0,"water_fall", 0)
	api_game.enable_visibility(0,"shadow", 0)
	api_game.enable_visibility(0,"mosaik_filled", 0)
	api_game.enable_visibility(0,"end_karta", 0)
	api_game.enable_visibility(0,"end_sprite", 0)
	api_game.enable_visibility(0,"MozaikaFull", 0)
	api_game.enable_visibility(0,"back_mini", 0)
	api_game.enable_visibility(0,"open_mini", 0)
	api_game.enable_visibility(0,"map_mini", 0)
	api_game.enable_visibility(0,"karta_glow", 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)
	api_game.enable_visibility(p_part,"fire2_flame",0)
	api_game.enable_visibility(p_part,"fire2_light",0)
	api_game.enable_visibility(p_part,"fire3_flame",0)
	api_game.enable_visibility(p_part,"fire3_light",0)
	api_game.enable_visibility(p_part,"fire4_flame",0)
	api_game.enable_visibility(p_part,"fire4_light",0)
	api_game.enable_visibility(p_part,"fire5_flame",0)
	api_game.enable_visibility(p_part,"fire5_light",0)

	str_icons_menu=[str_path_icon+"miniicon_15.jpg",str_path_icon+"miniicon_14.jpg",str_path_icon+"miniicon_7.jpg",str_path_icon+"miniicon_8.jpg",str_path_icon+"miniicon_6.jpg","","",""]
	str_icon_mouse=[str_path_m_icon+"bigicon_10.jpg",str_path_m_icon+"bigicon_9.jpg",str_path_m_icon+"bigicon_2.jpg",str_path_m_icon+"bigicon_3.jpg",str_path_m_icon+"bigicon_1.jpg","","",""]
	str_objects_on_loc=["item_11","item_10","item_9","item_8","item_12","","",""]
	quest_game.add_of("fakel_object", str_img_menu, str_icons_menu, str_icon_mouse, str_objects_on_loc, -1.5,0,0)

	str_icons_menu=[str_path_icon+"miniicon_11.jpg",str_path_icon+"miniicon_10.jpg",str_path_icon+"miniicon_10.jpg",str_path_icon+"miniicon_9.jpg",str_path_icon+"miniicon_9.jpg","","",""]
	str_icon_mouse=[str_path_m_icon+"bigicon_6.jpg",str_path_m_icon+"bigicon_5.jpg",str_path_m_icon+"bigicon_5.jpg",str_path_m_icon+"bigicon_4.jpg",str_path_m_icon+"bigicon_4.jpg","","",""]
	str_objects_on_loc=["item_24","item_23","item_25","item_26","item_27","","",""]
	quest_game.add_of("waterfall_object", str_img_menu, str_icons_menu, str_icon_mouse, str_objects_on_loc, -1.5,0,0)

	str_icons_menu=[str_path_icon+"miniicon_13.jpg",str_path_icon+"miniicon_12.jpg",str_path_icon+"miniicon_12.jpg",str_path_icon+"miniicon_12.jpg",str_path_icon+"miniicon_12.jpg","","",""]
	str_icon_mouse=[str_path_m_icon+"bigicon_8.jpg",str_path_m_icon+"bigicon_7.jpg",str_path_m_icon+"bigicon_7.jpg",str_path_m_icon+"bigicon_7.jpg",str_path_m_icon+"bigicon_7.jpg","","",""]
	str_objects_on_loc=["item_13","item_14","item_15","item_16","item_17","","",""]
	quest_game.add_of("lampada_object", str_img_menu, str_icons_menu, str_icon_mouse, str_objects_on_loc, -1.5,0,0)

	str_icons_menu=[str_path_icon+"miniicon_1.jpg",str_path_icon+"miniicon_2.jpg",str_path_icon+"miniicon_3.jpg",str_path_icon+"miniicon_4.jpg",str_path_icon+"miniicon_5.jpg","","",""]
	str_icon_mouse=[str_path_m_icon+"bigicon_19.jpg",str_path_m_icon+"bigicon_20.jpg",str_path_m_icon+"bigicon_21.jpg",str_path_m_icon+"bigicon_22.gif",str_path_m_icon+"bigicon_23.jpg","","",""]
	str_objects_on_loc=["item_18","item_19","item_20","item_21","item_22","","",""]
	quest_game.add_of("mosaik_areal", str_img_menu, str_icons_menu, str_icon_mouse, str_objects_on_loc, -1.5,0,0)

	str_icons_menu=[str_path_icon+"miniicon_17.jpg",str_path_icon+"miniicon_18.jpg",str_path_icon+"miniicon_16.jpg",str_path_icon+"miniicon_19.jpg",str_path_icon+"miniicon_20.jpg",str_path_icon+"miniicon_21.jpg",str_path_icon+"miniicon_22.jpg",str_path_icon+"miniicon_23.jpg"]
	str_icon_mouse=[str_path_m_icon+"bigicon_11.jpg",str_path_m_icon+"bigicon_12.jpg",str_path_m_icon+"bigicon_13.jpg",str_path_m_icon+"bigicon_14.jpg",str_path_m_icon+"bigicon_15.jpg",str_path_m_icon+"bigicon_16.jpg",str_path_m_icon+"bigicon_17.jpg",str_path_m_icon+"bigicon_18.jpg"]
	str_objects_on_loc=["item_6","item_5","item_7","item_4","item_key","item_3","item_1","item_2"]
	quest_game.add_of("dver", str_img_menu, str_icons_menu, str_icon_mouse, str_objects_on_loc, -1.5,0,0)

	quest_game.set_collect_sound("dver","data\\sound\\quest\\q_door_stone.ogg")

	quest_game.set_state_of("fakel_object", 2)

	api_game.set_goal("goal_5_1")

def on_mouse_down_of(object_name, p_object, state):
	if object_name == "fakel_object" and state == 3:
#		quest_game.show_object("fire_5","quest_anim",0.5,0,0)
		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)
		quest_game.show_object("fakel_light","quest_anim",0.5,0,0)
		quest_game.show_object("all_light","quest_anim",0.5,0,0)
		api_game.play_anim(0,"shadow","quest_anim",0.5,0)
		quest_game.set_state_of("waterfall_object",2)
		api_game.play_sound("data\\sound\\quest\\q_gorenie.ogg",1)
	elif object_name == "waterfall_object" and state == 3:
		quest_game.show_object("waterfall","quest_anim",0.5,0,0)
		quest_game.show_object("water_fall","quest_anim",0.5,2,0)
		quest_game.show_object("item_13","quest_anim",0.5,0,0)
		quest_game.show_object("kamni","quest_anim",0.5,0,0)
		api_game.set_local_vol("data\\sound\\quest\\q_vodopad.ogg",0.3)
		quest_game.set_state_of("lampada_object",2)
		api_game.set_goal("goal_5_3")
	elif object_name == "lampada_object" and state == 3:
#		quest_game.show_object("fire_1","quest_anim",0.5,0,0)
#		quest_game.show_object("fire_2","quest_anim",0.5,0,0)
#		quest_game.show_object("fire_3","quest_anim",0.5,0,0)
#		quest_game.show_object("fire_4","quest_anim",0.5,0,0)
		p_part = api_game.get_child(0,"part_layer0")
		api_game.enable_visibility(p_part,"fire2_flame",1)
		api_game.enable_visibility(p_part,"fire2_light",1)
		api_game.enable_visibility(p_part,"fire3_flame",1)
		api_game.enable_visibility(p_part,"fire3_light",1)
		api_game.enable_visibility(p_part,"fire4_flame",1)
		api_game.enable_visibility(p_part,"fire4_light",1)
		api_game.enable_visibility(p_part,"fire5_flame",1)
		api_game.enable_visibility(p_part,"fire5_light",1)
		quest_game.show_object("Lampada_1","quest_anim",0.5,0,0)
		quest_game.show_object("Lampada_2","quest_anim",0.5,0,0)
		quest_game.show_object("Lampada_3","quest_anim",0.5,0,0)
		quest_game.show_object("Lampada_4","quest_anim",0.5,0,0)		
		quest_game.set_state_of("mosaik_areal", 2)
		api_game.set_local_vol("data\\sound\\quest\\q_gorenie.ogg",0.3)
		api_game.set_goal("goal_5_4")
	elif object_name == "mosaik_areal" and state == 3:
		api_game.attach_game("data\\menu\\levels\\loc_5_2")
		api_game.activate_game("loc_5_2",1)
		api_game.set_goal("tut_5_2")
	elif object_name == "dver" and state == 3:
#		quest_game.add_oc("dver", "data\\img\\lev\\loc_5_1\\objects\\object1_glow.gif", "")
		api_game.play_anim(0,"opened_door","quest_anim", 1.0, 0) 
		 
def on_mouse_down_oc(object_name, p_object):
	if object_name == "dver":
		api_game.play_anim(0,"opened_door","quest_anim", 0.1, 0) 
		quest_game.remove_oc("dver")
	elif object_name == "map_mini":
		quest_game.remove_oc("map_mini")
		api_game.play_anim(0,"map_mini","quest_anim", 0.5, 1) 
		api_game.play_anim(0,"end_sprite","quest_anim", 0.5, 0) 

def on_event(object_name, p_object, event):
	if event == 11000 and object_name == "loc_5_2":
		api_game.set_goal("goal_5_5")
		quest_game.add_oc("secret", "data\\img\\lev\\loc_5_1\\mini\\glow.gif", "vkl_1")
		api_game.activate_game("loc_5_2",0)
		quest_game.set_state_of("dver", 2)
		api_game.play_anim(0,"mosaik_filled","quest_anim", 0.5, 0) 
		api_game.play_sound("data\\sound\\quest\\q_padam.ogg",0)
	elif event == 11004 and object_name == "loc_5_2":
		api_game.fade_off(1,object_name)
		api_game.play_anim(0,"MozaikaFull","quest_anim", 0.5, 0) 
	elif event == 11000 and object_name == "loc_5_3":
		api_game.activate_game("loc_5_3",0)
		api_game.enable_visibility(0,"end_karta", 1)
		quest_game.add_oc("end_karta", "data\\img\\lev\\loc_5_1\\objects\\karta_glow.gif", "")
	elif event == 11004 and object_name == "loc_5_3":
		api_game.fade_off(1,object_name)
		api_game.play_anim(0,"back_mini","quest_anim", 0.5, 0) 
		api_game.play_anim(0,"map_mini","quest_anim", 0.5, 0) 
		api_game.play_anim(0,"open_mini","quest_anim", 0.5, 0) 		
#		quest_game.add_oc("map_mini","data\\img\\lev\\loc_5_3\\karta_glow.gif", "")
		quest_game.add_object_check(0,"map_mini","karta_glow")
		api_game.set_goal("goal_5_6")
	elif event == 11000 and object_name == "loc_5_4":
		api_game.activate_game("loc_5_4",0)
		api_game.play_anim(0,"back_mini","quest_anim", 0.5, 1) 
		api_game.play_anim(0,"open_mini","quest_anim", 0.5, 1) 
#		api_game.play_anim(0,"end_sprite","quest_anim", 0.5, 1) 
	elif event == 11004 and object_name == "loc_5_4":
		api_game.game_win()

def on_mouse_down_simple(object_name,p_object):
	if object_name == "map_mini":
		api_game.play_anim(0,"map_mini","quest_anim", 0.5, 1) 
		api_game.play_anim(0,"karta_glow","quest_anim", 0.5, 1) 
		api_game.play_anim(0,"end_sprite","quest_anim", 0.5, 0) 

def on_stop_anim(object_name, anim_name, p_object, i_track):
	if object_name == "opened_door":
		api_game.attach_game("data\\menu\\levels\\loc_5_3")
		api_game.activate_game("loc_5_3",1)
		api_game.set_goal("tut_5_31")
	elif object_name == "end_sprite":
		api_game.fade_on(1,"loc_5_4_on")
	elif object_name == "fakel_light":
		api_game.set_goal("goal_5_2")

def on_fade_event(i_state, str_def):
	if str_def == "loc_5_4" and i_state == 0:
		api_game.game_win()
	elif str_def == "loc_5_4_on" and i_state == 1:
		api_game.attach_game("data\\menu\\levels\\loc_5_4")
		api_game.activate_game("loc_5_4",1)
		api_game.set_goal("tut_5_4")
		