class 'l_11_Vitraj' (LevelEventHandler)

function l_11_Vitraj:__init(name)
	LevelEventHandler.__init(self, name)
	
	self.DragObj = {0, 0} -- номер кликнутого объекта
	self.DragObjCell = {0, 0} -- в какой ячейке находится выбранный объект
	self.DualDir = false -- при клике на предмет эта переменная становится true и проверяем в каком направлении тянем паззл - вертикально или горизонтально
	self.DragDeltaX = 0 -- разница между центром спрайта и координатой мышки, чтоб при клике на предмет, он подхватился в месте клика, а не по центру
	self.DragDeltaY = 0
	self.DirMove = nil -- can be 'vertical' or 'horizontal'
	self.DragZ = 170
	self.DeltaForMoveOtherPart = 136/3 -- дельта, при которой уже можно двигать другие части паззла на пустое место
	self.TimeMoveOtherParts = 0.2
	self.ToolFromInv = "10_piece_of_glass"
	self.TimeOpacity = 0.5
	self.ItemColorBlendMode = "0xFF3F3F3F" 
	self.ForMusicUpDateCanStop = 0
	self.x_prev, self.y_prev = 0, 0
	self.x_curr, self.y_curr = 0, 0
	
	-- sounds
	self.sound_put_tool = MakeSoundEntity('11_mg_put_tool')
	self.sound_move_items = MakeSoundEntity('11_mg_move_item')
	self.sound_final = MakeSoundEntity('11_mg_final')
	
