share/hedgewars/Data/Missions/Campaign/A_Space_Adventure/ice02.lua
changeset 14515 b54ba97c02d7
parent 14512 3b6976beb58b
child 14578 50f511588635
equal deleted inserted replaced
14514:5ac181cb2396 14515:b54ba97c02d7
   125 
   125 
   126 	SendHealthStatsOff()
   126 	SendHealthStatsOff()
   127 	AddAnim(dialog01)
   127 	AddAnim(dialog01)
   128 end
   128 end
   129 
   129 
       
   130 function onEndTurn()
       
   131 	if not hero.dead and CurrentHedgehog == hero.gear and challengeStarted then
       
   132 		heroLost()
       
   133 	end
       
   134 end
       
   135 
   130 function onNewTurn()
   136 function onNewTurn()
   131 	if not hero.dead and CurrentHedgehog == ally.gear and challengeStarted then
   137 	if not hero.dead and CurrentHedgehog == ally.gear and challengeStarted then
   132 		heroLost()
   138 		heroLost()
   133 	elseif not hero.dead and CurrentHedgehog == hero.gear and challengeStarted then
   139 	elseif not hero.dead and CurrentHedgehog == hero.gear and challengeStarted then
   134 		SetWeapon(amJetpack)
   140 		SetWeapon(amJetpack)
   183 	end
   189 	end
   184 	if heroTurn and challengeStarted and not gameEnded and not hero.dead and ReadyTimeLeft == 0 then
   190 	if heroTurn and challengeStarted and not gameEnded and not hero.dead and ReadyTimeLeft == 0 then
   185 		local time = totalTime - TurnTimeLeft
   191 		local time = totalTime - TurnTimeLeft
   186 		local timePrinted  = time / 1000
   192 		local timePrinted  = time / 1000
   187 		SetTeamLabel(teamA.name, string.format(loc("%.1fs"), timePrinted))
   193 		SetTeamLabel(teamA.name, string.format(loc("%.1fs"), timePrinted))
       
   194 		if TurnTimeLeft <= 0 then
       
   195 			local wp = waypoints[currentWaypoint-1]
       
   196 			if wp ~= nil then
       
   197 				DeleteVisualGear(wp.gear)
       
   198 				DeleteVisualGear(wp.gear2)
       
   199 			end
       
   200 		end
   188 	end
   201 	end
   189 end
   202 end
   190 
   203 
   191 function onGearDelete(gear)
   204 function onGearDelete(gear)
   192 	if gear == hero.gear then
   205 	if gear == hero.gear then
   249 	EndTurn(true)
   262 	EndTurn(true)
   250 	challengeStarted = true
   263 	challengeStarted = true
   251 end
   264 end
   252 
   265 
   253 function placeNextWaypoint()
   266 function placeNextWaypoint()
       
   267 	if gameEnded then
       
   268 		return
       
   269 	end
   254 	if currentWaypoint > 1 then
   270 	if currentWaypoint > 1 then
   255 		local wp = waypoints[currentWaypoint-1]
   271 		local wp = waypoints[currentWaypoint-1]
   256 		DeleteVisualGear(wp.gear)
   272 		DeleteVisualGear(wp.gear)
   257 		DeleteVisualGear(wp.gear2)
   273 		DeleteVisualGear(wp.gear2)
   258 	end
   274 	end
   306 	end
   322 	end
   307 	return false
   323 	return false
   308 end
   324 end
   309 
   325 
   310 function checkIfHeroInWaypoint()
   326 function checkIfHeroInWaypoint()
   311 	if not hero.dead then
   327 	if (not hero.dead) and (TurnTimeLeft > 0) then
   312 		local wp = waypoints[currentWaypoint-1]
   328 		local wp = waypoints[currentWaypoint-1]
   313 		if gearIsInCircle(hero.gear, wp.x, wp.y, radius+4, false) then
   329 		if gearIsInCircle(hero.gear, wp.x, wp.y, radius+4, false) then
   314 			SetWind(GetRandom(201)-100)
   330 			SetWind(GetRandom(201)-100)
   315 			return true
   331 			return true
   316 		end
   332 		end
   323 	SendStat(siCustomAchievement, loc("To win the game you have to pass into the rings in time."))
   339 	SendStat(siCustomAchievement, loc("To win the game you have to pass into the rings in time."))
   324 	SendStat(siCustomAchievement, loc("You'll get extra time in case you need it when you pass a ring."))
   340 	SendStat(siCustomAchievement, loc("You'll get extra time in case you need it when you pass a ring."))
   325 	SendStat(siCustomAchievement, loc("Green double rings also give you a new flying saucer."))
   341 	SendStat(siCustomAchievement, loc("Green double rings also give you a new flying saucer."))
   326 	SendStat(siCustomAchievement, loc("Use the attack key twice to change the flying saucer while being in air."))
   342 	SendStat(siCustomAchievement, loc("Use the attack key twice to change the flying saucer while being in air."))
   327 	sendSimpleTeamRankings({teamA.name})
   343 	sendSimpleTeamRankings({teamA.name})
       
   344 	gameEnded = true
   328 	EndGame()
   345 	EndGame()
   329 end
   346 end