Best Python code snippet using yandex-tank
story_ant.py
Source:story_ant.py
...136 # Outdoors137 #########################138 def create_outdoors_state_graph(self):139 s = self.rootState.create_successor("Init")140 s.add_action(bat.story.ActConstraintSet("Hand.L", "Copy Transforms", 1.0))141 s.add_action(bat.story.ActAction('Ant_Digging1', 1, 42, Ant.L_ANIM,142 play_mode=bge.logic.KX_ACTION_MODE_LOOP))143 sKnock = s.create_sub_step("Knock sound")144 sKnock.add_condition(bat.story.CondActionGE(Ant.L_ANIM, 34.5, tap=True))145 sKnock.add_action(self.knock_sound_action)146 senter_start, _ = self.create_enter_states()147 senter_start.add_predecessor(s)148 sconv_start, sconv_end = self.create_conversation()149 sconv_start.add_predecessor(s)150 # Create a super state to catch when the player leaves. Can't have one151 # for canceling dialogue, because that would catch any dialogue152 # elsewhere in the level.153 self.super_state = bat.story.State('Super')154 s_leave = self.super_state.create_successor('Leave')155 s_leave.add_condition(bat.story.CondEvent('LeaveAnt', self))156 #157 # Loop back to start.158 #159 s = bat.story.State("Reset")160 s.add_predecessor(sconv_end)161 s.add_predecessor(s_leave)162 s.add_action(Scripts.story.ActResumeInput())163 s.add_action(Scripts.story.ActRemoveCamera('AntCloseCam'))164 s.add_action(Scripts.story.ActRemoveCamera('AntCrackCam'))165 s.add_action(Scripts.story.ActRemoveCamera('AntCrackCamIn'))166 s.add_action(Scripts.story.ActRemoveCamera('AntMidCam'))167 s.add_action(Scripts.story.ActRemoveFocalPoint('Ant'))168 s.add_action(bat.story.ActActionStop(Ant.L_IDLE))169 s.add_successor(self.rootState)170 def create_conversation(self):171 '''172 State graph that plays when Cargo approaches the ant at the tree door.173 '''174 s = sconv_start = bat.story.State("Talk")175 s.add_condition(Scripts.story.CondNotInShell())176 s.add_condition(bat.story.CondEvent("ApproachAnt", self))177 s.add_action(Scripts.story.ActSuspendInput())178 s.add_event("StartLoading", self)179 # Catch-many state for when the user cancels a dialogue. Should only be180 # allowed if the conversation has been played once already.181 scancel = bat.story.State("Cancel")182 scancel.add_condition(bat.story.CondEvent('DialogueCancelled', self))183 scancel.add_condition(bat.story.CondStore('/game/level/antConversation1', True, default=False))184 # Start conversation185 s = s.create_successor()186 s.add_condition(bat.story.CondNextFrame())187 s.add_condition(bat.story.CondWait(0.5))188 s.add_event("FinishLoading", self)189 s.add_action(Scripts.story.ActSetFocalPoint('Ant'))190 s.add_action(Scripts.story.ActSetCamera('AntCloseCam'))191 s.add_event("TeleportSnail", "HP_SnailTalkPos")192 # Reset camera pos193 s.add_action(bat.story.ActAction('HP_AntConverse_Cam', 1, 1, 0, ob='AntCloseCam'))194 s.add_action(bat.story.ActAction('HP_AntCrackCam', 1, 1, 0, ob='AntCrackCam'))195 sKnock = s.create_sub_step("Knock sound")196 sKnock.add_condition(bat.story.CondActionGE(Ant.L_ANIM, 34.5, tap=True))197 sKnock.add_action(self.knock_sound_action)198 # Raises head, takes deep breath199 s = s.create_successor()200 s.add_condition(bat.story.CondWait(2))201 s.add_condition(bat.story.CondActionGE(Ant.L_ANIM, 38))202 s.add_action(bat.story.ActAction('HP_AntConverse', 30, 70, Ant.L_IDLE,203 play_mode=bge.logic.KX_ACTION_MODE_LOOP))204 s.add_action(bat.story.ActAction('HP_AntConverse', 1, 30, Ant.L_ANIM))205 s = s.create_successor()206 s.add_condition(bat.story.CondActionGE(Ant.L_ANIM, 20))207 s.add_event("ShowDialogue", "Mmmm, smell that?")208 s.add_action(bat.story.ActSound('//Sound/ant.question.ogg'))209 # Gestures fiercely at Cargo210 scancel.add_predecessor(s)211 s = s.create_successor()212 s.add_condition(bat.story.CondEvent("DialogueDismissed", self))213 s.add_action(bat.story.ActGeneric(self.drop_pick))214 s.add_event("ShowDialogue", "Doesn't it smell amazing? So sweet! So sugary!")215 s.add_action(bat.story.ActSound('//Sound/ant.outrage.ogg'))216 s.add_action(bat.story.ActAction('HP_AntConverse', 90, 93, Ant.L_IDLE,217 play_mode=bge.logic.KX_ACTION_MODE_LOOP, blendin=5.0))218 s.add_action(bat.story.ActAction('HP_AntConverse', 70, 90, Ant.L_ANIM, blendin=5.0))219 s.add_action(bat.story.ActAction('HP_AntConverse_Cam', 70, 90, 0, ob='AntCloseCam'))220 sdrop_pick = s.create_sub_step("Adjust influence")221 sdrop_pick.add_action(bat.story.ActConstraintFade("Hand.L", "Copy Transforms",222 1.0, 0.0, 70.0, 76.0, Ant.L_ANIM))223 # Step sounds224 sstep = s.create_sub_step()225 sstep.add_condition(bat.story.CondActionGE(Ant.L_ANIM, 76, tap=True))226 sstep.add_action(self.step_sound_action)227 sstep = s.create_sub_step()228 sstep.add_condition(bat.story.CondActionGE(Ant.L_ANIM, 82, tap=True))229 sstep.add_action(self.step_sound_action)230 # Holds fists tight; then, gestures towards the tree231 scancel.add_predecessor(s)232 s = s.create_successor()233 s.add_condition(bat.story.CondEvent("DialogueDismissed", self))234 s.add_action(bat.story.ActActionStop(Ant.L_IDLE))235 s.add_action(bat.story.ActAction('HP_AntConverse', 95, 160, Ant.L_ANIM, blendin=2.0))236 s.add_event("ShowDialogue", "I've got to have it! But this wood is just too strong,")237# s.add_action(bat.story.ActSound('//Sound/ant.mutter3.ogg'))238 sswitch_cam = s.create_sub_step("Switch camera")239 sswitch_cam.add_condition(bat.story.CondActionGE(Ant.L_ANIM, 126, tap=True))240 sswitch_cam.add_action(Scripts.story.ActSetCamera('AntCrackCam'))241 sswitch_cam.add_action(bat.story.ActAction('HP_AntCrackCam', 140, 360, 0,242 ob='AntCrackCam'))243 sloop = s.create_sub_step("Loop")244 sloop.add_condition(bat.story.CondActionGE(Ant.L_ANIM, 160, tap=True))245 sloop.add_action(bat.story.ActAction('HP_AntConverse', 160, 230, Ant.L_IDLE,246 play_mode=bge.logic.KX_ACTION_MODE_LOOP, blendin=2.0))247 # Sizes up door with hands in front of his eyes248 scancel.add_predecessor(s)249 s = s.create_successor()250 s.add_condition(bat.story.CondEvent("DialogueDismissed", self))251 s.add_condition(bat.story.CondActionGE(Ant.L_ANIM, 140))252 s.add_event("ShowDialogue", "... and this crack is too small, even for me.")253# s.add_action(bat.story.ActSound('//Sound/ant.mutter2.ogg'))254 s.add_action(bat.story.ActAction('HP_AntConverse', 240, 255, Ant.L_ANIM, blendin=2.0))255 s.add_action(Scripts.story.ActRemoveCamera('AntCrackCam'))256 s.add_action(Scripts.story.ActSetCamera('AntCrackCamIn'))257 sloop = s.create_sub_step("Loop")258 sloop.add_condition(bat.story.CondActionGE(Ant.L_ANIM, 255, tap=True))259 sloop.add_action(bat.story.ActAction('HP_AntConverse', 255, 283, Ant.L_IDLE,260 play_mode=bge.logic.KX_ACTION_MODE_LOOP, blendin=2.0))261 # Step sounds262 sstep = s.create_sub_step()263 sstep.add_condition(bat.story.CondActionGE(Ant.L_ANIM, 245, tap=True))264 sstep.add_action(self.step_sound_action)265 sstep = s.create_sub_step()266 sstep.add_condition(bat.story.CondActionGE(Ant.L_ANIM, 248, tap=True))267 sstep.add_action(self.step_sound_action)268 sstep = s.create_sub_step()269 sstep.add_condition(bat.story.CondActionGE(Ant.L_ANIM, 267, tap=True))270 sstep.add_action(self.step_sound_action)271 sstep = s.create_sub_step()272 sstep.add_condition(bat.story.CondActionGE(Ant.L_ANIM, 272, tap=True))273 sstep.add_action(self.step_sound_action)274 # Pauses to consider275 scancel.add_predecessor(s)276 s = s.create_successor()277 s.add_condition(bat.story.CondEvent("DialogueDismissed", self))278 s.add_event("ShowDialogue", "If only I had something stronger...")279 s.add_action(bat.story.ActSound('//Sound/ant.mutter1.ogg'))280 s.add_action(bat.story.ActAction('HP_AntConverse', 290, 300, Ant.L_ANIM, blendin=1.0))281 s.add_action(Scripts.story.ActRemoveCamera('AntCrackCamIn'))282 s.add_action(Scripts.story.ActSetCamera('AntCloseCam'))283 sloop = s.create_sub_step("Loop")284 sloop.add_condition(bat.story.CondActionGE(Ant.L_ANIM, 300, tap=True))285 sloop.add_action(bat.story.ActAction('HP_AntConverse', 300, 347, Ant.L_IDLE,286 play_mode=bge.logic.KX_ACTION_MODE_LOOP, blendin=2.0))287 # Picks up mattock, and glares at the door288 scancel.add_predecessor(s)289 s = s.create_successor()290 s.add_condition(bat.story.CondEvent("DialogueDismissed", self))291 s.add_condition(bat.story.CondActionGE(Ant.L_ANIM, 300))292 s.add_action(bat.story.ActActionStop(Ant.L_IDLE))293 s.add_action(bat.story.ActAction('HP_AntConverse', 360, 407, Ant.L_ANIM, blendin=1.0))294 s.add_event("ShowDialogue", "But I won't give up!")295# s.add_action(bat.story.ActSound('//Sound/ant.surprise.ogg'))296 sgrab_pickR = s.create_sub_step("Grab pick - right hand")297 sgrab_pickR.add_condition(bat.story.CondActionGE(Ant.L_ANIM, 370.5, tap=True))298 sgrab_pickR.add_action(bat.story.ActGeneric(self.pick_up))299 sgrab_pickL = s.create_sub_step("Grab pick - left hand")300 sgrab_pickL.add_action(bat.story.ActConstraintFade("Hand.L", "Copy Transforms",301 0.0, 1.0, 401.0, 403.0, Ant.L_ANIM))302 sloop = s.create_sub_step("Loop")303 sloop.add_condition(bat.story.CondActionGE(Ant.L_ANIM, 407, tap=True))304 sloop.add_action(bat.story.ActAction('HP_AntConverse', 407, 440, Ant.L_IDLE,305 play_mode=bge.logic.KX_ACTION_MODE_LOOP, blendin=2.0))306 # Step sounds307 sstep = s.create_sub_step()308 sstep.add_condition(bat.story.CondActionGE(Ant.L_ANIM, 367, tap=True))309 sstep.add_action(self.step_sound_action)310 sstep = s.create_sub_step()311 sstep.add_condition(bat.story.CondActionGE(Ant.L_ANIM, 373, tap=True))312 sstep.add_action(self.step_sound_action)313 sstep = s.create_sub_step()314 sstep.add_condition(bat.story.CondActionGE(Ant.L_ANIM, 392, tap=True))315 sstep.add_action(self.step_sound_action)316 # Play the first bit of the digging animation317 scancel.add_predecessor(s)318 s = s.create_successor()319 s.add_condition(bat.story.CondEvent("DialogueDismissed", self))320 s.add_condition(bat.story.CondActionGE(Ant.L_ANIM, 407))321 s.add_action(bat.story.ActAction('HP_AntConverse', 440, 470, Ant.L_ANIM, blendin=1.0))322 s.add_action(bat.story.ActActionStop(Ant.L_IDLE))323 s.add_action(bat.story.ActConstraintSet("Hand.L", "Copy Transforms", 1.0))324 sKnock = s.create_sub_step("Knock sound")325 sKnock.add_condition(bat.story.CondActionGE(Ant.L_ANIM, 466.5, tap=True))326 sKnock.add_action(self.knock_sound_action)327 # Step sounds328 sstep = s.create_sub_step()329 sstep.add_condition(bat.story.CondActionGE(Ant.L_ANIM, 443, tap=True))330 sstep.add_action(self.step_sound_action)331 sstep = s.create_sub_step()332 sstep.add_condition(bat.story.CondActionGE(Ant.L_ANIM, 446, tap=True))333 sstep.add_action(self.step_sound_action)334 s = s.create_successor()335 s.add_condition(bat.story.CondActionGE(Ant.L_ANIM, 470))336 s.add_action(bat.story.ActStoreSet('/game/level/antConversation1', True))337 s = sconv_end = s.create_successor()338 s.add_predecessor(scancel)339 return sconv_start, sconv_end340 def create_enter_states(self):341 '''State graph that plays when the tree door is broken.'''342 s = senter_start = bat.story.State("Enter start")343 s.add_condition(bat.story.CondEvent("treeDoorBroken", self))344 s.add_action(Scripts.story.ActSetCamera('AntMidCam'))345 s.add_action(Scripts.story.ActSetFocalPoint('Ant'))346 s.add_action(Scripts.story.ActSuspendInput())347 s.add_action(bat.story.ActAction('HP_AntEnter', 1, 40,348 Ant.L_ANIM, blendin=1.0))349 s.add_action(bat.story.ActDestroy(target_descendant='Ant_Pick'))350 sdrop_pick = s.create_sub_step("Adjust influence")351 sdrop_pick.add_action(bat.story.ActConstraintFade("Hand.L",352 "Copy Transforms", 1.0, 0.0, 1.0, 4.0, Ant.L_ANIM))353 s = s.create_successor()354 s.add_condition(bat.story.CondActionGE(Ant.L_ANIM, 25))355 s.add_action(Scripts.story.ActSetCamera('AntVictoryCam'))356 s.add_event("ShowDialogue", "Amazing! You've done it!")357 s.add_action(bat.story.ActSound('//Sound/ant.outrage.ogg'))358 s.add_event("TeleportSnail", "HP_SnailTalkPos")359 sbreathe = s.create_sub_step()360 sbreathe.add_condition(bat.story.CondActionGE(Ant.L_ANIM, 40, tap=True))361 sbreathe.add_action(bat.story.ActAction('HP_AntEnter', 40, 80, Ant.L_ANIM,362 play_mode=bge.logic.KX_ACTION_MODE_LOOP))363 s = s.create_successor()364 s.add_condition(bat.story.CondActionGE(Ant.L_ANIM, 40))365 s.add_condition(bat.story.CondEvent("DialogueDismissed", self))366 s.add_action(Scripts.story.ActSetCamera('AntSniffCam'))367 s.add_event("ShowDialogue", "And look, it's just as I suspected - sugary syrup!")368# s.add_action(bat.story.ActSound('//Sound/ant.mutter1.ogg'))369 s.add_action(bat.story.ActAction('HP_AntEnter', 80, 100, Ant.L_ANIM,370 blendin=3.0))371 ssniff = s.create_sub_step("Sniff")372 ssniff.add_condition(bat.story.CondActionGE(Ant.L_ANIM, 100, tap=True))373 ssniff.add_action(bat.story.ActAction('HP_AntEnter', 100, 132, Ant.L_ANIM,374 play_mode=bge.logic.KX_ACTION_MODE_LOOP))375 s = s.create_successor()376 s.add_condition(bat.story.CondActionGE(Ant.L_ANIM, 100))377 s.add_condition(bat.story.CondEvent("DialogueDismissed", self))378 s.add_event("ShowDialogue", "Let's find the source. Last one up the tree is a rotten egg!")379 s.add_action(bat.story.ActSound('//Sound/ant.gratitude.ogg'))380 s.add_action(bat.story.ActAction('HP_AntEnter', 132, 153, Ant.L_ANIM,381 blendin=3.0))382 slook = s.create_sub_step("look")383 slook.add_condition(bat.story.CondActionGE(Ant.L_ANIM, 153, tap=True))384 slook.add_action(bat.story.ActAction('HP_AntEnter', 153, 188, Ant.L_ANIM,385 play_mode=bge.logic.KX_ACTION_MODE_LOOP))386 s = s.create_successor()387 s.add_condition(bat.story.CondEvent("DialogueDismissed", self))388 s.add_action(bat.story.ActAction('HP_AntEnter', 188, 230, Ant.L_ANIM,389 blendin=3.0))390 s = senter_end = s.create_successor()391 s.add_condition(bat.story.CondActionGE(Ant.L_ANIM, 230))392 s.add_action(Scripts.story.ActRemoveCamera('AntSniffCam'))393 s.add_action(Scripts.story.ActRemoveCamera('AntVictoryCam'))394 s.add_action(Scripts.story.ActRemoveCamera('AntMidCam'))395 s.add_action(Scripts.story.ActResumeInput())396 s.add_action(bat.story.ActDestroy(ob='Honeypot'))397 s.add_action(bat.story.ActDestroy())398 return senter_start, senter_end399 #########################400 # Dungeon401 #########################402 def create_dungeon_state_graph(self):403 s = self.rootState.create_successor("Init")404 # Hide ant first thing405 s.add_action(bat.story.ActAttrSet('visible', False, target_descendant="Ant_Body"))406 s.add_action(bat.story.ActAttrSet('visible', False, target_descendant="Ant_Pick"))407 # Pick was left outside.408 s.add_action(bat.story.ActConstraintSet("Hand.L", "Copy Transforms", 0))409 s.add_action(bat.story.ActAction('Ant_Idle', 1, 80, Ant.L_IDLE,410 play_mode=bge.logic.KX_ACTION_MODE_LOOP))411 srescue_start, srescue_end = self.create_rescue_states()412 srescue_start.add_predecessor(s)413 sstranded_start, sstranded_end = self.create_stranded_states()414 sstranded_start.add_predecessor(s)415 sgrab_start, sgrab_end = self.create_grab_states()416 sgrab_start.add_predecessor(s)417 # Create a super state to catch when the player leaves. Can't have one418 # for canceling dialogue, because that would catch any dialogue419 # elsewhere in the level.420 self.super_state = bat.story.State('Super')421 s_leave = self.super_state.create_successor('Leave')422 s_leave.add_condition(bat.story.CondEvent('LeaveAnt', self))423 #424 # Loop back to start.425 #426 s = self.s_reset = bat.story.State("Reset")427 s.add_predecessor(s_leave)428 s.add_predecessor(sgrab_end)429 s.add_predecessor(srescue_end)430 s.add_predecessor(sstranded_end)431 s.add_action(Scripts.story.ActResumeInput())432 s.add_action(Scripts.story.ActRemoveCamera('WindowCam'))433 s.add_action(Scripts.story.ActRemoveCamera('AntGrabCam'))434 s.add_action(Scripts.story.ActRemoveFocalPoint('Ant'))435 s.add_action(bat.story.ActActionStop(Ant.L_IDLE))436 s.add_successor(self.rootState)437 def create_grab_states(self):438 #439 # Non-interactive cut-scene: the camera dollys through a window to show440 # the machine room. A bucket rises from the lower level. It is grabbed441 # by the Ant, who pulls it away from the rubber band it is attached to.442 # The force knocks the ant off the ledge and out of view.443 #444 s = s_start = bat.story.State("Grab")445 s.add_condition(bat.story.CondStore('/game/level/AntStranded', False, False))446 s = s.create_successor()447 s.add_condition(bat.story.CondEvent("ApproachWindow", self))448 s.add_action(Scripts.story.ActSuspendInput())449 s.add_action(bat.story.ActAddObject('Thimble_ant'))450 s.add_event('ParkBuckets')451 s.add_event('ForceExitShell')452 s_fra = 855453 e_fra = 1020454 s = s.create_successor()455 s.add_action(Scripts.story.ActSetCamera('WindowCam'))456 s.add_action(Scripts.story.ActSetFocalPoint('Ant'))457 s.add_action(bat.story.ActAttrSet('visible', True, target_descendant="Ant_Body"))458 s.add_action(bat.story.ActAction('Ant_GetThimble', s_fra, e_fra, Ant.L_ANIM))459 s.add_action(bat.story.ActAction('WindowCam', s_fra, e_fra, ob='WindowCam'))460 s.add_action(bat.story.ActAction('AntGrabCam', s_fra, e_fra, ob='AntGrabCam'))461 s.add_action(bat.story.ActAction('RubberBandPluck', s_fra, e_fra, ob='RubberBand_upper'))462 s.add_action(bat.story.ActAction('Thimble_ant_grab', s_fra, e_fra, ob='Thimble_ant'))463 s = s.create_successor()464 s.add_condition(bat.story.CondActionGE(Ant.L_ANIM, 935))465 s.add_action(Scripts.story.ActSetCamera('AntGrabCam'))466 s = s.create_successor()467 s.add_condition(bat.story.CondActionGE(Ant.L_ANIM, 977))468 s.add_action(self.step_sound_action)469 s = s.create_successor()470 s.add_condition(bat.story.CondActionGE(Ant.L_ANIM, 986))471 s.add_action(bat.story.ActSound('//Sound/cc-by/RubberBandTwang.ogg'))472 s = s.create_successor()473 s.add_condition(bat.story.CondActionGE(Ant.L_ANIM, 1020))474 s = s.create_successor()475 s.add_condition(bat.story.CondWait(1))476 s.add_action(bat.story.ActDestroy(ob='Thimble_ant'))477 s.add_action(Scripts.story.ActRemoveCamera('WindowCam'))478 s.add_action(Scripts.story.ActRemoveCamera('WindowCam.001'))479 s.add_action(Scripts.story.ActRemoveCamera('AntGrabCam'))480 s.add_action(Scripts.story.ActRemoveFocalPoint('Ant'))481 # Start the buckets again, and set saved game state. When story state482 # loops, create_stranded_states will be executed instead.483 s = s_end = s.create_successor()484 s.add_event('StartBuckets')485 s.add_action(bat.story.ActStoreSet('/game/level/AntStranded', True))486 s.add_action(bat.story.ActStoreSet('/game/storySummary', 'AntStranded'))487 return s_start, s_end488 def create_stranded_states(self):489 s = s_start = bat.story.State("Stranded")490 s.add_condition(bat.story.CondStore('/game/level/AntStranded', True, False))491 s = s.create_successor('Strand ant')492 s.add_action(bat.story.ActAttrSet('visible', True, target_descendant="Ant_Body"))493 s.add_action(bat.story.ActAction('Ant_Stranded', 1, 1, Ant.L_ANIM))494 s.add_event('SpawnShell', 'Thimble')495 s = s.create_successor()496 s.add_condition(bat.story.CondEvent("ApproachAnt", self))497 s.add_action(Scripts.story.ActSuspendInput())498 s.add_event("StartLoading", self)499 s.add_action(bat.story.ActAction('AntStrandedCamLS_FrontAction', 1, 1, ob='AntStrandedCamLS_Front'))500 s = s.create_successor()501 s.add_condition(bat.story.CondWait(1))502 s.add_action(Scripts.story.ActSetFocalPoint('Ant'))503 s.add_event("TeleportSnail", "AntStranded_SnailTalkPos")504 s.add_action(Scripts.story.ActSetCamera('AntStrandedCamLS_Front'))505 s.add_event("FinishLoading", self)506 s = s.create_successor()507 s.add_condition(bat.story.CondWait(1))508 s.add_event("ShowDialogue", "Cargo! Am I glad to see you!")509 s.add_action(bat.story.ActSound('//Sound/ant.greeting.ogg'))510 s.add_action(bat.story.ActAction('Ant_Stranded', 1, 22, Ant.L_ANIM))511 s = s.create_successor()512 s.add_condition(bat.story.CondEvent("DialogueDismissed", self))513 s.add_event("ShowDialogue", "This is a bit embarrassing, but I fell down, and now I'm stuck.")514 s.add_action(bat.story.ActAction('Ant_Stranded', 30, 70, Ant.L_ANIM))515 s = s.create_successor()516 s.add_condition(bat.story.CondEvent("DialogueDismissed", self))517 s.add_event("ShowDialogue", "I was obsessed with the honey. I couldn't stop eating it.")518 s.add_action(bat.story.ActSound('//Sound/ant.mutter2.ogg'))519 s.add_action(bat.story.ActAction('Ant_Stranded', 90, 120, Ant.L_ANIM))520 s.add_action(bat.story.ActAction('AntStrandedCamLS_FrontAction', 90, 140, ob='AntStrandedCamLS_Front'))521 sub = s.create_sub_step()522 sub.add_condition(bat.story.CondActionGE(Ant.L_ANIM, 103, tap=True))523 sub.add_action(self.step_sound_action)524 s = s.create_successor()525 s.add_condition(bat.story.CondEvent("DialogueDismissed", self))526 s.add_action(bat.story.ActAction('Ant_Stranded', 150, 180, Ant.L_ANIM))527 s.add_event("ShowDialogue", "Then I thought, I should take some home to my family, you know?")528 s = s.create_successor()529 s.add_condition(bat.story.CondEvent("DialogueDismissed", self))530 s.add_action(Scripts.story.ActSetFocalPoint('Thimble'))531 s.add_event("ShowDialogue", "I took this thimble to use as a bucket...")532 s.add_action(bat.story.ActSound('//Sound/ant.mutter1.ogg'))533 s.add_action(bat.story.ActAction('Ant_Stranded', 200, 225, Ant.L_ANIM))534 s.add_action(Scripts.story.ActSetCamera('AntStrandedCamLS_FrontZoom'))535 s.add_action(bat.story.ActAction('AntStrandedCamLS_FrontAction', 200, 250, ob='AntStrandedCamLS_Front'))536 sub = s.create_sub_step()537 sub.add_condition(bat.story.CondActionGE(Ant.L_ANIM, 207, tap=True))538 sub.add_action(self.step_sound_action)539 sub = s.create_sub_step()540 sub.add_condition(bat.story.CondActionGE(Ant.L_ANIM, 212, tap=True))541 sub.add_action(self.step_sound_action)542 sub = s.create_sub_step()543 sub.add_condition(bat.story.CondActionGE(Ant.L_ANIM, 219, tap=True))544 sub.add_action(self.step_sound_action)545 s = s.create_successor()546 s.add_condition(bat.story.CondEvent("DialogueDismissed", self))547 s.add_action(Scripts.story.ActSetCamera('AntStrandedCamLS'))548 s.add_event("ShowDialogue", "... I feel like such a fool.")549 s = s.create_successor()550 s.add_condition(bat.story.CondEvent("DialogueDismissed", self))551 s.add_action(Scripts.story.ActRemoveFocalPoint('Thimble'))552 s.add_event("ShowDialogue", "I can't walk through the honey: it's too sticky.")553 s.add_action(bat.story.ActAction('AntStrandedCamLS_FrontAction', 90, 90, ob='AntStrandedCamLS_FrontZoom'))554 s = s.create_successor()555 s.add_condition(bat.story.CondEvent("DialogueDismissed", self))556 s.add_action(Scripts.story.ActRemoveCamera('AntStrandedCamLS'))557 s.add_event("ShowDialogue", "But I bet you could do it. Please, help me out!")558 s.add_action(bat.story.ActSound('//Sound/ant.outrage.ogg'))559 s.add_action(bat.story.ActAction('Ant_Stranded', 260, 300, Ant.L_ANIM))560 sub = s.create_sub_step()561 sub.add_condition(bat.story.CondActionGE(Ant.L_ANIM, 283, tap=True))562 sub.add_action(self.step_sound_action)563 sub = s.create_sub_step()564 sub.add_condition(bat.story.CondActionGE(Ant.L_ANIM, 292, tap=True))565 sub.add_action(self.step_sound_action)566 sub = s.create_sub_step()567 sub.add_condition(bat.story.CondActionGE(Ant.L_ANIM, 298, tap=True))568 sub.add_action(self.step_sound_action)569 s = s.create_successor()570 s.add_condition(bat.story.CondEvent("DialogueDismissed", self))571 s.add_action(Scripts.story.ActRemoveCamera('AntStrandedCamLS_FrontZoom'))572 s.add_action(Scripts.story.ActRemoveCamera('AntStrandedCamLS_Front'))573 s.add_action(Scripts.story.ActRemoveCamera('AntStrandedCamLS'))574 s.add_action(Scripts.story.ActRemoveFocalPoint('Thimble'))575 s.add_action(Scripts.story.ActRemoveFocalPoint('Ant'))576 s.add_action(Scripts.story.ActResumeInput())577 # Player is free to move around now. If they go outside of the sensor,578 # the global state will notice and reset.579 s = s.create_successor("BeingRescued")580 s.add_condition(bat.story.CondEventEq("ShellFound", "Thimble", self))581 s = s.create_successor()582 s.add_condition(bat.story.CondWait(0.5))583 s.add_action(Scripts.story.ActSuspendInput())584 s.add_event("ShowDialogue", "You got the Thimble! It's impervious to sharp objects.")585 s = s.create_successor()586 s.add_condition(bat.story.CondEvent("DialogueDismissed", self))587 s.add_action(Scripts.story.ActSetCamera('AntStrandedCamLS_Front'))588 s.add_action(Scripts.story.ActSetFocalPoint('Ant'))589 s.add_event("ShowDialogue", "Hey, nice work! I'll jump on. Thanks a million!")590 s.add_action(bat.story.ActSound('//Sound/ant.graditude.ogg'))591 s.add_action(bat.story.ActAction('Ant_Stranded', 320, 340, Ant.L_ANIM))592 sub = s.create_sub_step()593 sub.add_condition(bat.story.CondActionGE(Ant.L_ANIM, 325, tap=True))594 sub.add_action(self.step_sound_action)595 sub = s.create_sub_step()596 sub.add_condition(bat.story.CondActionGE(Ant.L_ANIM, 329, tap=True))597 sub.add_action(self.step_sound_action)598 sub = s.create_sub_step()599 sub.add_condition(bat.story.CondActionGE(Ant.L_ANIM, 333, tap=True))600 sub.add_action(self.step_sound_action)601 # No animation here; just show the loading screen and teleport ant on to602 # thimble.603 s = s.create_successor()604 s.add_condition(bat.story.CondEvent("DialogueDismissed", self))605 s.add_event("StartLoading", self)606 s = s.create_successor()607 s.add_condition(bat.story.CondWait(1))608 s.add_action(bat.story.ActAction('Ant_SitOnThimble', 1, 1, Ant.L_ANIM))609 s.add_action(bat.story.ActCopyTransform("Thimble"))610 s.add_action(bat.story.ActParentSet("Thimble"))611 s.add_action(Scripts.story.ActRemoveFocalPoint('Ant'))612 s = s.create_successor()613 s.add_condition(bat.story.CondNextFrame())614 s.add_event("FinishLoading", self)615 s.add_action(bat.story.ActStoreSet('/game/storySummary', 'gotThimble'))616 s.add_action(Scripts.story.ActRemoveCamera('AntStrandedCamLS_Front'))617 s.add_action(Scripts.story.ActResumeInput())618 s.add_action(bat.story.ActGeneric(self.prevent_shell_actions))619 # Player is free to move around now. Here, we override the super state620 # transition which watches for the LeaveAnt event.621 s = s.create_successor('Carried ant over honey')622 s.add_condition(bat.story.CondEvent('ReachShore', self))623 s.add_action(bat.story.ActGeneric(self.allow_shell_actions))624 s.add_action(Scripts.story.ActSuspendInput())625 s.add_event("StartLoading", self)626 s = s.create_successor()627 s.add_condition(bat.story.CondNextFrame())628 s.add_condition(bat.story.CondEvent("LoadingScreenShown", self))629 s.add_action(bat.story.ActAction('AntStrandedCam_RescueTopAction', 1, 150, ob='AntStrandedCam_RescueTop'))630 s.add_action(Scripts.story.ActSetCamera('AntStrandedCam_RescueTop'))631 s.add_action(Scripts.story.ActSetFocalPoint('Ant'))632 s.add_action(bat.story.ActParentRemove())633 s = s.create_successor()634 s.add_condition(bat.story.CondNextFrame())635 s.add_action(bat.story.ActCopyTransform("AntSpawnPoint"))636 s.add_event("TeleportSnail", "AntStranded_SnailTalkPos_rescue")637 s.add_action(bat.story.ActAction('Ant_Rescued', 1, 1, Ant.L_ANIM))638 s = s.create_successor()639 s.add_condition(bat.story.CondNextFrame())640 s.add_event("FinishLoading", self)641 s = s.create_successor()642 s.add_condition(bat.story.CondWait(1))643 s.add_action(bat.story.ActAction('Ant_Rescued', 1, 53, Ant.L_ANIM))644 s.add_event("ShowDialogue", "All right - we made it!")645 s.add_action(bat.story.ActSound('//Sound/ant.mutter1.ogg'))646 s = s.create_successor()647 s.add_condition(bat.story.CondEvent("DialogueDismissed", self))648 s.add_event('ParkBuckets')649 s.add_action(Scripts.story.ActSetCamera('AntStrandedCam_RescueFront'))650 s.add_action(bat.story.ActAction('Ant_Rescued', 78, 151, Ant.L_ANIM))651 s.add_event("ShowDialogue", "I bet that was the strangest delivery you ever made, eh? He-he.")652 s = s.create_successor()653 s.add_condition(bat.story.CondEvent("DialogueDismissed", self))654 s.add_condition(bat.story.CondActionGE(Ant.L_ANIM, 150))655 s.add_action(bat.story.ActAction('Ant_Rescued', 175, 285, Ant.L_ANIM))656 s.add_event("ShowDialogue", "You know, with that thimble you should be able to sneak past the bees if you want to.")657 s = s.create_successor()658 s.add_condition(bat.story.CondEvent("DialogueDismissed", self))659 s.add_condition(bat.story.CondActionGE(Ant.L_ANIM, 285))660 s.add_action(bat.story.ActAction('Ant_Rescued', 313, 373, Ant.L_ANIM))661 s.add_event("ShowDialogue", "There must be another entrance to the hive further up the tree.")662 s.add_action(bat.story.ActAction(663 'AntStrandedCam_RescueFrontAction', 313, 373,664 ob='AntStrandedCam_RescueFront'))665 s = s.create_successor()666 s.add_condition(bat.story.CondEvent("DialogueDismissed", self))667 s.add_condition(bat.story.CondActionGE(Ant.L_ANIM, 370))668 s.add_action(bat.story.ActAction('Ant_Rescued', 398, 523, Ant.L_ANIM))669 s.add_event("ShowDialogue", "Well, I'm going to head outside. I'm looking forward to some fresh air after being stranded!")670 s.add_action(bat.story.ActSound('//Sound/ant.mutter3.ogg'))671 s.add_action(bat.story.ActAction(672 'AntStrandedCam_RescueFrontAction', 398, 555,673 ob='AntStrandedCam_RescueFront'))674 s = s.create_successor()675 s.add_condition(bat.story.CondActionGE(Ant.L_ANIM, 520))676 s.add_condition(bat.story.CondEvent("DialogueDismissed", self))677 s.add_action(bat.story.ActAction('Ant_Rescued', 593, 660, Ant.L_ANIM))678 s.add_action(bat.story.ActStoreSet('/game/level/AntRescued', True))679 sub = s.create_sub_step()680 sub.add_condition(bat.story.CondActionGE(Ant.L_ANIM, 605, tap=True))681 sub.add_action(self.step_sound_action)682 sub = s.create_sub_step()683 sub.add_condition(bat.story.CondActionGE(Ant.L_ANIM, 607, tap=True))684 sub.add_action(self.step_sound_action)685 sub = s.create_sub_step()686 sub.add_condition(bat.story.CondActionGE(Ant.L_ANIM, 611, tap=True))687 sub.add_action(self.step_sound_action)688 sub = s.create_sub_step()689 sub.add_condition(bat.story.CondActionGE(Ant.L_ANIM, 615, tap=True))690 sub.add_action(self.step_sound_action)691 sub = s.create_sub_step()692 sub.add_condition(bat.story.CondActionGE(Ant.L_ANIM, 618, tap=True))693 sub.add_action(self.step_sound_action)694 sub = s.create_sub_step()695 sub.add_condition(bat.story.CondActionGE(Ant.L_ANIM, 621, tap=True))696 sub.add_action(self.step_sound_action)697 sub = s.create_sub_step()698 sub.add_condition(bat.story.CondActionGE(Ant.L_ANIM, 623, tap=True))699 sub.add_action(self.step_sound_action)700 sub = s.create_sub_step()701 sub.add_condition(bat.story.CondActionGE(Ant.L_ANIM, 626, tap=True))702 sub.add_action(self.step_sound_action)703 sub = s.create_sub_step()704 sub.add_condition(bat.story.CondActionGE(Ant.L_ANIM, 103, tap=True))705 sub.add_action(self.step_sound_action)706 sub = s.create_sub_step()707 sub.add_condition(bat.story.CondActionGE(Ant.L_ANIM, 630, tap=True))708 sub.add_action(self.step_sound_action)709 sub = s.create_sub_step()710 sub.add_condition(bat.story.CondActionGE(Ant.L_ANIM, 632, tap=True))711 sub.add_action(self.step_sound_action)712 sub = s.create_sub_step()713 sub.add_condition(bat.story.CondActionGE(Ant.L_ANIM, 636, tap=True))714 sub.add_action(self.step_sound_action)715 s = s.create_successor()716 s.add_condition(bat.story.CondActionGE(Ant.L_ANIM, 660))717 s.add_event('StartBuckets')718 s.add_action(Scripts.story.ActRemoveCamera('AntStrandedCam_RescueFront'))719 s.add_action(Scripts.story.ActRemoveCamera('AntStrandedCam_RescueTop'))720 s.add_action(Scripts.story.ActRemoveFocalPoint('Ant'))721 s.add_action(Scripts.story.ActResumeInput())722 s.add_action(bat.story.ActDestroy())723 s_end = s724 return s_start, s_end725 def create_rescue_states(self):726 # Just destroy the ant: already rescued!727 s = s_start = bat.story.State("Rescued")728 s.add_condition(Scripts.story.CondHasShell('Thimble'))729 s.add_action(bat.story.ActDestroy())730 s = s_end = s.create_successor()731 return s_start, s_end732def test_anim():733 sce = bge.logic.getCurrentScene()734 ant = sce.objects['Ant']735 ant = bat.bats.mutate(ant)...
story_cargo_house.py
Source:story_cargo_house.py
...81 o = c.sensors['sParticleHook'].owner82 o['nParticles'] = o['nParticles'] + number83 o['maxSpeed'] = maxSpeed84 s = self.rootState.create_successor("Init")85 s.add_action(Scripts.story.ActSuspendInput())86 s.add_event("ShowControlsInfo")87 s = s.create_successor("Init")88 s.add_condition(bat.story.CondWait(1))89 s.add_event("ForceEnterShell", False)90 s.add_action(Scripts.story.ActSetCamera('WormCamera_Enter'))91 s.add_action(Scripts.story.ActSetFocalPoint('CargoHoldAuto'))92 s.add_action(bat.story.ActAction('ParticleEmitMove', 1, 1, Worm.L_ANIM, "ParticleEmitterLoc"))93 s.add_action(bat.story.ActGenericContext(letter_manual))94 #95 # Peer out of ground96 #97 s = s.create_successor("Begin")98 s.add_condition(bat.story.CondEvent('ShellEntered', self))99 s.add_event('AnchorShell', 'CH_ShellAnchor')100 s.add_event("FinishLoading", self)101 s.add_action(bat.story.ActGenericContext(spray_dirt, 10, 15.0))102 s.add_action(bat.story.ActAction('BurstOut', 1, 75, Worm.L_ANIM))103 s.add_action(bat.story.ActAction('BurstOut_S', 1, 75, Worm.L_ANIM, 'WormBody'))104 s.add_action(Scripts.story.ActSleepParticles(start=True, scale=1, ob='Shell'))105 s = s.create_successor("Greet")106 s.add_condition(bat.story.CondActionGE(Worm.L_ANIM, 74.0))107 s.add_event("ShowDialogue", "Cargo?")108 s.add_action(bat.story.ActSound('//Sound/WormQuestion1.ogg', vol=1.5))109 #110 # Get out of the ground111 #112 s = s.create_successor("Get out of the ground")113 s.add_condition(bat.story.CondEvent('DialogueDismissed', self))114 s.add_action(Scripts.story.ActRemoveCamera('WormCamera_Enter'))115 s.add_action(Scripts.story.ActSetCamera('WormCamera_Converse'))116 s.add_action(bat.story.ActAction('BurstOut', 75, 186, Worm.L_ANIM))117 s.add_action(bat.story.ActAction('BurstOut_S', 75, 186, Worm.L_ANIM, 'WormBody'))118 s = s.create_successor()119 s.add_condition(bat.story.CondActionGE(Worm.L_ANIM, 115.0))120 s.add_action(bat.story.ActGenericContext(spray_dirt, 3, 10.0))121 s = s.create_successor()122 s.add_condition(bat.story.CondActionGE(Worm.L_ANIM, 147.0))123 s.add_action(bat.story.ActGenericContext(spray_dirt, 5, 10.0))124 s = s.create_successor()125 s.add_condition(bat.story.CondActionGE(Worm.L_ANIM, 153.0))126 s.add_action(bat.story.ActGenericContext(spray_dirt, 5, 10.0))127 #128 # Knock on shell129 #130 s = s.create_successor("Knock on shell")131 s.add_condition(bat.story.CondActionGE(Worm.L_ANIM, 185.0))132 s.add_action(Scripts.story.ActSetCamera('WormCamera_Knock'))133 s.add_event("ShowDialogue", "Wake up, Cargo!")134 s.add_action(bat.story.ActAction('BurstOut', 187, 200, Worm.L_ANIM,135 play_mode=bge.logic.KX_ACTION_MODE_LOOP))136 s.add_action(bat.story.ActAction('BurstOut_S', 187, 200, Worm.L_ANIM, 'WormBody'))137 sKnock = s.create_sub_step("Knock sound")138 sKnock.add_condition(bat.story.CondActionGE(Worm.L_ANIM, 189, tap=True))139 sKnock.add_action(bat.story.ActSound('//Sound/Knock.ogg', vol=0.6, pitchmin=0.8,140 pitchmax= 1.1))141 s = s.create_successor()142 s.add_condition(bat.story.CondEvent('DialogueDismissed', self))143 s.add_condition(bat.story.CondActionGE(Worm.L_ANIM, 199))144 s.add_action(bat.story.ActAction('BurstOut', 200, 220, Worm.L_ANIM))145 s.add_action(bat.story.ActAction('BurstOut_S', 200, 220, Worm.L_ANIM, 'WormBody'))146 s.add_action(bat.story.ActSound('//Sound/Knock.ogg', vol=0.6, pitchmin=0.8,147 pitchmax= 1.1))148 s = s.create_successor()149 s.add_condition(bat.story.CondActionGE(Worm.L_ANIM, 200.0))150 s.add_action(Scripts.story.ActRemoveCamera('WormCamera_Knock'))151 #152 # Wake / chastise153 #154 s = s.create_successor("Wake")155 s.add_condition(bat.story.CondActionGE(Worm.L_ANIM, 205.0))156 s.add_event("ForceExitShell", True)157 s.add_action(Scripts.story.ActSleepParticles(start=False, ob='Shell'))158 s = s.create_successor("Chastise")159 s.add_condition(bat.story.CondEvent('ShellExited', self))160 s.add_event("ShowDialogue", "Sleeping in, eh? Don't worry, I won't tell anyone.")161 s.add_action(bat.story.ActSound('//Sound/WormQuestion2.ogg', vol=1.5))162 s = s.create_successor()163 s.add_condition(bat.story.CondEvent('DialogueDismissed', self))164 s.add_event("ShowDialogue", "I have something for you!")165 #166 # Dig up letter167 #168 s = s.create_successor("Dig up letter")169 s.add_condition(bat.story.CondEvent('DialogueDismissed', self))170 s.add_action(bat.story.ActAction('ParticleEmitMove', 2, 2, Worm.L_ANIM, "ParticleEmitterLoc"))171 s.add_action(bat.story.ActAction('BurstOut', 220, 280, Worm.L_ANIM))172 s.add_action(bat.story.ActAction('BurstOut_S', 220, 280, Worm.L_ANIM, 'WormBody'))173 s = s.create_successor()174 s.add_condition(bat.story.CondActionGE(Worm.L_ANIM, 235))175 s.add_action(bat.story.ActGenericContext(spray_dirt, 3, 10.0))176 s = s.create_successor()177 s.add_condition(bat.story.CondActionGE(Worm.L_ANIM, 241))178 s.add_action(bat.story.ActGenericContext(spray_dirt, 3, 7.0))179 s = s.create_successor()180 s.add_condition(bat.story.CondActionGE(Worm.L_ANIM, 249))181 s.add_action(bat.story.ActGenericContext(spray_dirt, 3, 7.0))182 s = s.create_successor()183 s.add_condition(bat.story.CondActionGE(Worm.L_ANIM, 257))184 s.add_action(bat.story.ActGenericContext(spray_dirt, 3, 7.0))185 s = s.create_successor()186 s.add_condition(bat.story.CondActionGE(Worm.L_ANIM, 265))187 s.add_action(bat.story.ActGenericContext(spray_dirt, 3, 7.0))188 s.add_action(bat.story.ActGenericContext(letter_auto))189 s = s.create_successor()190 s.add_condition(bat.story.CondActionGE(Worm.L_ANIM, 275))191 s.add_action(Scripts.story.ActSetCamera('WormCamera_Envelope'))192 s = s.create_successor()193 s.add_condition(bat.story.CondActionGE(Worm.L_ANIM, 279))194 s.add_event("ShowDialogue",195 ("Ta-da! Please deliver this express \[envelope] for me.",196 ("Of course!", "I'm too sleepy...")))197 s.add_action(bat.story.ActSound('//Sound/WormTaDa.ogg', vol=1.5))198 #199 # FORK - conversation splits.200 #201 syes = s.create_successor("Yes")202 # Use 'not equal' here, because it's safer than using two equals (in203 # case the dialogue returns a value other than 1 or 0).204 syes.add_condition(bat.story.CondEventNe("DialogueDismissed", 1, self))205 syes.add_event("ShowDialogue", "Great!")206 syes.add_action(bat.story.ActSound('//Sound/WormPleased.ogg', vol=1.5))207 sno = s.create_successor("No")208 sno.add_condition(bat.story.CondEventEq("DialogueDismissed", 1, self))209 sno.add_event("ShowDialogue", "Oh, come on! It's your job, after all.")210 sno.add_action(bat.story.ActSound('//Sound/WormFrown.ogg', vol=1.5))211 # Lots of text, so wait for a second.212 sno = sno.create_successor()213 sno.add_condition(bat.story.CondWait(1))214 #215 # Give letter - conversation merges.216 #217 s = bat.story.State("Give letter")218 syes.add_successor(s)219 sno.add_successor(s)220 s.add_action(Scripts.story.ActRemoveCamera('WormCamera_Envelope'))221 s.add_action(bat.story.ActAction('BurstOut', 290, 330, Worm.L_ANIM))222 s.add_action(bat.story.ActAction('BurstOut_S', 290, 330, Worm.L_ANIM, 'WormBody'))223 s = s.create_successor()224 s.add_condition(bat.story.CondActionGE(Worm.L_ANIM, 308))225 s.add_action(bat.story.ActGenericContext(letter_manual))226 s = s.create_successor()227 s.add_condition(bat.story.CondActionGE(Worm.L_ANIM, 315))228 s.add_action(bat.story.ActGenericContext(letter_hide))229 #230 # Point to lighthouse231 #232 s = s.create_successor("Point to lighthouse")233 s.add_condition(bat.story.CondActionGE(Worm.L_ANIM, 330))234 s.add_event("ShowDialogue", "Please take it to the lighthouse keeper as soon as possible. I have paid for express mail!")235 s.add_action(bat.story.ActAction('BurstOut', 360, 395, Worm.L_ANIM))236 s.add_action(bat.story.ActAction('BurstOut_S', 360, 395, Worm.L_ANIM, 'WormBody'))237 s = s.create_successor()238 s.add_condition(bat.story.CondActionGE(Worm.L_ANIM, 360))239 s.add_action(Scripts.story.ActSetCamera('WormCamera_Lighthouse'))240 s.add_action(Scripts.story.ActSetFocalPoint('Torch'))241 s.add_action(Scripts.story.ActShowMarker('Torch'))242 s = s.create_successor()243 s.add_action(Scripts.story.ActSetCamera('WormCamera_Lighthouse_zoom'))244 s = s.create_successor()245 s.add_condition(bat.story.CondActionGE(Worm.L_ANIM, 394))246 s.add_condition(bat.story.CondEvent("DialogueDismissed", self))247 s.add_action(Scripts.story.ActRemoveCamera('WormCamera_Lighthouse_zoom'))248 s.add_action(Scripts.story.ActRemoveCamera('WormCamera_Lighthouse'))249 s.add_action(Scripts.story.ActRemoveFocalPoint('Torch'))250 s.add_action(Scripts.story.ActShowMarker(None))251 s = s.create_successor()252 s.add_event("ShowDialogue", "The lighthouse is marked in red on your map.")253 s.add_action(bat.story.ActStoreSet('/game/level/mapGoal', 'Torch'))254 s.add_event("MapGoalChanged")255 s = s.create_successor()256 s.add_condition(bat.story.CondEvent("DialogueDismissed", self))257 s.add_event("ShowDialogue", "See you later!")258 s.add_action(bat.story.ActSound('//Sound/WormBye.ogg', vol=1.5))259 s.add_action(bat.story.ActAction('BurstOut', 395, 420, Worm.L_ANIM))260 s.add_action(bat.story.ActAction('BurstOut_S', 395, 420, Worm.L_ANIM, 'WormBody'))261 s = s.create_successor()262 s.add_condition(bat.story.CondActionGE(Worm.L_ANIM, 420))263 s.add_condition(bat.story.CondEvent("DialogueDismissed", self))264 s.add_action(bat.story.ActAction('BurstOut', 420, 540, Worm.L_ANIM))265 s.add_action(bat.story.ActAction('BurstOut_S', 420, 540, Worm.L_ANIM, 'WormBody'))266 s.add_action(bat.story.ActMusicStop(name='worm'))267 #268 # Return to game269 #270 s = s.create_successor("Return to game")271 s.add_condition(bat.story.CondActionGE(Worm.L_ANIM, 460))272 s.add_action(bat.story.ActAction('SodFade', 120, 200, 0, 'Sods'))273 s.add_action(Scripts.story.ActResumeInput())274 s.add_action(Scripts.story.ActRemoveCamera('WormCamera_Lighthouse_zoom'))275 s.add_action(Scripts.story.ActRemoveCamera('WormCamera_Converse'))276 s.add_action(Scripts.story.ActRemoveFocalPoint('CargoHoldAuto'))277 s.add_action(bat.story.ActStoreSet('/game/level/wormMissionStarted', True))278 s.add_action(bat.story.ActStoreSet('/game/storySummary', 'wormMissionStarted'))279 #280 # Clean up. At this point, the worm is completely hidden and the sods have faded.281 #282 s = s.create_successor("Clean up")283 s.add_condition(bat.story.CondActionGE(Worm.L_ANIM, 540))284 s.add_action(bat.story.ActDestroy())285 def isInsideWorld(self):...
MainWindow.py
Source:MainWindow.py
...60 self.addDockWidget(Qt.LeftDockWidgetArea, self._main_dock_widget)61 self.centralWidget()62 # ------------- actions -----------------63 # Data64 self._load_file_action = self.add_action("Load", "load", "Load file", True, self.on_load_file, QKSec.Open)65 self._new_data_set = self.add_action("New data set", "new-data-set", "New data set", True, self.on_new_data_set, QKSec.Save)66 self._edit_data_set = self.add_action("Edit data set", "edit-data-set", "Edit data set", True, self.on_edit_data_set, QKSec.Copy)67 # Models68 self._models = self.add_action("Models", "models", "View models", True, self.on_models, QKSec.Paste)69 self._create_PCA = self.add_action("Create PCA", "models", "Create PCA", True, self.on_create_PCA, QKSec.Paste)70 # Explore71 self._line_plot = self.add_action("Line plot", "line_plot", "Line plot", True, self.on_line_plot, QKSec.Paste)72 self._obs_plot = self.add_action("Obs plot", "obs_plot", "Observations plot", True, self.on_obs_plot, QKSec.Paste)73 self._vars_plot = self.add_action("Vars plot", "vars_plot", "Observations plot", True, self.on_vars_plot, QKSec.Paste)74 self._scatter = self.add_action("Scatter", "scatter", "Scatter plot", True, self.on_scatter, QKSec.Paste)75 self._populations = self.add_action("Populations", "populations", "Populations plot", True, self.on_populations, QKSec.Paste)76 self._correlation_plot = self.add_action("Correlation", "correlation", "Plot correlation", True, self.on_correlation, QKSec.Paste)77 # Analyze78 self._variance_plot = self.add_action("Variance exp.", "variance_explained", "Variance explained plot", True, self.on_variance_explained, QKSec.Paste)79 self._scores = self.add_action("Score plot", "scores", "View scores", True, self.on_scores, QKSec.Paste)80 self._line_scores = self.add_action("Line scores", "line_scores", "View scores", True, self.on_line_scores, QKSec.Paste)81 self._loadings = self.add_action("Loadings", "loadings", "View loadings", True, self.on_loadings, QKSec.Paste)82 self._line_loadings = self.add_action("Line loadings", "line_loadings", "View loadings", True, self.on_line_loadings, QKSec.Paste)83 self._t2_hotelling = self.add_action("Hotelling's T2", "hotelling", "View Hotelling's T2", True, self.on_t2_hotelling, QKSec.Paste)84 self._SPE = self.add_action("SPE-X", "spe", "View SPE-X", True, self.on_spe, QKSec.Paste)85 # Selection86 self._exclude = self.add_action("Exclude", "exclude", "Create data set", True, self.on_exclude, QKSec.Paste)87 self._include = self.add_action("Include", "include", "Create data set", True, self.on_include, QKSec.Paste)88 self._paste_action = self.add_action("Paste", "paste", "Paste from clipboard", True, self.on_paste, QKSec.Paste)89 self._zoom_action = self.add_action("Zoom", "zoom", "Zoom in on document", True, self.on_zoom)90 self._about_action = self.add_action("About", "about", "About QupyRibbon", True, self.on_about)91 self._license_action = self.add_action("License", "license", "Licence for this software", True, self.on_license)92 # ------------- textboxes -----------------93 self._text_box1 = RibbonTextbox("Text 1", self.on_text_box1_changed, 80)94 self._text_box2 = RibbonTextbox("Text 2", self.on_text_box1_changed, 80)95 self._text_box3 = RibbonTextbox("Text 3", self.on_text_box1_changed, 80)96 # Menu bar97 # Icons98 spacer = QtGui.QWidget()99 spacer.setSizePolicy(QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Expanding)100 layout = QHBoxLayout(self)101 new_project_icon = QtGui.QPixmap("icons/save.png")102 self.new_project_button = QPushButton(self)103 self.new_project_button.setIcon(QIcon(new_project_icon))104 self.new_project_button.setObjectName('FromMenuBar')105 load_icon = QtGui.QPixmap("icons/load_project.png")106 self.load_button = QPushButton(self)107 self.load_button.setIcon(QIcon(load_icon))108 self.load_button.setObjectName('FromMenuBar')109 save_icon = QtGui.QPixmap("icons/save.png")110 self.save_button = QPushButton(self)111 self.save_button.setIcon(QIcon(save_icon))112 self.save_button.setObjectName('FromMenuBar')113 # Model selector114 label = QLabel(self)115 # TODO: Add a data set selector. By default, selected data set is the data set from the116 # last selected model. Indicate when a selected data set doesn't correspond to selected model117 label.setText('Selected model: ')118 self.model_selector = QComboBox(self)119 self.model_selector.setMinimumWidth(300)120 # layout.addWidget(self.new_project_button)121 # layout.addWidget(self.load_button)122 # layout.addWidget(self.save_button)123 layout.addWidget(spacer)124 layout.addWidget(label)125 layout.addWidget(self.model_selector)126 self.menuBar().setMinimumHeight(45)127 # TODO: reduce margins. That doesn't seems to work128 self.menuBar().setContentsMargins(0, 0, 0, 0)129 self.menuBar().setLayout(layout)130 self.menuBar().setStyleSheet(get_style().get_stylesheet("main"))131 # Ribbon132 self._ribbon = RibbonWidget(self)133 self.addToolBar(self._ribbon)134 self.init_ribbon()135 def add_action(self, caption, icon_name, status_tip, icon_visible, connection, shortcut=None):136 action = QAction(get_icon(icon_name), caption, self)137 action.setStatusTip(status_tip)138 action.triggered.connect(connection)139 action.setIconVisibleInMenu(icon_visible)140 if shortcut is not None:141 action.setShortcuts(shortcut)142 self.addAction(action)143 return action144 def init_ribbon(self):145 # Data146 home_tab = self._ribbon.add_ribbon_tab("Data")147 file_pane = home_tab.add_ribbon_pane("File")148 file_pane.add_ribbon_widget(RibbonButton(self, self._load_file_action, True))149 edit_panel = home_tab.add_ribbon_pane("Data set")...
scene_manager.py
Source:scene_manager.py
...97 self._add_dialog(cast, ENTER_TO_START)98 self._add_initialize_script(script)99 self._add_load_script(script)100 script.clear_actions(INPUT)101 script.add_action(INPUT, ChangeSceneAction(self.KEYBOARD_SERVICE, NEXT_LEVEL))102 self._add_output_script(script)103 self._add_unload_script(script)104 self._add_release_script(script)105 106 def _prepare_next_level(self, cast, script):107 self._add_ball(cast)108 # self._add_bricks(cast)109 self._add_racket(cast)110 self._add_racket_2(cast) 111 self._add_dialog(cast, PREP_TO_LAUNCH)112 script.clear_actions(INPUT)113 script.add_action(INPUT, TimedChangeSceneAction(IN_PLAY, 2))114 self._add_output_script(script)115 script.add_action(OUTPUT, PlaySoundAction(self.AUDIO_SERVICE, WELCOME_SOUND))116 117 def _prepare_try_again(self, cast, script):118 self._add_ball(cast)119 self._add_racket(cast)120 self._add_racket_2(cast)121 self._add_dialog(cast, PREP_TO_LAUNCH)122 script.clear_actions(INPUT)123 script.add_action(INPUT, TimedChangeSceneAction(IN_PLAY, 2))124 self._add_update_script(script)125 self._add_output_script(script)126 def _prepare_in_play(self, cast, script):127 self._activate_ball(cast)128 cast.clear_actors(DIALOG_GROUP)129 script.clear_actions(INPUT)130 script.add_action(INPUT, self.CONTROL_RACKET_1_ACTION)131 script.add_action(INPUT, self.CONTROL_RACKET_2_ACTION)132 self._add_update_script(script)133 self._add_output_script(script)134 def _prepare_game_over(self, cast, script):135 self._add_ball(cast)136 self._add_racket(cast)137 self._add_racket_2(cast)138 self._add_dialog(cast, WAS_GOOD_GAME)139 script.clear_actions(INPUT)140 script.add_action(INPUT, TimedChangeSceneAction(NEW_GAME, 5))141 script.clear_actions(UPDATE)142 self._add_output_script(script)143 # ----------------------------------------------------------------------------------------------144 # casting methods145 # ----------------------------------------------------------------------------------------------146 147 def _activate_ball(self, cast):148 ball = cast.get_first_actor(BALL_GROUP)149 ball.release()150 def _add_ball(self, cast):151 cast.clear_actors(BALL_GROUP)152 x = CENTER_X - BALL_WIDTH / 2153 y = SCREEN_HEIGHT - RACKET_HEIGHT - BALL_HEIGHT 154 position = Point(x, y)155 size = Point(BALL_WIDTH, BALL_HEIGHT)156 velocity = Point(0, 0)157 body = Body(position, size, velocity)158 image = Image(BALL_IMAGE)159 ball = Ball(body, image, True)160 cast.add_actor(BALL_GROUP, ball)161 def _add_dialog(self, cast, message):162 cast.clear_actors(DIALOG_GROUP)163 text = Text(message, FONT_FILE, FONT_SMALL, ALIGN_CENTER)164 position = Point(CENTER_X, CENTER_Y)165 label = Label(text, position)166 cast.add_actor(DIALOG_GROUP, label)167 def _add_score1(self, cast):168 cast.clear_actors(P1_GROUP)169 text = Text(SCORE_FORMAT, FONT_FILE, FONT_SMALL, ALIGN_CENTER)170 position = Point(100, HUD_MARGIN)171 label = Label(text, position)172 cast.add_actor(P1_GROUP, label)173 def _add_score2(self, cast):174 cast.clear_actors(P2_GROUP)175 text = Text(SCORE_FORMAT, FONT_FILE, FONT_SMALL, ALIGN_CENTER)176 position = Point(SCREEN_WIDTH - 100, HUD_MARGIN)177 label = Label(text, position)178 cast.add_actor(P2_GROUP, label)179 def _add_stats(self, cast):180 cast.clear_actors(STATS_GROUP)181 stats = Stats()182 cast.add_actor(STATS_GROUP, stats)183 def _add_racket(self, cast):184 cast.clear_actors(RACKET_GROUP_1)185 x = 0 + 50 + RACKET_WIDTH / 2186 y = CENTER_Y - RACKET_HEIGHT / 2187 position = Point(x, y)188 size = Point(RACKET_WIDTH, RACKET_HEIGHT)189 velocity = Point(0, 0)190 body = Body(position, size, velocity)191 animation = Animation(RACKET_IMAGES_1, RACKET_RATE)192 racket = Racket(body, animation)193 cast.add_actor(RACKET_GROUP_1, racket)194 def _add_racket_2(self, cast):195 cast.clear_actors(RACKET_GROUP_2)196 x = SCREEN_WIDTH - 50 - RACKET_WIDTH / 2197 y = CENTER_Y - RACKET_HEIGHT / 2198 position = Point(x, y)199 size = Point(RACKET_WIDTH, RACKET_HEIGHT)200 velocity = Point(0, 0)201 body = Body(position, size, velocity)202 animation = Animation(RACKET_IMAGES_2, RACKET_RATE)203 racket = Racket(body, animation)204 cast.add_actor(RACKET_GROUP_2, racket)205 # ----------------------------------------------------------------------------------------------206 # scripting methods207 # ----------------------------------------------------------------------------------------------208 def _add_initialize_script(self, script):209 script.clear_actions(INITIALIZE)210 script.add_action(INITIALIZE, self.INITIALIZE_DEVICES_ACTION)211 def _add_load_script(self, script):212 script.clear_actions(LOAD)213 script.add_action(LOAD, self.LOAD_ASSETS_ACTION)214 215 def _add_output_script(self, script):216 script.clear_actions(OUTPUT)217 script.add_action(OUTPUT, self.START_DRAWING_ACTION)218 script.add_action(OUTPUT, self.DRAW_HUD_ACTION)219 script.add_action(OUTPUT, self.DRAW_BALL_ACTION)220 # script.add_action(OUTPUT, self.DRAW_BRICKS_ACTION)221 script.add_action(OUTPUT, self.DRAW_RACKET_1_ACTION)222 script.add_action(OUTPUT, self.DRAW_RACKET_2_ACTION)223 script.add_action(OUTPUT, self.DRAW_DIALOG_ACTION)224 script.add_action(OUTPUT, self.END_DRAWING_ACTION)225 def _add_release_script(self, script):226 script.clear_actions(RELEASE)227 script.add_action(RELEASE, self.RELEASE_DEVICES_ACTION)228 229 def _add_unload_script(self, script):230 script.clear_actions(UNLOAD)231 script.add_action(UNLOAD, self.UNLOAD_ASSETS_ACTION)232 233 def _add_update_script(self, script):234 script.clear_actions(UPDATE)235 script.add_action(UPDATE, self.MOVE_BALL_ACTION)236 script.add_action(UPDATE, self.MOVE_RACKET_1_ACTION)237 script.add_action(UPDATE, self.MOVE_RACKET_2_ACTION)238 script.add_action(UPDATE, self.COLLIDE_BORDERS_ACTION)239 # script.add_action(UPDATE, self.COLLIDE_BRICKS_ACTION)240 script.add_action(UPDATE, self.COLLIDE_RACKET_1_ACTION)241 script.add_action(UPDATE, self.COLLIDE_RACKET_2_ACTION)242 script.add_action(UPDATE, self.MOVE_RACKET_1_ACTION)243 script.add_action(UPDATE, self.MOVE_RACKET_2_ACTION)...
Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!