--	self.sound_final:PlaySound(false)

	Object('Light'):SetVisible(false)
	play_field:IgnoreOnTestPoint('Light')
	
	self.Size_cell_x, self.Size_cell_y = 136, 136 
    self.x, self.y = Object('Puzzle_1_1'):GetScrX(), Object('Puzzle_1_1'):GetScrY()
	
	self.Cells = {}		
	self.Cells.CountRow = 4
	self.Cells.CountCol = 5
	for i = 1,self.Cells.CountCol do
           self.Cells[i] = {}
           for j = 1,self.Cells.CountRow do
                   self.Cells[i][j] = {} 
                   self.Cells[i][j].Col = i
                   self.Cells[i][j].Row = j
                   self.Cells[i][j].Pos = Vector(self.x + self.Size_cell_x * (i - 1), self.y + self.Size_cell_y * (j - 1))  
           end
	end
	
	self.Objects = {}		
	for i = 1,self.Cells.CountCol do
           self.Objects[i] = {}
           for j = 1,self.Cells.CountRow do
                   self.Objects[i][j] = {} 
                   self.Objects[i][j].Entity = Object('Puzzle_'..i..'_'..j)                   
                   self.Objects[i][j].Z = Object('Puzzle_'..i..'_'..j):GetZ()  

					GetCurrentLevel().ignore_on_highlight['Puzzle_'..i..'_'..j] = true
					GetCurrentLevel().custom_cursors['Puzzle_'..i..'_'..j] = 'CursorActive'
           end
	end
	
	-- save
	self.Save_state_mg = '11_Vitraj_SaveLoad'
    self.ArrayForSaveMG = {}
    -- cells
    self.ArrayForSaveMG.NumPuzzle = {} -- какие кусочки находятся в ячейках
    for i = 1, self.Cells.CountCol do
           self.ArrayForSaveMG.NumPuzzle[i] = {}        
    end         
	
	self.ArrayForSaveMG.NumPuzzle[1][1] = {5, 1}
	self.ArrayForSaveMG.NumPuzzle[2][1] = {2, 1}
	self.ArrayForSaveMG.NumPuzzle[3][1] = {3, 4}
	self.ArrayForSaveMG.NumPuzzle[4][1] = {3, 3}
	self.ArrayForSaveMG.NumPuzzle[5][1] = {1, 4}
	
	self.ArrayForSaveMG.NumPuzzle[1][2] = {5, 2}
	self.ArrayForSaveMG.NumPuzzle[2][2] = {4, 1}
	self.ArrayForSaveMG.NumPuzzle[3][2] = {5, 3}
	self.ArrayForSaveMG.NumPuzzle[4][2] = {5, 4}
	self.ArrayForSaveMG.NumPuzzle[5][2] = {4, 2}
	
	self.ArrayForSaveMG.NumPuzzle[1][3] = {1, 1}
	self.ArrayForSaveMG.NumPuzzle[2][3] = {2, 2}
	self.ArrayForSaveMG.NumPuzzle[3][3] = {2, 3}
	self.ArrayForSaveMG.NumPuzzle[4][3] = {1, 2}
	self.ArrayForSaveMG.NumPuzzle[5][3] = {2, 4}
	
	self.ArrayForSaveMG.NumPuzzle[1][4] = {4, 4}
	self.ArrayForSaveMG.NumPuzzle[2][4] = {3, 1}
	self.ArrayForSaveMG.NumPuzzle[3][4] = {1, 3}
	self.ArrayForSaveMG.NumPuzzle[4][4] = {3, 2}
	self.ArrayForSaveMG.NumPuzzle[5][4] = {4, 3}
	
	-- restore
	if HasGameState(self.Save_state_mg) then
		self.ArrayForSaveMG = Helpers.RestoreObjectFromGameState(self.Save_state_mg)  
	end
	
	-- set puzzles on their place
	for i = 1,self.Cells.CountCol do
           for j = 1,self.Cells.CountRow do
				self.Objects[self.ArrayForSaveMG.NumPuzzle[i][j][1]][self.ArrayForSaveMG.NumPuzzle[i][j][2]].Entity:SetXY(self.Cells[i][j].Pos.x, self.Cells[i][j].Pos.y)
           end
	end
	
	-- start tool
	Object('Puzzle_5_3'):SetOpacity(0)
	self:IgnoreObjectMG(true)      
	local function OnToolApply(event)
		self:GetPanelLuaObject():SetMode(EPanelMode.PM_MINIGAME) 
		Object('area_need_part'):SetVisible(false)
		if not event.save then
			self.sound_put_tool:PlaySound(false)
			Object('Puzzle_5_3'):ChangeOpacity(0, 1, self.TimeOpacity)			
			self.timer:Add(function()
						self:IgnoreObjectMG(false)
					  end,
					  self.TimeOpacity)			
		else
			Object('Puzzle_5_3'):SetOpacity(1)
			if not IsMiniGameCompleted('l_11_Vitraj') then
				self:IgnoreObjectMG(false)
			end
		end 			    
	end
	RegisterToolApplyInfo(self.ToolFromInv, 'area_need_part',  OnToolApply, 'BBT_MG_NEED_PART')
	
	if IsMiniGameCompleted('l_11_Vitraj') then
		for i = 1,self.Cells.CountCol do
				for j = 1,self.Cells.CountRow do
					self.Objects[i][j].Entity:GetAnimation():SetBlendMode(3)
					self.Objects[i][j].Entity:GetAnimation():SetColor(self.ItemColorBlendMode)
				end
		end
		CompleteMinigame(0.5)
	end
	
end

--------------------------------------------- extra functions
function l_11_Vitraj:IgnoreObjectMG(bool)
	if bool then
		for i = 1,self.Cells.CountCol do
           for j = 1,self.Cells.CountRow do
				play_field:IgnoreOnTestPoint('Puzzle_'..i..'_'..j)
			end
		end
	else
		for i = 1,self.Cells.CountCol do
           for j = 1,self.Cells.CountRow do
				play_field:DoNotIgnoreOnTestPoint('Puzzle_'..i..'_'..j)
			end
		end
	end
end

function l_11_Vitraj:IsCompleted()
		for i = 1, self.Cells.CountCol do
				for j = 1, self.Cells.CountRow do
						if not (self.ArrayForSaveMG.NumPuzzle[i][j][1] == i and self.ArrayForSaveMG.NumPuzzle[i][j][2] == j) then
								return false
						end
				end
		end
		
		return true
