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

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

	api_game.load_stream("data\\sound\\quest\\q_vodopad.ogg",0)
	api_game.set_local_vol("data\\sound\\quest\\q_vodopad.ogg",0.3)

	api_game.enable_visibility(0,"cep1", 0)
	api_game.enable_visibility(0,"poys1", 0)
	api_game.enable_visibility(0,"water", 0)
	api_game.enable_visibility(0,"water_ruchei", 0)
	api_game.enable_visibility(0,"box2", 0)
	api_game.enable_visibility(0,"shalash1", 0)
	api_game.enable_visibility(0,"parrot", 0)

	str_icons_menu=[str_path_icon+"ikonka5.gif",str_path_icon+"ikonka9.gif",str_path_icon+"ikonka8.gif",str_path_icon+"ikonka20.gif",str_path_icon+"ikonka6.gif","","",""]
	str_icon_mouse=[str_path_m_icon+"kirka1.gif",str_path_m_icon+"flyga1.gif",str_path_m_icon+"dinamit1.gif",str_path_m_icon+"star1.gif",str_path_m_icon+"sell1.gif","","",""]
	str_objects_on_loc=["kirka","flyga","dinamit","star","shell","","",""]
	quest_game.add_of("stone", str_img_menu, str_icons_menu, str_icon_mouse, str_objects_on_loc, -1.5,0,0)

	str_icons_menu=[str_path_icon+"ikonka21.gif",str_path_icon+"ikonka22.gif",str_path_icon+"ikonka25.gif",str_path_icon+"ikonka10.gif",str_path_icon+"ikonka12.gif","","",""]
	str_icon_mouse=[str_path_m_icon+"remen1.gif",str_path_m_icon+"shilo1.gif",str_path_m_icon+"axe1.gif",str_path_m_icon+"molot1.gif",str_path_m_icon+"nosh1.gif","","",""]
	str_objects_on_loc=["rem","shilo","axe","molot","noznic","","",""]
	quest_game.add_of("poys", str_img_menu, str_icons_menu, str_icon_mouse, str_objects_on_loc, 2.0,0,0)

	str_icons_menu=[str_path_icon+"ikonka11.gif",str_path_icon+"ikonka2.gif",str_path_icon+"ikonka19.gif",str_path_icon+"ikonka24.gif",str_path_icon+"ikonka23.gif","","",""]
	str_icon_mouse=[str_path_m_icon+"huck1.gif",str_path_m_icon+"verevka1.gif",str_path_m_icon+"perchatka1.gif",str_path_m_icon+"mask1.gif",str_path_m_icon+"tufli1.gif","","",""]
	str_objects_on_loc=["huck","verevka","perchatka","maska","tufli","","",""]
	quest_game.add_of("cep", str_img_menu, str_icons_menu, str_icon_mouse, str_objects_on_loc, -1.5,0,0)

	str_icons_menu=[str_path_icon+"ikonka15.gif",str_path_icon+"ikonka13.gif",str_path_icon+"ikonka14.gif",str_path_icon+"ikonka3.gif",str_path_icon+"ikonka18.gif","","",""]
	str_icon_mouse=[str_path_m_icon+"cocos1.gif",str_path_m_icon+"bus1.gif",str_path_m_icon+"korzina1.gif",str_path_m_icon+"shild1.gif",str_path_m_icon+"vilka1.gif","","",""]
	str_objects_on_loc=["kokos","busi","korzina","shild","vilka","","",""]
	quest_game.add_of("box1", str_img_menu, str_icons_menu, str_icon_mouse, str_objects_on_loc, -1.5,0,0)

	str_icons_menu=[str_path_icon+"ikonka1.gif",str_path_icon+"ikonka4.gif",str_path_icon+"ikonka17.gif",str_path_icon+"ikonka16.gif",str_path_icon+"ikonka7.gif","","",""]
	str_icon_mouse=[str_path_m_icon+"flute1.gif",str_path_m_icon+"maika1.gif",str_path_m_icon+"skrepka1.gif",str_path_m_icon+"prishepka1.gif",str_path_m_icon+"trost1.gif","","",""]
	str_objects_on_loc=["fleita","maika","skrepka","prishepka","trost","","",""]
	quest_game.add_of("shalash", str_img_menu, str_icons_menu, str_icon_mouse, str_objects_on_loc, -1.5,0,0)

	quest_game.set_collect_sound("cep","data\\sound\\quest\\q_podshipnik.ogg")
	quest_game.set_collect_sound("box1","data\\sound\\quest\\q_parrot.ogg")
	quest_game.set_collect_sound("shalash","data\\sound\\quest\\q_molotok.ogg")

	quest_game.set_state_of("stone", 2)
	api_game.set_goal("goal_3_1")

