Changeset 235:831e4f6b3d18
- Timestamp:
- Sep 4, 2013, 7:16:09 PM (7 years ago)
- Branch:
- default
- Location:
- nagslang
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
nagslang/enemies.py
r229 r235 9 9 from nagslang.mutators import FLIP_H 10 10 from nagslang.resources import resources 11 12 13 def get_editable_enemies(): 14 classes = [] 15 for cls_name, cls in globals().iteritems(): 16 if isinstance(cls, type) and issubclass(cls, Enemy): 17 if hasattr(cls, 'requires'): 18 classes.append((cls_name, cls)) 19 return classes 11 20 12 21 … … 33 42 def attack(self): 34 43 raise NotImplementedError 44 45 @classmethod 46 def requires(cls): 47 return [("name", "string"), ("position", "coordinates")] 35 48 36 49 … … 113 126 self.set_direction(x_step, y_step) 114 127 super(PatrollingAlien, self).animate() 128 129 @classmethod 130 def requires(cls): 131 return [("name", "string"), ("position", "coordinates"), 132 ("end_position", "coordinates")] -
nagslang/game_object.py
r229 r235 9 9 from nagslang.resources import resources 10 10 from nagslang.events import DoorEvent 11 12 13 def get_editable_game_objects(): 14 classes = [] 15 for cls_name, cls in globals().iteritems(): 16 if isinstance(cls, type) and hasattr(cls, 'requires'): 17 classes.append((cls_name, cls)) 18 return classes 11 19 12 20 … … 137 145 return True 138 146 147 @classmethod 148 def requires(cls): 149 """Hints for the level editor""" 150 return [("name", "string")] 151 139 152 140 153 class FloorSwitch(GameObject): … … 155 168 ) 156 169 170 @classmethod 171 def requires(cls): 172 return [("name", "string"), ("position", "coordinates")] 173 157 174 158 175 class Note(GameObject): … … 169 186 render.TextOverlay(message), 170 187 ) 188 189 @classmethod 190 def requires(cls): 191 return [("name", "string"), ("position", "coordinates"), 192 ("message", "text")] 171 193 172 194 … … 187 209 puzzle.StateProxyPuzzler(state_source), 188 210 ) 211 212 @classmethod 213 def requires(cls): 214 return [("name", "string"), ("position", "coordinates"), 215 ("state_source", "puzzler")] 189 216 190 217 … … 201 228 ) 202 229 230 @classmethod 231 def requires(cls): 232 return [("name", "string"), ("position", "coordinates"), 233 ("state_source", "puzzler")] 234 203 235 204 236 class Door(GameObject): … … 226 258 if self.puzzler.get_state(): 227 259 DoorEvent.post(self.destination, self.dest_pos) 260 261 @classmethod 262 def requires(cls): 263 return [("name", "string"), ("position", "coordinates"), 264 ("destination", "level name"), ("dest_pos", "coordinate"), 265 ("key_state", "puzzler")] 228 266 229 267 … … 250 288 return False 251 289 return True 290 291 @classmethod 292 def requires(cls): 293 return [("name", "string"), ("end1", "coordinates"), 294 ("end2", "coordinates"), ("key_state", "puzzler")] -
nagslang/puzzle.py
r201 r235 1 1 from nagslang.constants import COLLISION_TYPE_PLAYER 2 3 4 def get_editable_puzzlers(): 5 classes = [] 6 for cls_name, cls in globals().iteritems(): 7 if isinstance(cls, type) and hasattr(cls, 'requires'): 8 classes.append((cls_name, cls)) 9 return classes 2 10 3 11 … … 30 38 raise NotImplementedError() 31 39 40 @classmethod 41 def requires(cls): 42 """Tell the level editor the arguments we require 43 44 Format is a list of name: type hint tuples""" 45 return [("name", "string")] 46 32 47 33 48 class YesPuzzler(Puzzler): … … 58 73 return False 59 74 75 @classmethod 76 def requires(cls): 77 return [("name", "string"), ("collision_types", "list of ints")] 78 60 79 61 80 class StateProxyPuzzler(Puzzler): … … 65 84 def get_state(self): 66 85 return self.glue.get_state_of(self._state_source) 86 87 @classmethod 88 def requires(cls): 89 return [("name", "string"), ("sources", "list of names")] 67 90 68 91 … … 76 99 return False 77 100 return True 101 102 @classmethod 103 def requires(cls): 104 return [("name", "string"), ("sources", "list of names")]
Note: See TracChangeset
for help on using the changeset viewer.