--Specjalizacja dla : Ursus c355 By Marcello1942
--#Autor: marcello1942
--#data: 10/02/2013 r.

Wladymirec = {};

function Wladymirec.prerequisitesPresent(specializations)
    return SpecializationUtil.hasSpecialization(Motorized, specializations);
end;

function Wladymirec:load(xmlFile)

	local klapalewa = Utils.indexToObject(self.rootNode, getXMLString(xmlFile, "vehicle.lok#lewe"));
	if klapalewa ~= nil then
		self.klapalewa = klapalewa;
	end;
		local klapaprawa = Utils.indexToObject(self.rootNode, getXMLString(xmlFile, "vehicle.lok#prawe"));
	if klapaprawa ~= nil then
		self.klapaprawa = klapaprawa;
	end;
		local zaczep = Utils.indexToObject(self.rootNode, getXMLString(xmlFile, "vehicle.lok#zaczep"));
	if zaczep ~= nil then
		self.zaczep = zaczep;
	end;
		local maska = Utils.indexToObject(self.rootNode, getXMLString(xmlFile, "vehicle.lok#maska"));
	if maska ~= nil then
		self.maska = maska;
	end;
		local pompka = Utils.indexToObject(self.rootNode, getXMLString(xmlFile, "vehicle.lok#pompka"));
	if pompka ~= nil then
		self.pompka = pompka;
	end;
	local one = Utils.indexToObject(self.rootNode, getXMLString(xmlFile, "vehicle.lok#one"));
	if one ~= nil then
		self.one = one;
	end;
	local two = Utils.indexToObject(self.rootNode, getXMLString(xmlFile, "vehicle.lok#two"));
	if two ~= nil then
		self.two = two;
	end;
	local three = Utils.indexToObject(self.rootNode, getXMLString(xmlFile, "vehicle.lok#three"));
	if three ~= nil then
		self.three = three;
	end;
	local four = Utils.indexToObject(self.rootNode, getXMLString(xmlFile, "vehicle.lok#four"));
	if four ~= nil then
		self.four = four;
	end;
	local rear = Utils.indexToObject(self.rootNode, getXMLString(xmlFile, "vehicle.lok#rear"));
	if rear ~= nil then
		self.rear = rear;
	end;

  	local hydraulicsCount = Utils.getNoNil(getXMLInt(xmlFile, "vehicle.hydraulics#count"), 0);
	self.hydraulics = {};
	for i=1, hydraulicsCount do
		local hydraulicName = string.format("vehicle.hydraulics.hydraulic%d", i);
		self.hydraulics[i] = {};
		self.hydraulics[i].node = Utils.indexToObject(self.components, getXMLString(xmlFile, hydraulicName .. "#index"));
		self.hydraulics[i].punch = Utils.indexToObject(self.components, getXMLString(xmlFile, hydraulicName .. "#punch"));
		self.hydraulics[i].translationPunch = Utils.indexToObject(self.components, getXMLString(xmlFile, hydraulicName .. "#punchFixpoint"));
		self.hydraulics[i].fixPoint = Utils.indexToObject(self.components, getXMLString(xmlFile, hydraulicName .. "#fixpoint"));
		local xUp, yUp, zUp = Utils.getVectorFromString(Utils.getNoNil(getXMLString(xmlFile, hydraulicName .. "#upVectors"),"0 1 0"));
		self.hydraulics[i].upVectors = {xUp, yUp, zUp};

		local ax, ay, az;
		if self.hydraulics[i].punch ~= nil then
			ax, ay, az = getWorldTranslation(self.hydraulics[i].punch);
		else
			ax, ay, az = getWorldTranslation(self.hydraulics[i].node);
		end;
		if self.hydraulics[i].translationPunch ~= nil then
			local bx, by, bz = getWorldTranslation(self.hydraulics[i].translationPunch);
			self.hydraulics[i].punchDistance = Utils.vector3Length(ax-bx, ay-by, az-bz);
		end;
	end;
	
	self.setHydraulicTime = 30;
    self.setHydraulicDirection = SpecializationUtil.callSpecializationsFunction("setHydraulicDirection");
    self.otworz = false
	self.zamknij = false
	
	local rotationLifter = Utils.indexToObject(self.rootNode, getXMLString(xmlFile, "vehicle.Lifter#index"));
	self.Lifter = {};
	self.Lifter.node = rotationLifter;

	local rotationLifterArm = Utils.indexToObject(self.rootNode, getXMLString(xmlFile, "vehicle.LifterArm#index"));
	self.LifterArm = {};
	self.LifterArm.node = rotationLifterArm;

	local rotationLifterBottom = Utils.indexToObject(self.rootNode, getXMLString(xmlFile, "vehicle.LifterBottom#index"));
	self.bottomArm2 = {};
	self.bottomArm2.node = rotationLifterBottom;

	local BottomArmNode = Utils.indexToObject(self.rootNode, getXMLString(xmlFile, "vehicle.attacherJoints.attacherJoint.bottomArm#rotationNode"));
	self.bottomArm = {};
	self.bottomArm.node = BottomArmNode;
	
	
	bieg1SoundFile = Utils.getFilename("bieg.wav", self.baseDirectory);
    self.bieg1SoundId = createSample("LizardHor12nSound");
    loadSample(self.bieg1SoundId, bieg1SoundFile, false);
    self.bieg1Playing = false;
	
	bieg2SoundFile = Utils.getFilename("bieg.wav", self.baseDirectory);
    self.bieg2SoundId = createSample("LizardHor12nSound");
    loadSample(self.bieg2SoundId, bieg2SoundFile, false);
    self.bieg2Playing = false;
	
	bieg3SoundFile = Utils.getFilename("bieg.wav", self.baseDirectory);
    self.bieg3SoundId = createSample("LizardHor12nSound");
    loadSample(self.bieg3SoundId, bieg3SoundFile, false);
    self.bieg3Playing = false;
	
	bieg4SoundFile = Utils.getFilename("bieg.wav", self.baseDirectory);
    self.bieg4SoundId = createSample("LizardHor12nSound");
    loadSample(self.bieg4SoundId, bieg4SoundFile, false);
    self.bieg4Playing = false;
	
	biegRSoundFile = Utils.getFilename("bieg1.wav", self.baseDirectory);
    self.biegRSoundId = createSample("LizardHor12nSound");
    loadSample(self.biegRSoundId, biegRSoundFile, false);
    self.biegRPlaying = false;
	
	maska_upSoundFile = Utils.getFilename("maska_up.wav", self.baseDirectory);
    self.maska_upSoundId = createSample("LizardHor12nSound");
    loadSample(self.maska_upSoundId, maska_upSoundFile, false);
    self.maska_upPlaying = false;
	
	maska_downSoundFile = Utils.getFilename("maska_down.wav", self.baseDirectory);
    self.maska_downSoundId = createSample("LizardHor12nSound");
    loadSample(self.maska_downSoundId, maska_downSoundFile, false);
    self.maska_downPlaying = false;
	
	podnosnikSoundFile = Utils.getFilename("podnosnik.wav", self.baseDirectory);
    self.podnosnikSoundId = createSample("LizardHor12nSound");
    loadSample(self.podnosnikSoundId, podnosnikSoundFile, false);
    self.podnosnikPlaying = false;
	
	powerSoundFile = Utils.getFilename("powerSound.wav", self.baseDirectory);
    self.powerSoundId = createSample("LizardHor12nSound");
    loadSample(self.powerSoundId, powerSoundFile, false);
    self.powerPlaying = false;
	
	otworzdrzwiSoundFile = Utils.getFilename("otworzdrzwi.wav", self.baseDirectory);
    self.otworzdrzwiSoundId = createSample("LizardHor12nSound");
    loadSample(self.otworzdrzwiSoundId, otworzdrzwiSoundFile, false);
    self.otworzdrzwiPlaying = false;
	
	zamknijdrzwiSoundFile = Utils.getFilename("zamknijdrzwi.wav", self.baseDirectory);
    self.zamknijdrzwiSoundId = createSample("LizardHor12nSound");
    loadSample(self.zamknijdrzwiSoundId, zamknijdrzwiSoundFile, false);
    self.zamknijdrzwiPlaying = false;
	
	wycieraczkaSoundFile = Utils.getFilename("wycieraczka.wav", self.baseDirectory);
    self.wycieraczkaSoundId = createSample("LizardHor12nSound");
    loadSample(self.wycieraczkaSoundId, wycieraczkaSoundFile, false);
    self.wycieraczkaPlaying = false;

