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

local	indicator_pos_x = -5;
local	indicator_pos_y = -20;

fight_down_spot = simple_object:new{
	character_cleaning_animation = "doing_stuff_up",
	parent_state_action = "normal",
	anchor_x=83,
	anchor_y=80,
	offset_x=-19,
	offset_y=-48,
	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,
	
	cleaning_state_time = 3000;
	
	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,
		
	set_click_enable = false;
	show_cleaning_particle = false;
	
	texture="anim/objects/fight_down_spot/fight_down_spot",
	--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",
	
	mask = false;
	
	fight_up_spot_name = "";
	
	flipped_animation = true;
	
	complex_object = true;
	
	is_a_mess = false,
}

function fight_down_spot:new(o)
	o = o or {}   -- create object if user does not provide one
	setmetatable(o, self)
	self.__index = self
	return o
end

function fight_down_spot:dirty_init()
	PlayObjectAnimation(self.object_name, self.object_dirty_animation);	
	--PlayGlowAnimation(self.object_name, "dirty");
	
	PlayCharacterAnimation(self.current_action_character, "fighting_down");
	FlipAnimation(self.current_action_character, self.flipped_animation);
	
	--[[
	if not self.parent_is_coming then
		IncludeObjectMouseHandler(self.object_name);
	end
	--]]
	
	self.previous_state = GetObjectState(self.object_name);
	
	if self.check_teamwork then
		ShowTeamWorkIcon(self.object_name, ShouldShowCharacterTeamWork(self.teamworktask_name));
		--ShowTeamWorkIcon(self.object_name, "mom", ShouldShowCharacterTeamWork("mom", self.teamworktask_name));
	end
end

function fight_down_spot:finished_init()	
	RemoveCharacterOnObject(self.current_action_character);
	FinishCharacterTask(self.current_action_character);
		
	PlayGlowAnimation(self.object_name, "clean");
	PlayObjectAnimation(self.object_name, self.object_clean_animation);
	ChangeObjectState(self.object_name, self.clean_state_name);	
end

function fight_down_spot:readytodiscipline_init()
	PlayCharacterAnimation(self.current_action_character, "idle");
	PlayObjectAnimation(self.object_name, self.object_clean_animation);
end

function fight_down_spot:clean_youngchild_action(character_name)
	self.current_action_character = character_name;
	if GetObjectState(self.fight_up_spot_name) == "childon" then
		ChangeObjectState(self.object_name, "dirty");
		ChangeObjectState(self.fight_up_spot_name, "dirty");
		PlaySound("fight", false);
	else
		ChangeObjectState(self.object_name, "childon");
	end
	PutCharacterOnObject(self.current_action_character, self.fight_up_spot_name);
end

function fight_down_spot:clean_toddler_action(character_name)
	self.current_action_character = character_name;
	if GetObjectState(self.fight_up_spot_name) == "childon" then
		ChangeObjectState(self.object_name, "dirty");
		ChangeObjectState(self.fight_up_spot_name, "dirty");
		PlaySound("fight", false);
	else
		ChangeObjectState(self.object_name, "childon");
	end
	PutCharacterOnObject(self.current_action_character, self.fight_up_spot_name);
end

function fight_down_spot:clean_schoolaged_action(character_name)
	self.current_action_character = character_name;
	if GetObjectState(self.fight_up_spot_name) == "childon" then
		ChangeObjectState(self.object_name, "dirty");
		ChangeObjectState(self.fight_up_spot_name, "dirty");
		PlaySound("fight", false);
	else
		ChangeObjectState(self.object_name, "childon");
	end
	PutCharacterOnObject(self.current_action_character, self.fight_up_spot_name);
end