end

-- skip
function l_11_Vitraj:SkipMiniGame()
        if not IsMiniGameCompleted('l_11_Vitraj') then
			CompleteMinigame(2.5)
			self:IgnoreObjectMG(true)
			
			for i = 1, self.Cells.CountCol do
					for j = 1, self.Cells.CountRow do
						self.ArrayForSaveMG.NumPuzzle[i][j] = {i, j}   
					end
			end         
	
			Helpers.SaveObjectToGameState(self.Save_state_mg, self.ArrayForSaveMG)
			
			for i = 1,self.Cells.CountCol do
			    for j = 1,self.Cells.CountRow do
					self.Objects[i][j].Entity:ChangeOpacity(1, 0, self.TimeOpacity)
				end
			end
			
			self.timer:Add(function()
									for i = 1,self.Cells.CountCol do
										for j = 1,self.Cells.CountRow do
											self.Objects[i][j].Entity:SetXY(self.Cells[i][j].Pos.x, self.Cells[i][j].Pos.y)
											self.Objects[i][j].Entity:ChangeOpacity(0, 1, self.TimeOpacity)
										end
									end
							end,
							self.TimeOpacity + 0.1)
			self.timer:Add(function()
									for i = 1,self.Cells.CountCol do
										for j = 1,self.Cells.CountRow do
											self.Objects[i][j].Entity:GetAnimation():SetBlendMode(3)
											self.Objects[i][j].Entity:GetAnimation():SetColor(self.ItemColorBlendMode)
										end
									end
									self.sound_final:PlaySound(false)
							end,
							2*self.TimeOpacity + 0.2)
			
        end
end

--------------------------------------------- base functions