end;
 function Wladymirec:delete()
end;
function Wladymirec:keyEvent(unicode, sym, modifier, isDown)

   if isDown and sym == Input.KEY_0 then
		self.pomoc = not self.pomoc;
	end;
	  
	  
	if isDown and sym == Input.KEY_b then
		self.Przekaznik = not self.Przekaznik;
	end;
	
	
	if isDown and sym == Input.KEY_b then
		self.wajcha = not self.wajcha;
	end;
	
	if isDown and sym == Input.KEY_w then
		self.front = not self.front;
	end;
	
	
	if isDown and sym == Input.KEY_s then
		self.backward = not self.backward;
	end;
	
	if isDown and sym == Input.KEY_l then
		self.wycieraczka = not self.wycieraczka;
	end;
	
	if isDown and sym == Input.KEY_v then
		self.podnosnik = not self.podnosnik;
	end;
  
end;


function Wladymirec:update(dt)

        local nearestDistance = 2;
		local vx, vy, vz = getWorldTranslation(g_currentMission.player.rootNode);
	
		
		local px, py, pz = getWorldTranslation(self.klapalewa); 
		local distance = Utils.vector3Length(px-vx, py-vy, pz-vz);	
		if distance < nearestDistance then
			self.przyklapiel = true; 
		else
			self.przyklapiel = false; 
		end;
		
		
		local sx, sy, sz = getWorldTranslation(self.zaczep); 
		local distance = Utils.vector3Length(sx-vx, sy-vy, sz-vz);	
		if distance < nearestDistance then
			self.przyzaczepie = true; 
		else
			self.przyzaczepie = false; 
		end; 

		local tx, ty, tz = getWorldTranslation(self.maska); 
		local distance = Utils.vector3Length(tx-vx, ty-vy, tz-vz);	
		if distance < nearestDistance then
			self.przymaska = true; 
		else
			self.przymaska = false; 
		end; 
		
		local ux, uy, uz = getWorldTranslation(self.pompka); 
		local distance = Utils.vector3Length(ux-vx, uy-vy, uz-vz);	
		if distance < nearestDistance then
			self.przypompka = true; 
		else
			self.przypompka = false; 
		end; 
		
		
