share/hedgewars/Data/Missions/Campaign/A_Space_Adventure/fruit03.lua
changeset 12911 4ea0691d0ad5
parent 12592 0b27d8b4f8e7
child 12913 9abb04174323
equal deleted inserted replaced
12910:06791c62c759 12911:4ea0691d0ad5
   169 	if CurrentHedgehog == hero.gear and TurnTimeLeft ~= 0 then
   169 	if CurrentHedgehog == hero.gear and TurnTimeLeft ~= 0 then
   170 		timeLeft = TurnTimeLeft
   170 		timeLeft = TurnTimeLeft
   171 	end
   171 	end
   172 end
   172 end
   173 
   173 
       
   174 -- Display ammo icon above gear. i = offset (start at 1)
       
   175 local function displayAmmoIcon(gear, ammoType, i)
       
   176 	local x = GetX(gear) + 2
       
   177 	local y = GetY(gear) + 32 * i
       
   178 	local vgear = AddVisualGear(x, y, vgtAmmo, 0, true)
       
   179 	if vgear ~= nil then
       
   180 		local vgtX,vgtY,vgtdX,vgtdY,vgtAngle,vgtFrame,vgtFrameTicks,vgtState,vgtTimer,vgtTint = GetVisualGearValues(vgear)
       
   181 		local vgtFrame = ammoType
       
   182 		SetVisualGearValues(vgear,vgtX,vgtY,vgtdX,vgtdY,vgtAngle,vgtFrame,vgtFrameTicks,vgtState,vgtTimer,vgtTint)
       
   183 	end
       
   184 end
       
   185 
   174 function onGearDelete(gear)
   186 function onGearDelete(gear)
   175 	if (isHog(gear)) then
   187 	if (isHog(gear)) then
   176 		local availableTeleports = GetAmmoCount(hero.gear,amTeleport)
   188 		local availableTeleports = GetAmmoCount(hero.gear,amTeleport)
   177 		local availableSniper = GetAmmoCount(hero.gear,amSniperRifle)
   189 		local availableSniper = GetAmmoCount(hero.gear,amSniperRifle)
       
   190 		local ammolist = ""
       
   191 		local tele = false
   178 		if availableTeleports < 2 then
   192 		if availableTeleports < 2 then
   179 			AddAmmo(hero.gear, amTeleport, availableTeleports + 1 )
   193 			AddAmmo(hero.gear, amTeleport, availableTeleports + 1 )
       
   194 			displayAmmoIcon(hero.gear, amTeleport, 1)
       
   195 			tele = true
       
   196 			ammolist = ammolist .. string.format(loc("%s (+1)"), GetAmmoName(amTeleport))
   180 		end
   197 		end
   181 		if availableSniper < 4 then
   198 		if availableSniper < 4 then
   182 			AddAmmo(hero.gear, amSniperRifle, availableSniper + 1 )
   199 			AddAmmo(hero.gear, amSniperRifle, availableSniper + 1 )
       
   200 			displayAmmoIcon(hero.gear, amSniperRifle, 2)
       
   201 			if tele then
       
   202 				ammolist = ammolist .. " • "
       
   203 			end
       
   204 			ammolist = ammolist .. string.format(loc("%s (+1)"), GetAmmoName(amSniperRifle))
       
   205 		end
       
   206 		-- Show collected ammo
       
   207 		if ammolist ~= "" then
       
   208 			PlaySound(sndShotgunReload)
       
   209 			AddCaption(ammolist, GetClanColor(GetHogClan(hero.gear)), capgrpAmmoinfo)
   183 		end
   210 		end
   184 	end
   211 	end
   185 end
   212 end
   186 
   213 
   187 -- Hide mission panel when player does anything
   214 -- Hide mission panel when player does anything