function l_11_Vitraj:OnUpdate(dt)
	if self.DragObj[1] ~= 0 then					
		-- смотрим, куда тянем объект - вниз или в сторону
		local mouse_x = GetMousePos().x - self.DragDeltaX
        local mouse_y = GetMousePos().y - self.DragDeltaY
        
        local x = self.Cells[self.DragObjCell[1]][self.DragObjCell[2]].Pos.x
        local y = self.Cells[self.DragObjCell[1]][self.DragObjCell[2]].Pos.y

        local delta_x = math.abs(mouse_x - x)
        local delta_y = math.abs(mouse_y - y)
        
		if self.DualDir then -- есть двойное направление и надо выяснить, в какую сторону тянем паззл
            self.DualDir = false

            if (delta_x > delta_y) and (delta_x > 10) then -- left/right 
               self.DirMove = 'horizontal'
            elseif (delta_x < delta_y) and (delta_y > 10) then -- up/down 
                self.DirMove = 'vertical'    
            else
                self.DualDir = true
            end
       end
       
       if not self.DualDir then -- направление выбрано
			-- for sound
			self.x_curr, self.y_curr = self.Objects[self.DragObj[1]][self.DragObj[2]].Entity:GetX(), self.Objects[self.DragObj[1]][self.DragObj[2]].Entity:GetY()
            if self.x_curr == self.x_prev and self.y_curr == self.y_prev then
                    self.ForMusicUpDateCanStop = self.ForMusicUpDateCanStop + 1
                    if self.ForMusicUpDateCanStop  > 10 then
                            self.sound_move_items:StopSound()
                            self.ForMusicUpDateCanStop = 0
                    end
            else
                    if not self.sound_move_items:IsPlaying() then
                            self.sound_move_items:PlaySound(true)                        
                    end
                    self.ForMusicUpDateCanStop = 0
            end
            self.x_prev, self.y_prev = self.Objects[self.DragObj[1]][self.DragObj[2]].Entity:GetX(), self.Objects[self.DragObj[1]][self.DragObj[2]].Entity:GetY()   
            
			if self.DirMove == 'horizontal' then
					local x_limit = mouse_x
					if mouse_x > self.Cells[self.Cells.CountCol][self.DragObjCell[2]].Pos.x then
						x_limit = self.Cells[self.Cells.CountCol][self.DragObjCell[2]].Pos.x
					elseif mouse_x < self.Cells[1][self.DragObjCell[2]].Pos.x then
						x_limit = self.Cells[1][self.DragObjCell[2]].Pos.x
					end
					self.Objects[self.DragObj[1]][self.DragObj[2]].Entity:SetXY(x_limit, y)
			elseif self.DirMove == 'vertical' then
					local y_limit = mouse_y
					if mouse_y > self.Cells[self.DragObjCell[1]][self.Cells.CountRow].Pos.y then
						y_limit = self.Cells[self.DragObjCell[1]][self.Cells.CountRow].Pos.y
					elseif mouse_y < self.Cells[self.Cells.CountRow][1].Pos.y then
						y_limit = self.Cells[self.Cells.CountRow][1].Pos.y
					end
					self.Objects[self.DragObj[1]][self.DragObj[2]].Entity:SetXY(x, y_limit)
			end
			
			-- other parts
			-- проверяем, какая ближайшая часть к подобранной и меньше ли это расстояние дельты
			if self.DirMove == 'horizontal' then
				for i = 1, self.Cells.CountCol do
					local num_cell_in_row = {i, self.DragObjCell[2]} -- ячейка в ряде по которому двигается часть
					local num_part_in_row = self.ArrayForSaveMG.NumPuzzle[i][ self.DragObjCell[2] ] -- номер паззла в этой ячейке
					local dist = math.sqrt( math.pow(Object('Puzzle_'..self.DragObj[1]..'_'..self.DragObj[2]):GetScrX() - self.Cells[num_cell_in_row[1]][num_cell_in_row[2]].Pos.x, 2) + 
											math.pow(Object('Puzzle_'..self.DragObj[1]..'_'..self.DragObj[2]):GetScrY() - self.Cells[num_cell_in_row[1]][num_cell_in_row[2]].Pos.y, 2))
					if dist <= self.DeltaForMoveOtherPart and (i ~= self.DragObjCell[1]) then
						-- двигаем найденный ближайший кусочек в координаты подобранного кусочка и присваиваем этим кусочкам новые места (меняем их местами)
						Object('Puzzle_'..num_part_in_row[1]..'_'..num_part_in_row[2]):MoveTo(self.Cells[self.DragObjCell[1]][self.DragObjCell[2]].Pos.x, 
																							  self.Cells[self.DragObjCell[1]][self.DragObjCell[2]].Pos.y, self.TimeMoveOtherParts)
						-- replace
						self.ArrayForSaveMG.NumPuzzle[i][ self.DragObjCell[2] ][1], self.ArrayForSaveMG.NumPuzzle[self.DragObjCell[1]][self.DragObjCell[2]][1] = 
						self.ArrayForSaveMG.NumPuzzle[self.DragObjCell[1]][self.DragObjCell[2]][1], self.ArrayForSaveMG.NumPuzzle[i][ self.DragObjCell[2] ][1] 
						self.ArrayForSaveMG.NumPuzzle[i][ self.DragObjCell[2] ][2], self.ArrayForSaveMG.NumPuzzle[self.DragObjCell[1]][self.DragObjCell[2]][2] = 
						self.ArrayForSaveMG.NumPuzzle[self.DragObjCell[1]][self.DragObjCell[2]][2], self.ArrayForSaveMG.NumPuzzle[i][ self.DragObjCell[2] ][2] 
						self.DragObjCell = {i, self.DragObjCell[2]}
						break
					end
				end
			elseif self.DirMove == 'vertical' then
				for i = 1, self.Cells.CountRow do
					local num_cell_in_row = {self.DragObjCell[1], i} -- ячейка в колонке по которой двигается часть
					local num_part_in_row = self.ArrayForSaveMG.NumPuzzle[ self.DragObjCell[1] ][i] -- номер паззла в этой ячейке
					local dist = math.sqrt( math.pow(Object('Puzzle_'..self.DragObj[1]..'_'..self.DragObj[2]):GetScrX() - self.Cells[num_cell_in_row[1]][num_cell_in_row[2]].Pos.x, 2) + 
											math.pow(Object('Puzzle_'..self.DragObj[1]..'_'..self.DragObj[2]):GetScrY() - self.Cells[num_cell_in_row[1]][num_cell_in_row[2]].Pos.y, 2))
					if dist <= self.DeltaForMoveOtherPart and (i ~= self.DragObjCell[2]) then
						-- двигаем найденный ближайший кусочек в координаты подобранного кусочка и присваиваем этим кусочкам новые места (меняем их местами)
						Object('Puzzle_'..num_part_in_row[1]..'_'..num_part_in_row[2]):MoveTo(self.Cells[self.DragObjCell[1]][self.DragObjCell[2]].Pos.x, 
																							  self.Cells[self.DragObjCell[1]][self.DragObjCell[2]].Pos.y, self.TimeMoveOtherParts)
						-- replace
						self.ArrayForSaveMG.NumPuzzle[ self.DragObjCell[1] ][i][1], self.ArrayForSaveMG.NumPuzzle[self.DragObjCell[1]][self.DragObjCell[2]][1] = 
						self.ArrayForSaveMG.NumPuzzle[self.DragObjCell[1]][self.DragObjCell[2]][1], self.ArrayForSaveMG.NumPuzzle[ self.DragObjCell[1] ][i][1] 
						self.ArrayForSaveMG.NumPuzzle[ self.DragObjCell[1] ][i][2], self.ArrayForSaveMG.NumPuzzle[self.DragObjCell[1]][self.DragObjCell[2]][2] = 
						self.ArrayForSaveMG.NumPuzzle[self.DragObjCell[1]][self.DragObjCell[2]][2], self.ArrayForSaveMG.NumPuzzle[ self.DragObjCell[1] ][i][2] 
						self.DragObjCell = {self.DragObjCell[1], i}
						break
					end
				end
			end
			
			
			
       end
       
	end