--------drzwi----------------
	if self.przyklapiep or self.isEntered then
	if InputBinding.hasEvent(InputBinding.PRAWE) then
			if self.animationParts[1].clipEndTime then
				self:setAnimationTime(1, self.animationParts[1].offSet);
			elseif self.animationParts[1].clipStartTime then
				self:setAnimationTime(1, self.animationParts[1].animDuration);
			end;
		end;
	end;
	
	if self.przyklapiel or self.isEntered then
	if InputBinding.hasEvent(InputBinding.LEWE) then
			if self.animationParts[2].clipEndTime then
				self:setAnimationTime(2, self.animationParts[2].offSet);
				self.sound9 = true;
				self.sound10 = false;
			elseif self.animationParts[2].clipStartTime then
				self:setAnimationTime(2, self.animationParts[2].animDuration);
				self.sound10 = true;
				self.sound9 = false;
			end;
		end;
	end;
	
	--Maska--
	if self.przymaska then
		if InputBinding.hasEvent(InputBinding.maska) then
			if self.animationParts[7].clipEndTime then
				self:setAnimationTime(7, self.animationParts[7].offSet);
				self.sound5 = true;
				self.sound6 = false;
			elseif self.animationParts[7].clipStartTime then
				self:setAnimationTime(7, self.animationParts[7].animDuration);
				self.sound6 = true;
				self.sound5 = false;
			end;
		end;
	end;
	
	--dach-	
	if self.isEntered then				
		if InputBinding.hasEvent(InputBinding.DACH) then
			if self.animationParts[3].clipEndTime then
				self:setAnimationTime(3, self.animationParts[3].offSet);
			elseif self.animationParts[3].clipStartTime then
				self:setAnimationTime(3, self.animationParts[3].animDuration);
			end;
		end;
		
	--hydraulika
		if InputBinding.isPressed(InputBinding.PODW) then
               self:setAnimationTime(5, self.animationParts[5].currentPosition+(self.animationParts[5].offSet+dt), false);
           elseif InputBinding.isPressed(InputBinding.PODN) then
               self:setAnimationTime(5, self.animationParts[5].currentPosition-(self.animationParts[5].offSet+dt), false);
        end;
       end;
	   
	--zaczep--
	if self.przyzaczepie then
	 	if InputBinding.isPressed(InputBinding.zaczepP) then
               self:setAnimationTime(4, self.animationParts[4].currentPosition+(self.animationParts[4].offSet+dt), false);
           elseif InputBinding.isPressed(InputBinding.zaczepL) then
               self:setAnimationTime(4, self.animationParts[4].currentPosition-(self.animationParts[4].offSet+dt), false);
        end;
        end;
		
		--pompka--
	if self.przypompka then
	 	if InputBinding.isPressed(InputBinding.pompkaup) then
               self:setAnimationTime(24, self.animationParts[24].currentPosition+(self.animationParts[24].offSet+dt), false);
           elseif InputBinding.isPressed(InputBinding.pompkadown) then
               self:setAnimationTime(24, self.animationParts[24].currentPosition-(self.animationParts[24].offSet+dt), false);
        end;
        end;
		
		---szyba_tyl---
		
	if self.isEntered then
	if InputBinding.hasEvent(InputBinding.szyba) then
	if self.animationParts[45].clipEndTime then
			self:setAnimationTime(45, self.animationParts[45].offSet);
	elseif  self.animationParts[45].clipStartTime then
		    self:setAnimationTime(45, self.animationParts[45].animDuration);
	end;
	end;
	end;
	
	---podnosnik---
	
	if self.Lifter.node ~= nil and self.bottomArm2.node ~= nil then
			rBBArmX, rBBArmY, rBBArmZ = getRotation(self.bottomArm2.node);
			setRotation(self.Lifter.node, rBBArmX*2, 0, 0);
	end;
	if self.LifterArm.node ~= nil and self.bottomArm2.node ~= nil then
			setRotation(self.LifterArm.node, 0.05-rBBArmX*2, 0, 0);
	end;
	
	---wajcha podnosnika---
		
		if self.podnosnik then
		   self:setAnimationTime(5,self.animationParts[5].animDuration);
		else 
		   self:setAnimationTime(5,self.animationParts[5].offSet);	   
		end;
		
	
		
	if self.setAnimationTime ~= nil then
		if self.isMotorStarted then
			self:setAnimationTime(6, 1);
		else
			self:setAnimationTime(6, 0);
		end;
		if self.isMotorStarted then
			self:setAnimationTime(8, 1);
		else
			self:setAnimationTime(8, 0);
		end;
		
		if self.Przekaznik then
           self:setAnimationTime(9, 1);
        else
           self:setAnimationTime(9, 0);
        end;
		
	    if self.isMotorStarted then
			self:setAnimationTime(11,self.animationParts[11].animDuration);
		else
			self:setAnimationTime(11,self.animationParts[11].offSet);
		end;
		
		---speed by marcello1942---
		
		
		 if self.lastSpeed*3600 > 1 then
			self:setAnimationTime(12,self.animationParts[12].animDuration);
		else
			self:setAnimationTime(12,self.animationParts[12].offSet);
		end;
		 if self.lastSpeed*3600 > 2 then
			self:setAnimationTime(13,self.animationParts[13].animDuration);
		else
			self:setAnimationTime(13,self.animationParts[13].offSet);
		end;
		 if self.lastSpeed*3600 > 3 then
			self:setAnimationTime(14,self.animationParts[14].animDuration);
		else
			self:setAnimationTime(14,self.animationParts[14].offSet);
		end;
		 if self.lastSpeed*3600 > 4 then
			self:setAnimationTime(15,self.animationParts[15].animDuration);
		else
			self:setAnimationTime(15,self.animationParts[15].offSet);
		end;
		if self.lastSpeed*3600 > 5 then
			self:setAnimationTime(16,self.animationParts[16].animDuration);
		else
			self:setAnimationTime(16,self.animationParts[16].offSet);
		end;
		 if self.lastSpeed*3600 > 6 then
			self:setAnimationTime(17,self.animationParts[17].animDuration);
		else
			self:setAnimationTime(17,self.animationParts[17].offSet);
		end;
		if self.lastSpeed*3600 > 7 then
			self:setAnimationTime(18,self.animationParts[18].animDuration);
		else
			self:setAnimationTime(18,self.animationParts[18].offSet);
		end;
		 if self.lastSpeed*3600 > 8 then
			self:setAnimationTime(19,self.animationParts[19].animDuration);
		else
			self:setAnimationTime(19,self.animationParts[19].offSet);
		end;
		if self.lastSpeed*3600 > 9 then
			self:setAnimationTime(20,self.animationParts[20].animDuration);
		else
			self:setAnimationTime(20,self.animationParts[20].offSet);
		end;
		 if self.lastSpeed*3600 > 10 then
			self:setAnimationTime(21,self.animationParts[21].animDuration);
		else
			self:setAnimationTime(21,self.animationParts[21].offSet);
		end;
		if self.lastSpeed*3600 > 12 then
			self:setAnimationTime(35,self.animationParts[35].animDuration);
		else
			self:setAnimationTime(35,self.animationParts[35].offSet);
		end;
		 if self.lastSpeed*3600 > 14 then
			self:setAnimationTime(36,self.animationParts[36].animDuration);
		else
			self:setAnimationTime(36,self.animationParts[36].offSet);
		end;
		 if self.lastSpeed*3600 > 16 then
			self:setAnimationTime(37,self.animationParts[37].animDuration);
		else
			self:setAnimationTime(37,self.animationParts[37].offSet);
		end;
		 if self.lastSpeed*3600 > 18 then
			self:setAnimationTime(38,self.animationParts[38].animDuration);
		else
			self:setAnimationTime(38,self.animationParts[38].offSet);
		end;
		if self.lastSpeed*3600 > 20 then
			self:setAnimationTime(39,self.animationParts[39].animDuration);
		else
			self:setAnimationTime(39,self.animationParts[39].offSet);
		end;
		 if self.lastSpeed*3600 > 22 then
			self:setAnimationTime(40,self.animationParts[40].animDuration);
		else
			self:setAnimationTime(40,self.animationParts[40].offSet);
		end;
		if self.lastSpeed*3600 > 24 then
			self:setAnimationTime(41,self.animationParts[41].animDuration);
		else
			self:setAnimationTime(41,self.animationParts[41].offSet);
		end;
		 if self.lastSpeed*3600 > 26 then
			self:setAnimationTime(42,self.animationParts[42].animDuration);
		else
			self:setAnimationTime(42,self.animationParts[42].offSet);
		end;
		if self.lastSpeed*3600 > 28 then
			self:setAnimationTime(43,self.animationParts[43].animDuration);
		else
			self:setAnimationTime(43,self.animationParts[43].offSet);
		end;
		 if self.lastSpeed*3600 > 30 then
			self:setAnimationTime(44,self.animationParts[44].animDuration);
		else
			self:setAnimationTime(44,self.animationParts[44].offSet);
		end;
		
		---over---
		
		
		if self.isMotorStarted then
			self:setAnimationTime(22,self.animationParts[22].animDuration);
		else
			self:setAnimationTime(22,self.animationParts[22].offSet);
		end;
		if self.hamuj then
			self:setAnimationTime(23,self.animationParts[23].animDuration);
		else
			self:setAnimationTime(23,self.animationParts[23].offSet);
		end;
		if self.wajcha then
			self:setAnimationTime(10,self.animationParts[10].animDuration);
		else
			self:setAnimationTime(10,self.animationParts[10].offSet);
		end;
		if self.wycieraczka then
           self:setAnimationTime(46, 1);
		   self.sound11 = true;
        else
           self:setAnimationTime(46, 0);
		   self.sound11 = false;
        end;
		
		---klapkafull---
		
		if self.lastSpeed*3600 > 23 then
			self:setAnimationTime(26,self.animationParts[26].animDuration);
		else
			self:setAnimationTime(26,self.animationParts[26].offSet);
		end;
		if self.isMotorStarted then
			self:setAnimationTime(25, 1);
		else
			self:setAnimationTime(25, 0);
		end;
	end;
	
		
                         --- gearBox marcello1942---		
		
		if self.motor.speedLevel == 4 then
			self:setAnimationTime(31,self.animationParts[31].animDuration);
			self.two = false;
			self.three = false;
			self.one = false;
			self.rear = false;
			self.sound4 = true;
		else
			self:setAnimationTime(31,self.animationParts[31].offSet);
			self.sound4 = false;
		end;
		if self.isEntered then
		if self.motor.speedLevel == 3 or Input.isKeyPressed(Input.KEY_w) then
			self:setAnimationTime(30,self.animationParts[30].animDuration);
			self.two = false;
			self.one = false;
			self.four = false;
			self.rear = false;
			self.sound3 = true;
		else
			self:setAnimationTime(30,self.animationParts[30].offSet);
			self.sound3 = false;
		end;
		end;
		if self.motor.speedLevel == 2 then
			self:setAnimationTime(29,self.animationParts[29].animDuration);
			self.one = false;
			self.three = false;
			self.four = false;
			self.rear = false;
			self.sound2 = true;
		else
			self:setAnimationTime(29,self.animationParts[29].offSet);
			self.sound2 = false;
		end;
		if self.isEntered then
		if self.motor.speedLevel == 1 then
			self:setAnimationTime(28,self.animationParts[28].animDuration);
			self.two = false;
			self.three = false;
			self.four = false;
			self.rear = false;
			self.sound1 = true;
		else
			self:setAnimationTime(28,self.animationParts[28].offSet);
			self.sound1 = false;
		end;
		end;
		
		if self.isMotorStarted then
		if self.isEntered then
		if Input.isKeyPressed(Input.KEY_s) then
		   self:setAnimationTime(32,self.animationParts[32].animDuration);
		   self.two = false;
		   self.three = false;
		   self.four = false;
		   self.one = false;
		   self.sound7 = true;
		else 
		   self:setAnimationTime(32,self.animationParts[32].offSet);
		   self.sound7 = false;
		end;
		end;
		end;
		
				
        if self.front then
			self.two = false;
			self.one = false;
			self.four = false;
		end;
		
		if self.backward then
		    self.one = false;
			self.two = false;
			self.four = false;
			self.three = false;
		end;
		
		if Input.isKeyPressed(Input.KEY_1) or Input.isKeyPressed(Input.KEY_2) or Input.isKeyPressed(Input.KEY_3) or Input.isKeyPressed(Input.KEY_4) then
		   self:setAnimationTime(33,self.animationParts[33].animDuration);
		else 
		   self:setAnimationTime(33,self.animationParts[33].offSet); 
		end;
		if self.isEntered then
		if Input.isKeyPressed(Input.KEY_w) or Input.isKeyPressed(Input.KEY_s) then
		   self:setAnimationTime(34,self.animationParts[34].animDuration);
		else 
		   self:setAnimationTime(34,self.animationParts[34].offSet); 
		end;
		end;

		
	  --napisy
		
		if self.przyklapiel then
	if self.animationParts[2].clipStartTime then
			g_currentMission:addExtraPrintText(string.format("%s: otworz Drzwi", InputBinding.getKeyNamesOfDigitalAction(InputBinding.LEWE)));
		else
			g_currentMission:addExtraPrintText(string.format("%s: zamknij Drzwi", InputBinding.getKeyNamesOfDigitalAction(InputBinding.LEWE)));
		end;
		end;
		if self.przyklapiep then
	if self.animationParts[1].clipStartTime then
			g_currentMission:addExtraPrintText(string.format("%s: otworz Drzwi", InputBinding.getKeyNamesOfDigitalAction(InputBinding.PRAWE)));
		else
			g_currentMission:addExtraPrintText(string.format("%s: zamknij Drzwi", InputBinding.getKeyNamesOfDigitalAction(InputBinding.PRAWE)));
		end;
		end
		if self.przymaska then
	if self.animationParts[7].clipStartTime then
			g_currentMission:addExtraPrintText(string.format("%s: otworz Maske", InputBinding.getKeyNamesOfDigitalAction(InputBinding.maska)));
		else
			g_currentMission:addExtraPrintText(string.format("%s: zamknij Maske", InputBinding.getKeyNamesOfDigitalAction(InputBinding.maska)));
		end;
		end
		if self.przypompka then
			g_currentMission:addExtraPrintText(string.format("%s: pompka up", InputBinding.getKeyNamesOfDigitalAction(InputBinding.pompkaup)));
			g_currentMission:addExtraPrintText(string.format("%s: pompka down", InputBinding.getKeyNamesOfDigitalAction(InputBinding.pompkadown)));
		end;

			if self:getIsActive() then
		self.setHydraulicTime = 30;
	end;


	if self.setHydraulicTime > 0 then
		for k,v in pairs(self.hydraulics) do
			self:setHydraulicDirection(k);
		end;
		self.setHydraulicTime = self.setHydraulicTime - 1;
	end;
	
	

	
		if self.sound1 then
       if not self.bieg1Playing then
            playSample(self.bieg1SoundId, 1, 3, 3);
            self.bieg1Playing = true;
        end;
       
    else
        if self.bieg1Playing then
            stopSample(self.bieg1SoundId);
            self.bieg1Playing = false;
        end;
         
    end;
	
	if self.sound2 then
       if not self.bieg2Playing then
            playSample(self.bieg2SoundId, 1, 3, 3);
            self.bieg2Playing = true;
        end;
       
    else
        if self.bieg2Playing then
            stopSample(self.bieg2SoundId);
            self.bieg2Playing = false;
        end;
         
    end;
	
	if self.sound3 then
       if not self.bieg3Playing then
            playSample(self.bieg3SoundId, 1, 3, 3);
            self.bieg3Playing = true;
        end;
       
    else
        if self.bieg3Playing then
            stopSample(self.bieg3SoundId);
            self.bieg3Playing = false;
        end;
         
    end;
	
	if self.sound4 then
       if not self.bieg4Playing then
            playSample(self.bieg4SoundId, 1, 3, 3);
            self.bieg4Playing = true;
        end;
       
    else
        if self.bieg4Playing then
            stopSample(self.bieg4SoundId);
            self.bieg4Playing = false;
        end;
         
    end;
	
	if self.sound5 then
       if not self.maska_upPlaying then
            playSample(self.maska_upSoundId, 1, 3, 3);
            self.maska_upPlaying = true;
        end;
       
    else
        if self.maska_upPlaying then
            stopSample(self.maska_upSoundId);
            self.maska_upPlaying = false;
        end;
         
    end;
	
	if self.sound6 then
       if not self.maska_downPlaying then
            playSample(self.maska_downSoundId, 1, 3, 3);
            self.maska_downPlaying = true;
        end;
       
    else
        if self.maska_downPlaying then
            stopSample(self.maska_downSoundId);
            self.maska_downPlaying = false;
        end;
         
    end;
	
	if self.isEntered then					   
	   if Input.isKeyPressed(Input.KEY_pageup) or Input.isKeyPressed(Input.KEY_pagedown) then
       if not self.podnosnikPlaying then
            playSample(self.podnosnikSoundId, 0, 1, 0);
            self.podnosnikPlaying = true;
        end;
       
    else
        if self.podnosnikPlaying then
            stopSample(self.podnosnikSoundId);
            self.podnosnikPlaying = false;
        end;
         
    end;
	end;
	
	if self.sound7 then
       if not self.biegRPlaying then
            playSample(self.biegRSoundId, 1, 3, 3);
            self.biegRPlaying = true;
        end;
       
    else
        if self.biegRPlaying then
            stopSample(self.biegRSoundId);
            self.biegRPlaying = false;
        end;
         
    end;
	
	if self.sound9 then
       if not self.otworzdrzwiPlaying then
            playSample(self.otworzdrzwiSoundId, 1, 3, 3);
            self.otworzdrzwiPlaying = true;
        end;
       
    else
        if self.otworzdrzwiPlaying then
            stopSample(self.otworzdrzwiSoundId);
            self.otworzdrzwiPlaying = false;
        end;
         
    end;
	
	
	if self.sound10 then
       if not self.zamknijdrzwiPlaying then
            playSample(self.zamknijdrzwiSoundId, 1, 3, 3);
            self.zamknijdrzwiPlaying = true;
        end;
       
    else
        if self.zamknijdrzwiPlaying then
            stopSample(self.zamknijdrzwiSoundId);
            self.zamknijdrzwiPlaying = false;
        end;
         
    end;
	
	
	if self.sound11 then
       if not self.wycieraczkaPlaying then
            playSample(self.wycieraczkaSoundId, 0, 1, 0);
            self.wycieraczkaPlaying = true;
        end;
       
    else
        if self.wycieraczkaPlaying then
            stopSample(self.wycieraczkaSoundId);
            self.wycieraczkaPlaying = false;
        end;
         
    end;
	
	if self.isEntered then					   
	   if Input.isKeyPressed(Input.KEY_w) then
       if not self.powerPlaying then
            playSample(self.powerSoundId, 1, 3, 3);
            self.powerPlaying = true;
        end;
       
    else
        if self.powerPlaying then
            stopSample(self.powerSoundId);
            self.powerPlaying = false;
        end;
         
    end;
	end;
         
   
	
