Mercurial > boomslang
comparison gamelib/scenes/game_widgets.py @ 655:c77d6aa29bee pyntnclick
Some code to kinda demonstrate the ever so cunning state handling plan
author | Neil Muller <neil@dip.sun.ac.za> |
---|---|
date | Sun, 12 Feb 2012 13:56:59 +0200 |
parents | 3ce19d33b51f |
children | 497b6d7c55e7 |
comparison
equal
deleted
inserted
replaced
654:335db68e0db4 | 655:c77d6aa29bee |
---|---|
26 | 26 |
27 def interact_default(self, item): | 27 def interact_default(self, item): |
28 return self.interact_without() | 28 return self.interact_without() |
29 | 29 |
30 | 30 |
31 def make_jim_dialog(mesg, state): | 31 def make_jim_dialog(mesg, game): |
32 "Utility helper function" | 32 "Utility helper function" |
33 if state.scenes['bridge'].get_data('ai status') == 'online': | 33 if game.data.get_jim_state() == 'online': |
34 return Result(mesg, style='JIM') | 34 return Result(mesg, style='JIM') |
35 else: | 35 else: |
36 return None | 36 return None |
37 | 37 |
38 | 38 |
43 INITIAL_DATA = { | 43 INITIAL_DATA = { |
44 'state': 'online', | 44 'state': 'online', |
45 } | 45 } |
46 | 46 |
47 def get_description(self): | 47 def get_description(self): |
48 status = self.game.scenes['bridge'].get_data('ai status') | 48 status = self.state.get_jim_state() |
49 if status == 'online': | 49 if status == 'online': |
50 return "A security camera watches over the room" | 50 return "A security camera watches over the room" |
51 elif status == 'looping': | 51 elif status == 'looping': |
52 return "The security camera is currently offline but should be" \ | 52 return "The security camera is currently offline but should be" \ |
53 " working soon" | 53 " working soon" |
54 else: | 54 else: |
55 return "The security camera is powered down" | 55 return "The security camera is powered down" |
56 | 56 |
57 def is_interactive(self, tool=None): | 57 def is_interactive(self, tool=None): |
58 return self.game.scenes['bridge'].get_data('ai status') == 'online' | 58 return self.state.get_jim_state() == 'online' |
59 | 59 |
60 def interact_with_escher_poster(self, item): | 60 def interact_with_escher_poster(self, item): |
61 # Order matters here, because of helper function | 61 # Order matters here, because of helper function |
62 if self.game.scenes['bridge'].get_data('ai status') == 'online': | 62 if self.state.get_jim_state() == 'online': |
63 ai_response = make_jim_dialog("3D scene reconstruction failed." | 63 ai_response = make_jim_dialog("3D scene reconstruction failed." |
64 " Critical error. Entering emergency shutdown.", | 64 " Critical error. Entering emergency shutdown.", |
65 self.game) | 65 self.game) |
66 self.game.scenes['bridge'].set_data('ai status', 'looping') | 66 self.game.data.loop_ai() |
67 return ai_response | 67 return ai_response |
68 | 68 |
69 def animate(self): | 69 def animate(self): |
70 ai_status = self.game.scenes['bridge'].get_data('ai status') | 70 ai_status = self.state.get_jim_state() |
71 if ai_status != self.get_data('status'): | 71 if ai_status != self.get_data('status'): |
72 self.set_data('status', ai_status) | 72 self.set_data('status', ai_status) |
73 self.set_interact(ai_status) | 73 self.set_interact(ai_status) |
74 super(BaseCamera, self).animate() | 74 super(BaseCamera, self).animate() |