end

function l_11_Vitraj:OnObjectMouseEnter(object)

	 if string.find(object:GetName(), 'Puzzle_') == 1  then
			if self.DragObj[1] == 0 then
				   Object('Light'):SetXY(object:GetX(), object:GetY())
				   Object('Light'):SetVisible(true)
			end
     end

end

function l_11_Vitraj:OnObjectMouseLeave(object)

	 if string.find(object:GetName(), 'Puzzle_') == 1  then
           Object('Light'):SetVisible(false)
     end

end

function l_11_Vitraj:OnScreenObjectMouseDown(object, key)

	if key == HGEK_LBUTTON then
            if string.find(object:GetName(), 'Puzzle_') then
					self:IgnoreObjectMG(true)
					Object('Light'):SetVisible(false)
					
					local num_col = tonumber(string.sub(object:GetName(), 8, 8))
					local num_row = tonumber(string.sub(object:GetName(), 10))
					
					self.DragObj = {num_col, num_row}
					play_field:DoNotIgnoreOnTestPoint('Puzzle_'..self.DragObj[1]..'_'..self.DragObj[2])

					self.DragDeltaX = GetMousePos().x - object:GetScrX()
					self.DragDeltaY = GetMousePos().y - object:GetScrY()
					
					-- z
					object:SetZ(self.DragZ)
					
					-- ищем, в какой ячейке находится итем
					for i = 1,self.Cells.CountCol do
							for j = 1,self.Cells.CountRow do
									if self.ArrayForSaveMG.NumPuzzle[i][j][1] == num_col and self.ArrayForSaveMG.NumPuzzle[i][j][2] == num_row then
											self.DragObjCell = {i, j}
											break
									end
							end
							if self.DragObjCell[1] ~= 0 then
									break
							end
					end	
					
					self.DualDir = true					
					
			end
	end

end

function l_11_Vitraj:OnMouseMove(previous_pos, current_pos)	
end