def on_mouse_down_of(object_name, p_object, state):
	if object_name == "stone" and state == 3:	
		api_game.play_sound("data\\sound\\quest\\q_vodopad.ogg",1)
		api_game.play_anim(0,"stone","quest_anim",0.1,1)
		api_game.play_anim(0,"water","ruchei_anim",0.1,0)
		api_game.play_anim(0,"water_ruchei","ruchei_anim",0.1,0)
		quest_game.set_state_of("poys", 2)
		api_game.set_goal("goal_3_2")
	elif object_name == "poys" and state == 3:
		api_game.play_anim(0,"poys","quest_anim",0.1,1)
		api_game.play_anim(0,"poys1","quest_anim",0.1,0)
		quest_game.set_state_of("cep", 2)
		api_game.set_goal("goal_3_3")
	elif object_name == "cep" and state == 3:
		api_game.play_anim(0,"cep1","quest_anim",0.1,0)
		quest_game.set_state_of("box1", 2)
		api_game.set_goal("goal_3_4")
	elif object_name == "box1" and state == 3:
		api_game.play_anim(0,"box1","quest_anim",0.1,1) 
		api_game.play_anim(0,"box2","quest_anim",0.1,0)
		api_game.play_anim(0,"parrot","quest_anim", 0.5, 0)
		quest_game.add_object_puzzle(0,"parrot")
		quest_game.add_oc("parrot", "", "")
		api_game.set_goal("goal_3_5")
	elif object_name == "shalash" and state == 3:
		api_game.play_anim(0,"shalash","quest_anim",0.1,1) 
		api_game.play_anim(0,"shalash1","quest_anim",0.1,0)
		 
def on_mouse_down_oc(object_name, p_object):
	if object_name == "door_object":
		api_game.play_anim(0,"shalash1","quest_anim", 0.1,1) 
		quest_game.remove_oc("shalash1")
	elif object_name == "parrot":
		quest_game.remove_object_puzzle(0,"parrot")
		api_game.attach_game("data\\menu\\levels\\loc_3_2")
#		import game_2 as parrot_game
#		parrot_game.cnt_collect(20)
#		parrot_game.cnt_simult(5)
#		parrot_game.init_object("obj_1","morhun_anim_fly_forward", 1, 10, 0)
#		parrot_game.init_object("obj_2","morhun_anim_fly_forward", 1, 10, 0)
#		parrot_game.init_object("obj_3","morhun_anim_fly_forward", 1, 10, 0)
#		parrot_game.init_object("obj_4","morhun_anim_fly_backward", 1, 10, 0)
#		parrot_game.init_object("obj_5","morhun_anim_fly_backward", 1, 10, 0)
#		parrot_game.init_object("obj_6","morhun_anim_fly_backward", 1, 10, 0)
#		parrot_game.init_object("obstacle_1","", 0, 0, 1)
#		parrot_game.init_object("obstacle_2","", 0, 0, 1)
#		parrot_game.init_object("obstacle_3","", 0, 0, 1)
#		parrot_game.init_object("obstacle_4","", 0, 0, 1)
#		parrot_game.init_object("obstacle_5","", 0, 0, 1)
#		parrot_game.init_object("obstacle_6","", 0, 0, 1)
                api_game.activate_game("loc_3_2",1)
		api_game.set_goal("tut_3_2")

def on_event(object_name, p_object, event):
	if event == 11000 and object_name == "loc_3_2":
		api_game.activate_game("loc_3_2",0)
		quest_game.set_state_of("shalash", 2)
		api_game.set_goal("goal_3_6")
	elif event == 11004 and object_name == "loc_3_2":
               api_game.fade_off(1,"")
	       quest_game.remove_oc("parrot")
	       api_game.stop_anim(0,"parrot",1)
	       api_game.enable_update(0,"parrot", 0)
	       api_game.enable_visibility(0,"parrot", 0)

def on_stop_anim(object_name, anim_name, p_object, i_track):
	if object_name == "parrot":
		if i_track == 1:
			api_game.play_anim(0,"parrot","parrot_bow_back", 0.5, 0)
		elif i_track == 0:
			api_game.play_anim(0,"parrot","parrot_bow_back", 0.5, 1)
	elif object_name == "shalash1":
		api_game.game_win()