require( "scripts/common/simple_object.lua" );

local	indicator_pos_x = 70;
local	indicator_pos_y = 0;



ask_to_play = simple_object:new{
	-- ANCHOR
	anchor_x=0,
	anchor_y=0,
	offset_x=0,
	offset_y=0,
	
	texture="anim/objects/fall_floor/fall_floor",
	animation_script="anim/objects/default_animation_script.lua",
	glow_texture="anim/objects/fall_floor/fall_floor_glow",
	glow_animation_script="anim/objects/default_glow_animation_script.lua",
	
	indicator_ui_x=indicator_pos_x,
	indicator_ui_y=indicator_pos_y,
	dad_ui_x=indicator_pos_x-35,
	dad_ui_y=indicator_pos_y,
	mom_ui_x=indicator_pos_x+35,
	mom_ui_y=indicator_pos_y,
		
	toy_x = "20",
	toy_y = "-100",
	toy_layer = "1",
	
	complex_object = true;
	
	set_click_enable = false,
	show_cleaning_particle = false;
}

function ask_to_play:new(o)
	o = o or {}   -- create object if user does not provide one
	setmetatable(o, self)
	self.__index = self
	return o
end
	
function ask_to_play:messing_update()
	if (GetCurrentTime() - self.new_state_start_time) > self.messing_state_time then
		PlayCharacterAnimation(self.current_action_character, self.character_dirty_animation);
		ShowCharacterStuff(self.current_action_character, "toy", self.toy_x, self.toy_y, self.toy_layer);
		FlipAnimation(self.current_action_character, self.flipped_animation);
		--FinishCharacterTask(self.current_action_character);
		ChangeObjectState(self.object_name, self.dirty_state_name);
	end
end	

function ask_to_play:cleaning_update()
	if (GetCurrentTime() - self.new_state_start_time) > self.cleaning_state_time then
		if self.parent_chosen == "dad" then
			PlaySound("task_complete_father", false);
		else
			PlaySound("task_complete_mother", false);
		end
		PlayCharacterAnimation(self.parent_chosen, self.character_clean_animation);
		FlipAnimation(self.parent_chosen, self.flipped_animation);
		--[[
		if self.stress_inc_enabled and not self.no_stress_power then
			AddCharacterStress(self.parent_chosen, self.stress_inc);
		end
		--]]
		if self.no_stress_power then
			HideNoStressIcon(self.object_name);
		end
		self.no_stress_power = false;
		FinishCharacterTask(self.parent_chosen);
		SetCharacterState(self.parent_chosen, "leaving_child_to_play");
		
		HideCharacterStuff(self.current_action_character);
		FinishCharacterTask(self.current_action_character);
		
		PlayObjectAnimation(self.object_name, self.object_clean_animation);
		ChangeObjectState(self.object_name, self.clean_state_name);
		
		self.cleaning_state_time = self.previous_cleaning_state_time;
	end
end