300 | function TourIconsMobile:activateNextIcon() |
301 | -- make all previous icons invisible (also handles cases where player managed to skip icons) |
302 | for i = 1, self.currentTourIconNumber do |
303 | local tourIcon = self.tourIcons[i] |
304 | if getVisibility(tourIcon.tourIconId) then |
305 | setVisibility(tourIcon.tourIconId, false) |
306 | setCollisionMask(tourIcon.tourIconTriggerId, 0) |
307 | end |
308 | end |
309 | |
310 | if self.tourIcons[self.currentTourIconNumber + 1] ~= nil then |
311 | self:makeIconVisible(self.tourIcons[self.currentTourIconNumber + 1].tourIconId) |
312 | else |
313 | -- end of tour! |
314 | if self.mapHotspot ~= nil then |
315 | g_currentMission:removeMapHotspot(self.mapHotspot) |
316 | self.mapHotspot:delete() |
317 | self.mapHotspot = nil |
318 | end |
319 | -- re-display non-tour help icons |
320 | if g_gameSettings:getValue("showHelpIcons") then |
321 | if g_currentMission.helpIconsBase ~= nil then |
322 | g_currentMission.helpIconsBase:showHelpIcons(true, true) |
323 | end |
324 | end |
325 | |
326 | self.visible = false |
327 | g_messageCenter:publish(MessageType.MISSION_TOUR_FINISHED) |
328 | |
329 | -- clean up scene objects: |
330 | self:delete() |
331 | end |
332 | |
333 | local title = g_i18n:getText("ui_tour") |
334 | local text = "" |
335 | local controls = {} |
336 | |
337 | if self.currentTourIconNumber == 1 then |
338 | text = g_i18n:getText("tour_mobile_part01_activate") |
339 | |
340 | elseif self.currentTourIconNumber == 2 then |
341 | text = g_i18n:getText("tour_mobile_part01_drive") |
342 | |
343 | elseif self.currentTourIconNumber == 3 then |
344 | text = g_i18n:getText("tour_mobile_part01_helper") |
345 | |
346 | elseif self.currentTourIconNumber == 4 then |
347 | text = g_i18n:getText("tour_mobile_part01_finished") |
348 | |
349 | elseif self.currentTourIconNumber == 5 then -- # cultivating |
350 | text = g_i18n:getText("tour_mobile_part02_activate") |
351 | |
352 | elseif self.currentTourIconNumber == 6 then |
353 | text = g_i18n:getText("tour_mobile_part02_drive") |
354 | |
355 | elseif self.currentTourIconNumber == 7 then |
356 | text = g_i18n:getText("tour_mobile_part02_finished") |
357 | |
358 | elseif self.currentTourIconNumber == 8 then -- # sowing |
359 | text = g_i18n:getText("tour_mobile_part03_attach") |
360 | |
361 | elseif self.currentTourIconNumber == 9 then |
362 | text = g_i18n:getText("tour_mobile_part03_activateDrive") |
363 | |
364 | elseif self.currentTourIconNumber == 10 then |
365 | text = g_i18n:getText("tour_mobile_part03_finished") |
366 | |
367 | elseif self.currentTourIconNumber == 11 then -- # trailer / tipping and selling |
368 | text = g_i18n:getText("tour_mobile_part04_driveToYard") |
369 | |
370 | elseif self.currentTourIconNumber == 12 then |
371 | text = g_i18n:getText("tour_mobile_part04_detach") |
372 | |
373 | elseif self.currentTourIconNumber == 13 then |
374 | text = g_i18n:getText("tour_mobile_part04_attachTrailer") |
375 | |
376 | elseif self.currentTourIconNumber == 14 then |
377 | text = g_i18n:getText("tour_mobile_part04_driveToHarvester") |
378 | |
379 | elseif self.currentTourIconNumber == 15 then |
380 | text = g_i18n:getText("tour_mobile_part04_driveToSellpoint") |
381 | |
382 | elseif self.currentTourIconNumber == 16 then |
383 | text = g_i18n:getText("tour_mobile_part04_Unload") |
384 | |
385 | elseif self.currentTourIconNumber == 17 then |
386 | text = g_i18n:getText("tour_mobile_end") |
387 | |
388 | end |
389 | |
390 | if g_currentMission.controlledVehicle ~= nil and g_currentMission.controlledVehicle.setCruiseControlState ~= nil then |
391 | g_currentMission.controlledVehicle:setCruiseControlState(Drivable.CRUISECONTROL_STATE_OFF) |
392 | end |
393 | |
394 | if g_gui:getIsGuiVisible() then |
395 | self.queuedMessage = {title=title, text=text} |
396 | else |
397 | g_currentMission.hud.ingameMap:toggleSize(IngameMapMobile.STATE_HIDDEN, true) |
398 | g_gui:showInfoDialog({title=title, text=text}) |
399 | end |
400 | |
401 | self.currentTourIconNumber = self.currentTourIconNumber + 1 |
402 | |
403 | self.permanentMessageDelay = 250 |
404 | end |
262 | function TourIconsMobile:makeIconVisible(tourIconId) |
263 | -- make next icon visible |
264 | setVisibility(tourIconId, true) |
265 | local x, y, z = getWorldTranslation(tourIconId) |
266 | |
267 | if self.mapHotspot == nil then |
268 | self.mapHotspot = TourHotspot.new() |
269 | g_currentMission:addMapHotspot(self.mapHotspot) |
270 | end |
271 | |
272 | self.mapHotspot:setWorldPosition(x, z) |
273 | |
274 | -- Find 'hidden' icon used internally only |
275 | local h = getTerrainHeightAtWorldPos(g_currentMission.terrainRootNode, x,y,z) |
276 | if y > h then |
277 | g_currentMission:setMapTargetHotspot(self.mapHotspot) |
278 | g_currentMission.disableMapTargetHotspotHiding = true |
279 | else |
280 | g_currentMission:setMapTargetHotspot(nil) |
281 | g_currentMission.disableMapTargetHotspotHiding = false |
282 | end |
283 | end |
23 | function TourIconsMobile.new(id) |
24 | local self = {} |
25 | setmetatable(self, TourIconsMobile_mt) |
26 | |
27 | self.me = id |
28 | local num = getNumOfChildren(self.me) |
29 | |
30 | self.tourIcons = {} |
31 | for i = 0, num - 1 do |
32 | local tourIconTriggerId = getChildAt(self.me, i) |
33 | local tourIconId = getChildAt(tourIconTriggerId, 0) |
34 | addTrigger(tourIconTriggerId, "triggerCallback", self) |
35 | setVisibility(tourIconId, false) |
36 | local tourIcon = {tourIconTriggerId = tourIconTriggerId, tourIconId = tourIconId} |
37 | table.insert(self.tourIcons, tourIcon) |
38 | end |
39 | |
40 | self.visible = false |
41 | self.mapHotspot = nil |
42 | self.currentTourIconNumber = 1 |
43 | self.alpha = 0.25 |
44 | self.alphaDirection = 1 |
45 | self.startTourDialog = false |
46 | self.startTourDialogDelay = 0 |
47 | self.permanentMessageDelay = 0 |
48 | self.isPaused = false |
49 | self.pauseTime = 0 |
50 | self.soldStuffAtGrainElevator = false |
51 | |
52 | |
53 | local plowLevelMaxValue = g_currentMission.fieldGroundSystem:getMaxValue(FieldDensityMap.PLOW_LEVEL) |
54 | local limeLevelMaxValue = g_currentMission.fieldGroundSystem:getMaxValue(FieldDensityMap.LIME_LEVEL) |
55 | self.plowLevelMaxValue = plowLevelMaxValue |
56 | self.limeLevelMaxValue = limeLevelMaxValue |
57 | |
58 | _, self.permanentTextSize = getNormalizedScreenValues(0, 28) |
59 | |
60 | return self |
61 | end |
108 | function TourIconsMobile:update(dt) |
109 | if not g_currentMission.missionInfo.isValid and g_server ~= nil and self.initDone == nil and g_currentMission:getIsTourSupported() then |
110 | self.initDone = true |
111 | |
112 | g_currentMission:fadeScreen(-1, 3000, function() |
113 | self.canStart = true |
114 | end, self) |
115 | |
116 | -- prepare fields |
117 | local field = g_fieldManager:getFieldByIndex(2) |
118 | local fruitDesc = g_fruitTypeManager:getFruitTypeByIndex(FruitType.WHEAT) |
119 | for i = 1,table.getn(field.maxFieldStatusPartitions) do |
120 | g_fieldManager:setFieldPartitionStatus(field, field.maxFieldStatusPartitions, i, fruitDesc.index, FieldManager.FIELDSTATE_GROWING, fruitDesc.maxHarvestingGrowthState, 3, true, self.plowLevelMaxValue, 0, self.limeLevelMaxValue) |
121 | end |
122 | |
123 | local field = g_fieldManager:getFieldByIndex(1) |
124 | local fruitDesc = g_fruitTypeManager:getFruitTypeByIndex(FruitType.CANOLA) |
125 | for i = 1,table.getn(field.maxFieldStatusPartitions) do |
126 | g_fieldManager:setFieldPartitionStatus(field, field.maxFieldStatusPartitions, i, fruitDesc.index, FieldManager.FIELDSTATE_HARVESTED, 0, 0, false, self.plowLevelMaxValue, 0, self.limeLevelMaxValue) |
127 | end |
128 | |
129 | local field = g_fieldManager:getFieldByIndex(3) |
130 | for i = 1,table.getn(field.maxFieldStatusPartitions) do |
131 | g_fieldManager:setFieldPartitionStatus(field, field.maxFieldStatusPartitions, i, nil, FieldManager.FIELDSTATE_CULTIVATED, 0, 0, false, self.plowLevelMaxValue, 0, self.limeLevelMaxValue) |
132 | end |
133 | end |
134 | |
135 | if self.startTourDialog and self.canStart then |
136 | self.startTourDialogDelay = self.startTourDialogDelay - dt |
137 | if self.startTourDialogDelay < 0 then |
138 | self.startTourDialog = false |
139 | self:showTourDialog() |
140 | end |
141 | end |
142 | |
143 | -- Delay messages always when UI is visible |
144 | if g_gui:getIsGuiVisible() then |
145 | return |
146 | elseif self.queuedMessage ~= nil then |
147 | -- Show queued message and try again next frame |
148 | g_currentMission.hud.ingameMap:toggleSize(IngameMapMobile.STATE_HIDDEN, true) |
149 | g_gui:showInfoDialog(self.queuedMessage) |
150 | self.queuedMessage = nil |
151 | return |
152 | end |
153 | |
154 | if self.isPaused then |
155 | if self.pauseTime > 0 then |
156 | self.pauseTime = self.pauseTime - dt |
157 | else |
158 | self.pauseTime = 0 |
159 | self.isPaused = false |
160 | self:activateNextIcon() |
161 | end |
162 | end |
163 | |
164 | if self.visible and not self.isPaused then |
165 | --# harvesting |
166 | |
167 | -- wait for player to activate the cutter |
168 | if self.currentTourIconNumber == 2 then |
169 | if g_currentMission.controlledVehicle ~= nil and g_currentMission.controlledVehicle == g_currentMission.tourVehicles["tourCombine"] then |
170 | if g_currentMission.tourVehicles["tourCombine"]:getActionControllerDirection() < 0 then |
171 | self.pauseTime = 2000 |
172 | self.isPaused = true |
173 | end |
174 | end |
175 | |
176 | -- wait for player to activate the helper |
177 | elseif self.currentTourIconNumber == 4 then |
178 | if g_currentMission.tourVehicles["tourCombine"]:getIsTurnedOn() and g_currentMission.tourVehicles["tourCombine"]:getIsAIActive() then |
179 | self.pauseTime = 1000 |
180 | self.isPaused = true |
181 | end |
182 | |
183 | --# cultivating |
184 | |
185 | -- wait for player to enter tractor1 and attach cultivator |
186 | elseif self.currentTourIconNumber == 5 then |
187 | if g_currentMission.controlledVehicle ~= nil and g_currentMission.controlledVehicle == g_currentMission.tourVehicles["tourTractor1"] then |
188 | self.pauseTime = 1000 |
189 | self.isPaused = true |
190 | end |
191 | |
192 | elseif self.currentTourIconNumber == 6 then |
193 | if g_currentMission.controlledVehicle ~= nil and g_currentMission.controlledVehicle == g_currentMission.tourVehicles["tourTractor1"] then |
194 | if g_currentMission.tourVehicles["tourTractor1"]:getActionControllerDirection() < 0 then |
195 | self.pauseTime = 1000 |
196 | self.isPaused = true |
197 | end |
198 | end |
199 | |
200 | --# sowing |
201 | |
202 | -- wait for player to enter tractor2 and attach sowingMachine |
203 | elseif self.currentTourIconNumber == 8 then |
204 | if g_currentMission.controlledVehicle ~= nil and g_currentMission.controlledVehicle == g_currentMission.tourVehicles["tourTractor2"] then |
205 | self.pauseTime = 1000 |
206 | self.isPaused = true |
207 | end |
208 | |
209 | elseif self.currentTourIconNumber == 9 then |
210 | if g_currentMission.controlledVehicle ~= nil and g_currentMission.controlledVehicle == g_currentMission.tourVehicles["tourTractor2"] then |
211 | if g_currentMission.tourVehicles["tourSowingMachine"].rootVehicle == g_currentMission.tourVehicles["tourTractor2"] then |
212 | self.pauseTime = 1000 |
213 | self.isPaused = true |
214 | end |
215 | end |
216 | |
217 | --# overloading / tipping |
218 | |
219 | -- wait for player to enter tractor2 |
220 | elseif self.currentTourIconNumber == 11 then |
221 | if g_currentMission.controlledVehicle ~= nil and g_currentMission.controlledVehicle == g_currentMission.tourVehicles["tourTractor1"] then |
222 | self.pauseTime = 1000 |
223 | self.isPaused = true |
224 | end |
225 | |
226 | elseif self.currentTourIconNumber == 13 then |
227 | if g_currentMission.tourVehicles["tourCultivator"].rootVehicle == g_currentMission.tourVehicles["tourCultivator"] then |
228 | self.pauseTime = 1000 |
229 | self.isPaused = true |
230 | end |
231 | |
232 | elseif self.currentTourIconNumber == 14 then |
233 | if g_currentMission.controlledVehicle ~= nil and g_currentMission.controlledVehicle == g_currentMission.tourVehicles["tourTractor1"] then |
234 | if g_currentMission.tourVehicles["tourTrailer"].rootVehicle == g_currentMission.tourVehicles["tourTractor1"] then |
235 | self.pauseTime = 1000 |
236 | self.isPaused = true |
237 | end |
238 | end |
239 | |
240 | elseif self.currentTourIconNumber == 15 then |
241 | if g_currentMission.controlledVehicle ~= nil and g_currentMission.controlledVehicle == g_currentMission.tourVehicles["tourTractor1"] then |
242 | if g_currentMission.tourVehicles["tourTrailer"]:getFillUnitFillLevel(1) > 800 then |
243 | self.pauseTime = 1000 |
244 | self.isPaused = true |
245 | end |
246 | end |
247 | |
248 | elseif self.currentTourIconNumber == 17 then |
249 | if g_currentMission.controlledVehicle ~= nil and g_currentMission.controlledVehicle == g_currentMission.tourVehicles["tourTractor1"] then |
250 | if g_currentMission.tourVehicles["tourTrailer"]:getFillUnitFillLevel(1) <= 2 then |
251 | self.pauseTime = 1000 |
252 | self.isPaused = true |
253 | end |
254 | end |
255 | end |
256 | end |
257 | end |