end;


function Wladymirec:mouseEvent(posX, posY, isDown, isUp, button)
end;

function Wladymirec:validateAttacherJoint(implement, jointDesc, dt)
    return true;
end;
function Wladymirec:setHydraulicDirection(index)
	local hydraulic = self.hydraulics[index];

	if hydraulic.fixPoint ~= nil then
		local ax, ay, az = getWorldTranslation(hydraulic.node);
		local bx, by, bz = getWorldTranslation(hydraulic.fixPoint);
		local x, y, z = worldDirectionToLocal(getParent(hydraulic.node), bx-ax, by-ay, bz-az);
		local xUp, yUp, zUp = unpack(hydraulic.upVectors);
		setDirection(hydraulic.node, x, y, z, xUp, yUp, zUp);
		if hydraulic.punch ~= nil then
			local distance = Utils.vector3Length(ax-bx, ay-by, az-bz);
			setTranslation(hydraulic.punch, 0, 0, distance-hydraulic.punchDistance);
		end;
	end;
end;
function Wladymirec:draw()

    if self.isEntered then
		if not self.pomoc then
			renderText(0.833, 0.175, 0.02, "Wcisnij 0: Pokaz pomoc");
		else
			renderText(0.833, 0.175, 0.02, "Wcisnij 0: Schowaj pomoc");
		end;
		if self.pomoc then
			renderText(0.72, 0.825, 0.025, "----->Wladymirec T-25<-----");
			if not self.isMotorStarted then
			renderText(0.72, 0.800, 0.02, " Num enter: odpal Wladymirca");
			else
			renderText(0.72, 0.800, 0.02, " Num enter: zgas Wladymirca");
			end;
	
	
		    renderText(0.72, 0.775, 0.02, "drzwi: N ");
         
           
			renderText(0.72, 0.750, 0.02, "Kierunkowskazy: Num 1/2/3 ");
	
		
			renderText(0.72, 0.725, 0.02, "halogen: 7 ");
			
		
			renderText(0.72, 0.7, 0.02, "pompka  up: Z,  down: X ");
			
			
			renderText(0.72, 0.675, 0.02, "wycieraczka: L ");
			
			
			renderText(0.72, 0.650, 0.02, "szyby: tylna: G, boczna: M ");
			
			
			renderText(0.72, 0.625, 0.02, "maska: J ");
			
			
			renderText(0.72, 0.6, 0.02, "dodaj, zmniejsz gaz: Num_plus, Num_minus ");
		
			
			renderText(0.72, 0.575, 0.02, "----->MARCELLO 1942<-----");
			
			
			renderText(0.72, 0.550, 0.02, "----->Fairred225<-----");
			
			
			renderText(0.72, 0.525, 0.02, "----->Tomek096<-----");
		end;
	end;	
end;

function Wladymirec:updateTick(dt)
		if self.backHydraulic ~= nil then		
		local x, y, z = getRotation(self.attacherJoints[1].bottomArm.rotationNode);
		setRotation(self.backHydraulic.rootArm, x, y, z);	
	end;		
end;