comparison gamelib/scenes/cryo.py @ 219:326300c218a6

Choppable cryopipes and can refactoring.
author Jeremy Thurgood <firxen@gmail.com>
date Thu, 26 Aug 2010 20:53:19 +0200
parents 6ad6575b501c
children 8d8aef45db4e
comparison
equal deleted inserted replaced
218:6ad6575b501c 219:326300c218a6
4 from albow.music import change_playlist, get_music, PlayList 4 from albow.music import change_playlist, get_music, PlayList
5 5
6 from gamelib import speech 6 from gamelib import speech
7 from gamelib.sound import get_sound 7 from gamelib.sound import get_sound
8 from gamelib.cursor import CursorSprite 8 from gamelib.cursor import CursorSprite
9 from gamelib.state import Scene, Item, Thing, Result, \ 9 from gamelib.state import Scene, Item, CloneableItem, Thing, Result, \
10 InteractImage, InteractNoImage, InteractRectUnion, \ 10 InteractImage, InteractNoImage, InteractRectUnion, \
11 InteractAnimated 11 InteractAnimated
12 from gamelib.statehelpers import GenericDescThing 12 from gamelib.statehelpers import GenericDescThing
13 from gamelib.constants import DEBUG 13 from gamelib.constants import DEBUG
14 from gamelib.scenes.game_constants import PLAYER_ID 14 from gamelib.scenes.game_constants import PLAYER_ID
38 super(Cryo, self).__init__(state) 38 super(Cryo, self).__init__(state)
39 self.add_item(TitaniumLeg("titanium_leg")) 39 self.add_item(TitaniumLeg("titanium_leg"))
40 self.add_thing(CryoUnitAlpha()) 40 self.add_thing(CryoUnitAlpha())
41 self.add_thing(CryoRoomDoor()) 41 self.add_thing(CryoRoomDoor())
42 self.add_thing(CryoComputer()) 42 self.add_thing(CryoComputer())
43 self.add_thing(CryoPipeLeft())
44 self.add_thing(CryoPipeRight())
43 45
44 # Flavour items 46 # Flavour items
45 # pipes 47 # pipes
46 self.add_thing(GenericDescThing('cryo.pipes', 1, 48 self.add_thing(GenericDescThing('cryo.pipes', 1,
47 "These pipes carry cooling fluid to the cryo units.", 49 "These pipes carry cooling fluid to the cryo units.",
149 def leave(self): 151 def leave(self):
150 # Stop music 152 # Stop music
151 change_playlist(None) 153 change_playlist(None)
152 154
153 155
156 class CryoPipeBase(Thing):
157 "Base class for cryo pipes that need to be stolen."
158
159 INITIAL = "fixed"
160
161 INITIAL_DATA = {
162 'fixed': True,
163 }
164
165 def interact_with_machete(self, item):
166 self.set_data('fixed', False)
167 pipe = CryoPipe('cryopipe')
168 self.state.add_item(pipe)
169 self.state.add_inventory_item(pipe.name)
170 self.set_interact("chopped")
171
172 def is_interactive(self):
173 return self.get_data('fixed')
174
175
176 class CryoPipe(CloneableItem):
177 "After emptying the full can."
178
179 INVENTORY_IMAGE = "triangle.png"
180 CURSOR = CursorSprite('triangle.png', 20, 30)
181
182
183 class CryoPipeLeft(CryoPipeBase):
184 "Left cryo pipe."
185
186 NAME = "cryo.pipe.left"
187 INTERACTS = {
188 "fixed": InteractNoImage(125, 192, 27, 258),
189 "chopped": InteractImage(125, 192, "triangle.png"),
190 }
191
192
193 class CryoPipeRight(CryoPipeBase):
194 "Left cryo pipe."
195
196 NAME = "cryo.pipe.right"
197 INTERACTS = {
198 "fixed": InteractNoImage(643, 199, 38, 233),
199 "chopped": InteractImage(643, 199, "triangle.png"),
200 }
201
202
154 class TitaniumLeg(Item): 203 class TitaniumLeg(Item):
155 "Titanium leg, found on a piratical corpse." 204 "Titanium leg, found on a piratical corpse."
156 205
157 INVENTORY_IMAGE = "titanium_femur.png" 206 INVENTORY_IMAGE = "titanium_femur.png"
158 CURSOR = CursorSprite('titanium_femur_cursor.png', 20, 3) 207 CURSOR = CursorSprite('titanium_femur_cursor.png', 20, 3)