95 | function TourIcons:update(dt) |
96 | |
97 | if not g_currentMission.missionInfo.isValid and g_server ~= nil and self.initDone == nil then |
98 | self.initDone = true; |
99 | |
100 | -- prepare fields |
101 | local fieldDef = g_currentMission.fieldDefinitionBase.fieldDefs[15]; |
102 | local fruitDesc = FruitUtil.fruitIndexToDesc[FruitUtil.FRUITTYPE_WHEAT]; |
103 | for i=1,table.getn(fieldDef.maxFieldStatusPartitions) do |
104 | FieldJobManager:setFieldPartitionStatus(fieldDef, fieldDef.maxFieldStatusPartitions, i, fruitDesc.index, FieldJobManager.FIELDSTATE_GROWING, fruitDesc.maxHarvestingGrowthState, 3, true); |
105 | end |
106 | |
107 | local fieldDef = g_currentMission.fieldDefinitionBase.fieldDefs[14]; |
108 | local fruitDesc = FruitUtil.fruitIndexToDesc[FruitUtil.FRUITTYPE_RAPE]; |
109 | for i=1,table.getn(fieldDef.maxFieldStatusPartitions) do |
110 | FieldJobManager:setFieldPartitionStatus(fieldDef, fieldDef.maxFieldStatusPartitions, i, fruitDesc.index, FieldJobManager.FIELDSTATE_HARVESTED, 0, 0, false); |
111 | end |
112 | |
113 | local fieldDef = g_currentMission.fieldDefinitionBase.fieldDefs[12]; |
114 | for i=1,table.getn(fieldDef.maxFieldStatusPartitions) do |
115 | FieldJobManager:setFieldPartitionStatus(fieldDef, fieldDef.maxFieldStatusPartitions, i, nil, FieldJobManager.FIELDSTATE_CULTIVATED, 0, 0, false); |
116 | end |
117 | |
118 | -- fillUp sowingMachine |
119 | if g_currentMission.tourVehicles["tourSowingMachine"] ~= nil then |
120 | local tool = g_currentMission.tourVehicles["tourSowingMachine"]; |
121 | if tool ~= nil and tool.components ~= nil and entityExists(tool.components[1].node) then |
122 | tool:setFillLevel(tool:getCapacity(FillUtil.FILLTYPE_SEEDS), FillUtil.FILLTYPE_SEEDS, true, nil); |
123 | tool:setFillLevel(tool:getCapacity(FillUtil.FILLTYPE_FERTILIZER), FillUtil.FILLTYPE_FERTILIZER, true, nil); |
124 | end |
125 | end |
126 | |
127 | -- open cover of trailer |
128 | local trailer = g_currentMission.tourVehicles["tourTrailer"]; |
129 | if trailer ~= nil then |
130 | if trailer.setCoverState ~= nil then |
131 | trailer:setCoverState(true, true); |
132 | end |
133 | end |
134 | end |
135 | |
136 | |
137 | if self.startTourDialog then |
138 | self.startTourDialogDelay = self.startTourDialogDelay - dt; |
139 | local showDialog = true; |
140 | if g_currentMission.cameraFlightManager ~= nil then |
141 | showDialog = g_currentMission.cameraFlightManager.careerStartFlightPlayed; |
142 | end |
143 | if showDialog then |
144 | if self.startTourDialogDelay < 0 then |
145 | self.startTourDialog = false; |
146 | g_currentMission.inGameMessage:showDialog(self.showTourDialog, self); |
147 | end; |
148 | end |
149 | end; |
150 | |
151 | if self.isPaused then |
152 | if self.pauseTime > 0 then |
153 | self.pauseTime = self.pauseTime - dt; |
154 | else |
155 | self.pauseTime = 0; |
156 | self.isPaused = false; |
157 | self:activateNextIcon(); |
158 | end; |
159 | end; |
160 | |
161 | if self.visible and not self.isPaused then |
162 | |
163 | -- show current permanent message on screen if no ingame message or any other GUI screen is displayed |
164 | if not g_currentMission.inGameMessage:getIsVisible() and not g_gui:getIsGuiVisible() then |
165 | |
166 | if false then --g_i18n:hasText("tour_permanentText" .. self.currentTourIconNumber - 1) then |
167 | |
168 | if self.permanentMessageDelay > 0 then |
169 | self.permanentMessageDelay = self.permanentMessageDelay - dt; |
170 | self.alpha = 0.25; |
171 | self.alphaDirection = 1; |
172 | else |
173 | |
174 | setTextColor(1, 1, 1, self.alpha); |
175 | setTextBold(true); |
176 | setTextAlignment(RenderText.ALIGN_CENTER); |
177 | setTextWrapWidth(0.35); |
178 | if GS_IS_CONSOLE_VERSION then |
179 | setTextWrapWidth(0.295); |
180 | end; |
181 | renderText(0.5, 0.93, self.permanentTextSize, g_i18n:getText("tour_permanentText" .. self.currentTourIconNumber - 1)); |
182 | setTextWrapWidth(0); |
183 | setTextAlignment(RenderText.ALIGN_LEFT); |
184 | setTextBold(false); |
185 | setTextColor(1, 1, 1, 1); |
186 | |
187 | self.alpha = self.alpha + self.alphaDirection * (dt / 600) ; |
188 | if self.alpha > 1 or self.alpha < 0.25 then |
189 | self.alphaDirection = self.alphaDirection * -1; |
190 | self.alpha = Utils.clamp(self.alpha, 0.25, 1); |
191 | end; |
192 | end; |
193 | |
194 | end; |
195 | end; |
196 | |
197 | -- handle special cases |
198 | |
199 | --# harvesting |
200 | |
201 | -- icon #3 activates as soon as the player enters the tour's combine harvester |
202 | if self.currentTourIconNumber <= 3 then |
203 | if g_currentMission.controlledVehicle ~= nil and g_currentMission.controlledVehicle == g_currentMission.tourVehicles["tourCombine"] then |
204 | self.currentTourIconNumber = 3; |
205 | -- self:activateNextIcon(); |
206 | self.pauseTime = 1000; |
207 | self.isPaused = true; |
208 | end; |
209 | end; |
210 | |
211 | -- wait for player to attach the cutter |
212 | if self.currentTourIconNumber == 4 then |
213 | if g_currentMission.controlledVehicle ~= nil and g_currentMission.controlledVehicle == g_currentMission.tourVehicles["tourCombine"] then |
214 | if g_currentMission.controlledVehicle.numAttachedCutters > 0 then |
215 | -- self:activateNextIcon(); |
216 | self.pauseTime = 1000; |
217 | self.isPaused = true; |
218 | end; |
219 | end; |
220 | end; |
221 | |
222 | -- wait for player to activate the cutter |
223 | if self.currentTourIconNumber == 5 then |
224 | if g_currentMission.controlledVehicle ~= nil and g_currentMission.controlledVehicle == g_currentMission.tourVehicles["tourCombine"] then |
225 | if g_currentMission.controlledVehicle:getIsTurnedOn() then |
226 | -- self:activateNextIcon(); |
227 | self.pauseTime = 1000; |
228 | self.isPaused = true; |
229 | end; |
230 | end; |
231 | end; |
232 | |
233 | -- wait for player to activate the helper |
234 | if self.currentTourIconNumber == 7 then |
235 | if g_currentMission.controlledVehicle ~= nil and g_currentMission.controlledVehicle == g_currentMission.tourVehicles["tourCombine"] then |
236 | if g_currentMission.controlledVehicle:getIsTurnedOn() and g_currentMission.controlledVehicle.aiIsStarted then |
237 | -- self:activateNextIcon(); |
238 | self.pauseTime = 1000; |
239 | self.isPaused = true; |
240 | end; |
241 | end; |
242 | end; |
243 | |
244 | --# cultivating |
245 | |
246 | -- wait for player to enter tractor1 and attach cultivator |
247 | if self.currentTourIconNumber == 9 then |
248 | if g_currentMission.controlledVehicle ~= nil and g_currentMission.controlledVehicle == g_currentMission.tourVehicles["tourTractor1"] then |
249 | if g_currentMission.tourVehicles["tourCultivator"]:getRootAttacherVehicle() == g_currentMission.tourVehicles["tourTractor1"] then |
250 | -- self:activateNextIcon(); |
251 | self.pauseTime = 1000; |
252 | self.isPaused = true; |
253 | end |
254 | end; |
255 | end; |
256 | |
257 | if self.currentTourIconNumber == 11 then |
258 | -- self:activateNextIcon(); |
259 | self.pauseTime = 1000; |
260 | self.isPaused = true; |
261 | end |
262 | |
263 | --# sowing |
264 | |
265 | -- wait for player to enter tractor2 and attach sowingMachine |
266 | if self.currentTourIconNumber == 13 then |
267 | if g_currentMission.controlledVehicle ~= nil and g_currentMission.controlledVehicle == g_currentMission.tourVehicles["tourTractor2"] then |
268 | if g_currentMission.tourVehicles["tourSowingMachine"]:getRootAttacherVehicle() == g_currentMission.tourVehicles["tourTractor2"] then |
269 | -- self:activateNextIcon(); |
270 | self.pauseTime = 1000; |
271 | self.isPaused = true; |
272 | end |
273 | end; |
274 | end; |
275 | |
276 | |
277 | --# overloading / tipping |
278 | |
279 | -- wait for player to enter tractor3 and attach trailer |
280 | if self.currentTourIconNumber == 16 then |
281 | if g_currentMission.controlledVehicle ~= nil and g_currentMission.controlledVehicle == g_currentMission.tourVehicles["tourTractor3"] then |
282 | if g_currentMission.tourVehicles["tourTrailer"]:getRootAttacherVehicle() == g_currentMission.tourVehicles["tourTractor3"] then |
283 | -- self:activateNextIcon(); |
284 | self.pauseTime = 1000; |
285 | self.isPaused = true; |
286 | end |
287 | end; |
288 | end; |
289 | |
290 | if self.currentTourIconNumber == 17 then |
291 | if g_currentMission.controlledVehicle ~= nil and g_currentMission.controlledVehicle == g_currentMission.tourVehicles["tourTractor3"] then |
292 | if g_currentMission.tourVehicles["tourTrailer"]:getRootAttacherVehicle() == g_currentMission.tourVehicles["tourTractor3"] then |
293 | |
294 | local tracctor = g_currentMission.tourVehicles["tourTractor3"]; |
295 | local trailer = g_currentMission.tourVehicles["tourTrailer"]; |
296 | local combine = g_currentMission.tourVehicles["tourCombine"]; |
297 | |
298 | local x,y,z = localToWorld(combine.components[1].node, 6,0,0); |
299 | self.mapHotspot.xMapPos = x; |
300 | self.mapHotspot.zMapPos = z; |
301 | |
302 | local xv,yv,zv = getWorldTranslation(tracctor.components[1].node); |
303 | local dist = Utils.vector3Length(x-xv, y-yv, z-zv); |
304 | if dist < 10 then |
305 | g_currentMission:setMapTargetHotspot(nil); |
306 | else |
307 | g_currentMission:setMapTargetHotspot(self.mapHotspot); |
308 | end |
309 | |
310 | if trailer:getUnitFillLevel(trailer.trailer.fillUnitIndex) > 0 and |
311 | g_currentMission.nodeToVehicle[combine.trailerFound] == trailer and |
312 | combine.overloading.didOverload == true |
313 | then |
314 | -- self:activateNextIcon(); |
315 | self.pauseTime = 1000; |
316 | self.isPaused = true; |
317 | end |
318 | end |
319 | end; |
320 | end; |
321 | |
322 | if self.currentTourIconNumber == 19 then |
323 | -- self:activateNextIcon(); |
324 | self.pauseTime = 3000; |
325 | self.isPaused = true; |
326 | end |
327 | |
328 | if self.currentTourIconNumber == 20 then |
329 | if g_currentMission.controlledVehicle ~= nil and g_currentMission.controlledVehicle == g_currentMission.tourVehicles["tourTractor3"] then |
330 | if g_currentMission.tourVehicles["tourTrailer"]:getRootAttacherVehicle() == g_currentMission.tourVehicles["tourTractor3"] then |
331 | local trailer = g_currentMission.tourVehicles["tourTrailer"]; |
332 | |
333 | if trailer.tipState == Trailer.TIPSTATE_OPENING or trailer.tipState == Trailer.TIPSTATE_OPEN then |
334 | if trailer.currentTipTrigger ~= nil and trailer.currentTipTrigger.stationName == "station_townBakeryGCV" then |
335 | -- self:activateNextIcon(); |
336 | self.pauseTime = 3000; |
337 | self.isPaused = true; |
338 | end |
339 | end |
340 | end |
341 | end |
342 | end |
343 | |
344 | --# shop |
345 | if self.currentTourIconNumber == 22 then |
346 | -- self:activateNextIcon(); |
347 | self.pauseTime = 1000; |
348 | self.isPaused = true; |
349 | end |
350 | |
351 | end; |
352 | end; |
400 | function TourIcons:activateNextIcon() |
401 | |
402 | -- make all previous icons invisible (also handles cases where player managed to skip icons) |
403 | for i = 1, self.currentTourIconNumber do |
404 | local tourIcon = self.tourIcons[i]; |
405 | if getVisibility(tourIcon.tourIconId) then |
406 | setVisibility(tourIcon.tourIconId, false); |
407 | setCollisionMask(tourIcon.tourIconTriggerId, 0); |
408 | end; |
409 | end; |
410 | |
411 | if self.tourIcons[self.currentTourIconNumber + 1] ~= nil then |
412 | self:makeIconVisible(self.tourIcons[self.currentTourIconNumber + 1].tourIconId); |
413 | else |
414 | -- end of tour! |
415 | if self.mapHotspot ~= nil then |
416 | g_currentMission.ingameMap:deleteMapHotspot(self.mapHotspot); |
417 | self.mapHotspot = nil; |
418 | end; |
419 | -- re-display non-tour help icons |
420 | if g_gameSettings:getValue("showHelpIcons") then |
421 | if g_currentMission.helpIconsBase ~= nil then |
422 | g_currentMission.helpIconsBase:showHelpIcons(true, true); |
423 | end; |
424 | end |
425 | |
426 | self.visible = false; |
427 | end; |
428 | |
429 | local title = g_i18n:getText("ui_tour"); |
430 | local text = ""; |
431 | local controls = {} |
432 | |
433 | if self.currentTourIconNumber == 1 then |
434 | |
435 | text = g_i18n:getText("tour_text_part01_lookAndWalk"); |
436 | table.insert(controls, InputBinding.getControllerSymbolOverlays(InputBinding.TOGGLE_MAP_SIZE, nil, g_i18n:getText("action_toggleMapView"))) |
437 | |
438 | local useGamepadButtons = InputBinding.getInputHelpMode() == GS_INPUT_HELP_MODE_GAMEPAD; |
439 | if useGamepadButtons then |
440 | table.insert(controls, InputBinding.getControllerSymbolOverlays(InputBinding.AXIS_MOVE_FORWARD_PLAYER, InputBinding.AXIS_MOVE_SIDE_PLAYER, g_i18n:getText("action_movePlayer"))); |
441 | table.insert(controls, InputBinding.getControllerSymbolOverlays(InputBinding.AXIS_LOOK_UPDOWN_PLAYER, InputBinding.AXIS_LOOK_LEFTRIGHT_PLAYER, g_i18n:getText("action_lookPlayer"))); |
442 | else |
443 | -- special case on PC |
444 | table.insert(controls, InputBinding.getControllerSymbolOverlays(InputBinding.AXIS_MOVE_FORWARD_PLAYER, nil, g_i18n:getText("action_movePlayer"))); |
445 | table.insert(controls, InputBinding.getControllerSymbolOverlays(InputBinding.AXIS_MOVE_SIDE_PLAYER, nil, g_i18n:getText("action_movePlayer"))); |
446 | -- to show a mouse icon, instead of 'arrow keys' on keyboard |
447 | local lookAroundSymbol = InputBinding.controllerSymbols["mouse_MOUSE_BUTTON_NONE"]; |
448 | if lookAroundSymbol ~= nil then |
449 | table.insert(controls, {overlays = {lookAroundSymbol.overlay}, text = g_i18n:getText("action_lookPlayer")} ); |
450 | end |
451 | end |
452 | |
453 | elseif self.currentTourIconNumber == 2 then -- # harvesting |
454 | |
455 | text = g_i18n:getText("tour_text_part01_enterCombine"); |
456 | table.insert(controls, InputBinding.getControllerSymbolOverlays(InputBinding.ENTER, nil, g_i18n:getText("input_ENTER"))) |
457 | |
458 | elseif self.currentTourIconNumber == 3 then |
459 | |
460 | text = g_i18n:getText("tour_text_part01_attachHeader"); |
461 | table.insert(controls, InputBinding.getControllerSymbolOverlays(InputBinding.ATTACH, nil, g_i18n:getText("input_ATTACH"))) |
462 | |
463 | elseif self.currentTourIconNumber == 4 then |
464 | |
465 | text = g_i18n:getText("tour_text_part01_turnOnCombine"); |
466 | table.insert(controls, InputBinding.getControllerSymbolOverlays(InputBinding.IMPLEMENT_EXTRA2, nil, g_i18n:getText("action_unfold"))) |
467 | table.insert(controls, InputBinding.getControllerSymbolOverlays(InputBinding.IMPLEMENT_EXTRA, nil, g_i18n:getText("action_turnOn"))) |
468 | |
469 | elseif self.currentTourIconNumber == 5 then |
470 | |
471 | text = g_i18n:getText("tour_text_part01_startHarvesting"); |
472 | table.insert(controls, InputBinding.getControllerSymbolOverlays(InputBinding.AXIS_ACCELERATE_VEHICLE, InputBinding.AXIS_BRAKE_VEHICLE, g_i18n:getText("action_accelerate"))) |
473 | table.insert(controls, InputBinding.getControllerSymbolOverlays(InputBinding.AXIS_MOVE_SIDE_VEHICLE, nil, g_i18n:getText("action_steer"))) |
474 | |
475 | elseif self.currentTourIconNumber == 6 then |
476 | |
477 | text = g_i18n:getText("tour_text_part01_startHelperHarvesting"); |
478 | table.insert(controls, InputBinding.getControllerSymbolOverlays(InputBinding.TOGGLE_AI, nil, g_i18n:getText("input_TOGGLE_AI"))) |
479 | |
480 | elseif self.currentTourIconNumber == 7 then |
481 | |
482 | text = g_i18n:getText("tour_text_part01_finished"); |
483 | table.insert(controls, InputBinding.getControllerSymbolOverlays(InputBinding.ENTER, nil, g_i18n:getText("action_exitVehicle"))) |
484 | |
485 | elseif self.currentTourIconNumber == 8 then -- # cultivating |
486 | |
487 | text = g_i18n:getText("tour_text_part02_enterTractor01"); |
488 | table.insert(controls, InputBinding.getControllerSymbolOverlays(InputBinding.ENTER, nil, g_i18n:getText("input_ENTER"))) |
489 | table.insert(controls, InputBinding.getControllerSymbolOverlays(InputBinding.ATTACH, nil, g_i18n:getText("input_ATTACH"))) |
490 | |
491 | elseif self.currentTourIconNumber == 9 then |
492 | |
493 | text = g_i18n:getText("tour_text_part02_startCultivating"); |
494 | table.insert(controls, InputBinding.getControllerSymbolOverlays(InputBinding.LOWER_IMPLEMENT, nil, g_i18n:getText("input_LOWER_IMPLEMENT"))); |
495 | |
496 | elseif self.currentTourIconNumber == 10 then |
497 | |
498 | text = g_i18n:getText("tour_text_part02_enoughCultivating"); |
499 | table.insert(controls, InputBinding.getControllerSymbolOverlays(InputBinding.TOGGLE_AI, nil, g_i18n:getText("input_TOGGLE_AI"))); |
500 | |
501 | elseif self.currentTourIconNumber == 11 then |
502 | |
503 | text = g_i18n:getText("tour_text_part02_finished"); |
504 | table.insert(controls, InputBinding.getControllerSymbolOverlays(InputBinding.SWITCH_VEHICLE, nil, g_i18n:getText("input_SWITCH_VEHICLE"))); |
505 | table.insert(controls, InputBinding.getControllerSymbolOverlays(InputBinding.SWITCH_VEHICLE_BACK, nil, g_i18n:getText("input_SWITCH_VEHICLE_BACK"))); |
506 | |
507 | elseif self.currentTourIconNumber == 12 then -- # sowing |
508 | |
509 | text = g_i18n:getText("tour_text_part03_enterTractor01"); |
510 | table.insert(controls, InputBinding.getControllerSymbolOverlays(InputBinding.ENTER, nil, g_i18n:getText("input_ENTER"))) |
511 | table.insert(controls, InputBinding.getControllerSymbolOverlays(InputBinding.ATTACH, nil, g_i18n:getText("input_ATTACH"))) |
512 | |
513 | elseif self.currentTourIconNumber == 13 then |
514 | |
515 | text = g_i18n:getText("tour_text_part03_startSowing"); |
516 | table.insert(controls, InputBinding.getControllerSymbolOverlays(InputBinding.IMPLEMENT_EXTRA3, nil, g_i18n:getText("action_chooseSeed"))) |
517 | table.insert(controls, InputBinding.getControllerSymbolOverlays(InputBinding.LOWER_IMPLEMENT, nil, g_i18n:getText("input_LOWER_IMPLEMENT"))) |
518 | table.insert(controls, InputBinding.getControllerSymbolOverlays(InputBinding.IMPLEMENT_EXTRA, nil, g_i18n:getText("action_turnOn"))) |
519 | |
520 | elseif self.currentTourIconNumber == 14 then |
521 | |
522 | text = g_i18n:getText("tour_text_part03_finished"); |
523 | table.insert(controls, InputBinding.getControllerSymbolOverlays(InputBinding.SWITCH_VEHICLE, nil, g_i18n:getText("input_SWITCH_VEHICLE"))); |
524 | table.insert(controls, InputBinding.getControllerSymbolOverlays(InputBinding.SWITCH_VEHICLE_BACK, nil, g_i18n:getText("input_SWITCH_VEHICLE_BACK"))); |
525 | |
526 | elseif self.currentTourIconNumber == 15 then -- # trailer / tipping and selling |
527 | |
528 | text = g_i18n:getText("tour_text_part04_enterTractor01"); |
529 | table.insert(controls, InputBinding.getControllerSymbolOverlays(InputBinding.ENTER, nil, g_i18n:getText("input_ENTER"))) |
530 | table.insert(controls, InputBinding.getControllerSymbolOverlays(InputBinding.ATTACH, nil, g_i18n:getText("input_ATTACH"))) |
531 | |
532 | elseif self.currentTourIconNumber == 16 then |
533 | |
534 | text = g_i18n:getText("tour_text_part04_alignToHarvester"); |
535 | |
536 | elseif self.currentTourIconNumber == 17 then |
537 | |
538 | text = g_i18n:getText("tour_text_part04_unloadWheat"); |
539 | |
540 | elseif self.currentTourIconNumber == 18 then |
541 | |
542 | text = g_i18n:getText("tour_text_part04_pricesInfo"); |
543 | table.insert(controls, InputBinding.getControllerSymbolOverlays(InputBinding.MENU, nil, g_i18n:getText("input_MENU"))) |
544 | |
545 | elseif self.currentTourIconNumber == 19 then |
546 | |
547 | text = g_i18n:getText("tour_text_part04_sellWheat"); |
548 | table.insert(controls, InputBinding.getControllerSymbolOverlays(InputBinding.TOGGLE_TIPSTATE, nil, g_i18n:getText("input_TOGGLE_TIPSTATE"))) |
549 | |
550 | elseif self.currentTourIconNumber == 20 then |
551 | |
552 | text = g_i18n:getText("tour_text_part04_doneSelling"); |
553 | |
554 | elseif self.currentTourIconNumber == 21 then -- # shop |
555 | |
556 | text = g_i18n:getText("tour_text_part05_visitShop"); |
557 | table.insert(controls, InputBinding.getControllerSymbolOverlays(InputBinding.TOGGLE_STORE, nil, g_i18n:getText("input_TOGGLE_STORE"))) |
558 | |
559 | elseif self.currentTourIconNumber == 22 then |
560 | |
561 | text = g_i18n:getText("tour_text_end"); |
562 | |
563 | end |
564 | |
565 | g_currentMission.inGameMessage:showMessage(title, text, -1, controls); |
566 | |
567 | |
568 | self.currentTourIconNumber = self.currentTourIconNumber + 1; |
569 | |
570 | self.permanentMessageDelay = 250; |
571 | end; |