--[[
    FloorSpike States:
    1003 - going down
    1005 - going up
    1006 - staying up
    1007 - staying down
]]

function main(self)
    local action = GetMainPlane()

	if self.State == 0 then
		FloorSpike(self)
        local detector = GetObject(3206)
		if detector.Difficulty == 2 then
			self.Damage = 2*self.Damage
		elseif detector.Difficulty == 1 then
			self.Damage = math.floor(self.Damage/2)
		end
		self.AttackRect = {-4, -12, 3, 12}
	else

        FloorSpike(self)

        if self.X > action.ScreenA.Left-80 and self.X < action.ScreenA.Right+80 and self.Y > action.ScreenA.Top-80 and self.Y < action.ScreenA.Bottom+80 and self.User[0] ~= 1 then
            if self.State == 1003 and not self.downSound then
			    PlaySound("CUSTOM_FLOORSPIKEDOWN")
			    self.downSound = true
		    elseif self.State == 1005 and not self.upSound then
                PlaySound("CUSTOM_FLOORSPIKEUP")
			    self.upSound = true
            elseif self.State == 1006 or self.State == 1007 then
                self.downSound = false
                self.upSound = false
		    end
        end
	end

end