function l_11_Vitraj:OnObjectMouseUp(object)

	 if self.DragObj[1] ~= 0 then
			-- sounds
			self.ForMusicUpDateCanStop = 0
			self.sound_move_items:StopSound()
					
			local col, row = self.DragObj[1], self.DragObj[2]
			self.Objects[col][row].Entity:MoveTo(self.Cells[self.DragObjCell[1]][self.DragObjCell[2]].Pos.x, 
												 self.Cells[self.DragObjCell[1]][self.DragObjCell[2]].Pos.y, self.TimeMoveOtherParts)
			-- !!! save
			self.DragObj = {0, 0}
			self.DragObjCell = {0, 0}
			
			local compl = self:IsCompleted()
			if compl then
					play_field:IgnoreOnTestPoint('Puzzle_'..col..'_'..row)					
					CompleteMinigame(1)
			end
			
			Helpers.SaveObjectToGameState(self.Save_state_mg, self.ArrayForSaveMG)
			
			self.timer:Add(function()
								self.Objects[col][row].Entity:SetZ(self.Objects[col][row].Z)
								if not IsMiniGameCompleted('l_11_Vitraj') then
									self:IgnoreObjectMG(false)
								else
									for i = 1,self.Cells.CountCol do
											for j = 1,self.Cells.CountRow do
												self.Objects[i][j].Entity:GetAnimation():SetBlendMode(3)
												self.Objects[i][j].Entity:GetAnimation():SetColor(self.ItemColorBlendMode)
											end
									end
									self.sound_final:PlaySound(false)
								end
							--	Object('Light'):SetXY(object:GetX(), object:GetY())
							--	Object('Light'):SetVisible(true)
							end,
							self.TimeMoveOtherParts)
	 end

end

function l_11_Vitraj:OnButtonPress(title)
end

--------------------------------------------------------------------------------
-- CLEAR_ON_SAVE_BEGIN
-- Do not edit code listed below (generated by the editor on each save)
function l_11_Vitraj:LoadData(screen)
	local anim
	anim = CreateAnimation('data/Texture/Minigames/11_Vitraj/Background.jpg',0,0,1024,768,1,0)
	anim:SetHotSpot(512,384)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	screen:CreateObject('Background',anim,512,384,90,0,1,1)
	
	anim = CreateAnimation('data/Texture/Minigames/11_Vitraj/05.jpg',0,0,136,136,1,0)
	anim:SetHotSpot(68,68)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	screen:CreateObject('Puzzle_1_1',anim,240,107,105,0,1,1)
	
	anim = CreateAnimation('data/Texture/Minigames/11_Vitraj/04.jpg',0,0,136,136,1,0)
	anim:SetHotSpot(68,68)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	screen:CreateObject('Puzzle_2_1',anim,376,107,104,0,1,1)
	
	anim = CreateAnimation('data/Texture/Minigames/11_Vitraj/03.jpg',0,0,136,136,1,0)
	anim:SetHotSpot(68,68)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	screen:CreateObject('Puzzle_3_1',anim,512,107,103,0,1,1)
	
	anim = CreateAnimation('data/Texture/Minigames/11_Vitraj/02.jpg',0,0,136,136,1,0)
	anim:SetHotSpot(68,68)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	screen:CreateObject('Puzzle_4_1',anim,648,107,102,0,1,1)
	
	anim = CreateAnimation('data/Texture/Minigames/11_Vitraj/01.jpg',0,0,136,136,1,0)
	anim:SetHotSpot(68,68)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	screen:CreateObject('Puzzle_5_1',anim,784,107,101,0,1,1)
	
	anim = CreateAnimation('data/Texture/Minigames/11_Vitraj/06.jpg',0,0,136,136,1,0)
	anim:SetHotSpot(68,68)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	screen:CreateObject('Puzzle_1_2',anim,240,243,106,0,1,1)
	
	anim = CreateAnimation('data/Texture/Minigames/11_Vitraj/07.jpg',0,0,136,136,1,0)
	anim:SetHotSpot(68,68)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	screen:CreateObject('Puzzle_2_2',anim,376,243,107,0,1,1)
	
	anim = CreateAnimation('data/Texture/Minigames/11_Vitraj/08.jpg',0,0,136,136,1,0)
	anim:SetHotSpot(68,68)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	screen:CreateObject('Puzzle_3_2',anim,512,243,108,0,1,1)
	
	anim = CreateAnimation('data/Texture/Minigames/11_Vitraj/09.jpg',0,0,136,136,1,0)
	anim:SetHotSpot(68,68)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	screen:CreateObject('Puzzle_4_2',anim,648,243,109,0,1,1)
	
	anim = CreateAnimation('data/Texture/Minigames/11_Vitraj/10.jpg',0,0,136,136,1,0)
	anim:SetHotSpot(68,68)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	screen:CreateObject('Puzzle_5_2',anim,784,243,110,0,1,1)
	
	anim = CreateAnimation('data/Texture/Minigames/11_Vitraj/15.jpg',0,0,136,136,1,0)
	anim:SetHotSpot(68,68)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	screen:CreateObject('Puzzle_1_3',anim,240,379,115,0,1,1)
	
	anim = CreateAnimation('data/Texture/Minigames/11_Vitraj/14.jpg',0,0,136,136,1,0)
	anim:SetHotSpot(68,68)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	screen:CreateObject('Puzzle_2_3',anim,376,379,114,0,1,1)
	
	anim = CreateAnimation('data/Texture/Minigames/11_Vitraj/13.jpg',0,0,136,136,1,0)
	anim:SetHotSpot(68,68)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	screen:CreateObject('Puzzle_3_3',anim,512,379,113,0,1,1)
	
	anim = CreateAnimation('data/Texture/Minigames/11_Vitraj/12.jpg',0,0,136,136,1,0)
	anim:SetHotSpot(68,68)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	screen:CreateObject('Puzzle_4_3',anim,648,379,112,0,1,1)
	
	anim = CreateAnimation('data/Texture/Minigames/11_Vitraj/11.jpg',0,0,136,136,1,0)
	anim:SetHotSpot(68,68)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	screen:CreateObject('Puzzle_5_3',anim,784,379,111,0,1,1)
	
	anim = CreateAnimation('data/Texture/Minigames/11_Vitraj/16.jpg',0,0,136,136,1,0)
	anim:SetHotSpot(68,68)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	screen:CreateObject('Puzzle_1_4',anim,240,515,116,0,1,1)
	
	anim = CreateAnimation('data/Texture/Minigames/11_Vitraj/17.jpg',0,0,136,136,1,0)
	anim:SetHotSpot(68,68)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	screen:CreateObject('Puzzle_2_4',anim,376,515,117,0,1,1)
	
	anim = CreateAnimation('data/Texture/Minigames/11_Vitraj/18.jpg',0,0,136,136,1,0)
	anim:SetHotSpot(68,68)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	screen:CreateObject('Puzzle_3_4',anim,512,515,118,0,1,1)
	
	anim = CreateAnimation('data/Texture/Minigames/11_Vitraj/19.jpg',0,0,136,136,1,0)
	anim:SetHotSpot(68,68)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	screen:CreateObject('Puzzle_4_4',anim,648,515,119,0,1,1)
	
	anim = CreateAnimation('data/Texture/Minigames/11_Vitraj/20.jpg',0,0,136,136,1,0)
	anim:SetHotSpot(68,68)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	screen:CreateObject('Puzzle_5_4',anim,784,515,120,0,1,1)
	
	anim = CreateAnimation('data/Texture/Minigames/11_Vitraj/Light.png',0,0,140,140,1,0)
	anim:SetHotSpot(70,70)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	screen:CreateObject('Light',anim,944,16,140,0,1,1)
	
	anim = CreateAnimation('data/Texture/Common/area.png',0,0,8,8,1,0)
	anim:SetHotSpot(4,4)
	anim:SetBlendMode(2)
	anim:SetColor('0x01FFFFFF')
	screen:CreateObject('area_need_part',anim,515,319,150,0,130,80)
	
end
-- CLEAR_ON_SAVE_END
