diff options
author | dmazzone <mazzone.diego@gmail.com> | 2010-12-07 12:44:08 (GMT) |
---|---|---|
committer | dmazzone <mazzone.diego@gmail.com> | 2010-12-07 12:44:08 (GMT) |
commit | 58528ea11a501604d59cd039ed0b3eca74d6e4f4 (patch) | |
tree | db00dcb053799e3aebf522e74483f90805d29c9b | |
parent | c1774450178e327f560a316ed1deabdfc28f2448 (diff) |
Change clothes [GUI & Logic]*.
New menu_item for change clothes.
* Sunny and School clothes.
-rwxr-xr-x | Saludame.activity/actions_creator.py | 24 | ||||
-rwxr-xr-x | Saludame.activity/animation.py | 4 | ||||
-rwxr-xr-x | Saludame.activity/character.py | 1 | ||||
-rwxr-xr-x | Saludame.activity/effects.py | 17 | ||||
-rwxr-xr-x | Saludame.activity/game_manager.py | 18 | ||||
-rw-r--r-- | Saludame.activity/kid_window.py | 4 | ||||
-rwxr-xr-x | Saludame.activity/menu_creator.py | 8 | ||||
-rwxr-xr-x | Saludame.activity/windows_controller.py | 7 |
8 files changed, 67 insertions, 16 deletions
diff --git a/Saludame.activity/actions_creator.py b/Saludame.activity/actions_creator.py index 0c38a7f..cc74f9b 100755 --- a/Saludame.activity/actions_creator.py +++ b/Saludame.activity/actions_creator.py @@ -19,8 +19,6 @@ JUMP_ROPE_PATH = os.path.normpath("assets/kid/actions/ropejump") bar_dec_effect = effects.Effect(None, [("nutrition", BARS_DECREASE_RATE), ("spare_time", BARS_DECREASE_RATE), ("physica", BARS_DECREASE_RATE), ("hygiene", BARS_DECREASE_RATE)]) - - #actions list tuple format: #[("action's id","icon_path","picture_path", appereance_probability, time_span, # kid_animation_frame_rate,kid_animation_loop_times, kid_animation_path, window_animation_frame_rate, @@ -195,6 +193,13 @@ locations_ac_list = [("goto_schoolyard", None, 1, None, None, None, None, None, ("goto_bathroom", None, 1, None, None, None, None, None, None, None, None, effects.LocationEffect(None, "home")) ] + +### ACTIONS THAT SET CHARACTER CLOTHES +clothes_ac_list = [("change_school_clothes", None, 1, None, None, None, None, None, None, None, None, effects.ClothesEffect(None, "school")), + ("change_sunny_clothes", None, 1, None, None, None, None, None, None, None, None, effects.ClothesEffect(None, "sunny")), + ("change_rainy_clothes", None, 1, None, None, None, None, None, None, None, None, effects.ClothesEffect(None, "sunny")), + ] + class ActionsLoader: """ Crea las acciones (Action) y sus efectos (Effect y EffectStatus) asociados. @@ -203,8 +208,7 @@ class ActionsLoader: def __init__(self, bar_controller, game_manager): self.bar_controller = bar_controller self.game_manager = game_manager - self.actions_list = self.__load_actions() - + self.actions_list = self.__load_actions() def get_actions_list(self): return self.actions_list @@ -214,14 +218,14 @@ class ActionsLoader: location_actions = [actions.Action(action[0], action[1], action[2], action[3], action[4], action[5], action[6], action[7], action[8], action[9], action[10], self.__set_game_manager(action[11])) for action in locations_ac_list] - return status_actions + location_actions + clothes_actions = [actions.Action(action[0], action[1], action[2], action[3], action[4], action[5], action[6], action[7], action[8], action[9], action[10], self.__set_game_manager(action[11])) for action in clothes_ac_list] + + return status_actions + location_actions + clothes_actions def __set_bar_controller(self, effect): effect.set_bar_controller(self.bar_controller) return effect - def __set_game_manager(self, location_effect): - location_effect.set_game_manager(self.game_manager) - return location_effect - - + def __set_game_manager(self, effect): + effect.set_game_manager(self.game_manager) + return effect
\ No newline at end of file diff --git a/Saludame.activity/animation.py b/Saludame.activity/animation.py index 04ffc8f..0637895 100755 --- a/Saludame.activity/animation.py +++ b/Saludame.activity/animation.py @@ -54,6 +54,10 @@ class Kid(Window): self.mood = self.moods[self.mood_index] self.set_animation() + ##### Clothes #### + def update_clothes(self): + self.set_animation() + ##### Actions ##### def play_action_animation(self, action): self.action = action diff --git a/Saludame.activity/character.py b/Saludame.activity/character.py index 54b200c..a6d3545 100755 --- a/Saludame.activity/character.py +++ b/Saludame.activity/character.py @@ -1,7 +1,6 @@ # -*- coding: utf-8 -*- import pygame - class Character: diff --git a/Saludame.activity/effects.py b/Saludame.activity/effects.py index 825a6fe..cb589f0 100755 --- a/Saludame.activity/effects.py +++ b/Saludame.activity/effects.py @@ -32,4 +32,19 @@ class LocationEffect: self.game_manager.set_character_location(self.place_id) def set_game_manager(self, game_manager): - self.game_manager = game_manager
\ No newline at end of file + self.game_manager = game_manager + +class ClothesEffect: + """ + Represents effects that set the character clothes. + """ + + def __init__(self, game_manager, clothes_id): + self.game_manager = game_manager + self.clothes_id = clothes_id + + def activate(self): + self.game_manager.set_character_clothes(self.clothes_id) + + def set_game_manager(self, game_manager): + self.game_manager = game_manager diff --git a/Saludame.activity/game_manager.py b/Saludame.activity/game_manager.py index a724cb8..ef5e2df 100755 --- a/Saludame.activity/game_manager.py +++ b/Saludame.activity/game_manager.py @@ -171,6 +171,15 @@ class GameManager: for place in self.places_list: if(place.id == place_id): return place + +### Clothes + def set_character_clothes(self, clothes_id): + """ + Set the character clothes. + """ + self.character.set_clothes(clothes_id) + self.windows_controller.update_clothes() + print "character's clothes: ", clothes_id ## Actions handling @@ -180,11 +189,16 @@ class GameManager: if action: if isinstance(action.effect, effects.Effect): #this action affects status bars self.set_active_action(action_id) - elif isinstance(action.effect, effects.LocationEffect): #this action affects character location + elif isinstance(action.effect, effects.LocationEffect): #this action affects character location + if(self.active_char_action): + self.interrupt_active_action(None) + action.perform() + action.reset() + elif isinstance(action.effect, effects.ClothesEffect): #this action affects character clothes if(self.active_char_action): self.interrupt_active_action(None) action.perform() - action.reset() + action.reset() def interrupt_active_action(self, action_id): """ diff --git a/Saludame.activity/kid_window.py b/Saludame.activity/kid_window.py index fedab77..812b234 100644 --- a/Saludame.activity/kid_window.py +++ b/Saludame.activity/kid_window.py @@ -44,6 +44,10 @@ class KidWindow(Window): self.kid.set_bg_image(self.bg_image.subsurface(self.kid_rect)) self.repaint = True + ##### Clothes ##### + def update_clothes(self): + self.kid.update_clothes() + ##### Moods ##### def change_mood(self): self.kid.change_mood() diff --git a/Saludame.activity/menu_creator.py b/Saludame.activity/menu_creator.py index dd7fe0e..e202cc5 100755 --- a/Saludame.activity/menu_creator.py +++ b/Saludame.activity/menu_creator.py @@ -72,7 +72,7 @@ example = [ (_("Clean up the bedroom"), "assets/icons/icon.png", "sp_clean", None) ]), - (_("Ir a..."), "assets/icons/icon_parent.png", None, [ + (_("Ir a..."), "assets/icons/icon_parent.png", None, [ (_("Schoolyard"), "assets/icons/icon.png", "goto_schoolyard", None), (_("Country"), "assets/icons/icon.png", "goto_country", None), (_("Classroom"), "assets/icons/icon.png", "goto_classroom", None), @@ -84,6 +84,12 @@ example = [ ]) ]), + (_("Cambiar de ropa"), "assets/icons/icon_parent.png", None, [ + (_("School"), "assets/icons/icon.png", "change_school_clothes", None), + (_("Sunny"), "assets/icons/icon.png", "change_sunny_clothes", None), + (_("Rainy"), "assets/icons/icon.png", "change_rainy_clothes", None), + ]), + (_("Higiene..."), "assets/icons/icon_parent.png", None, [ (_("BaƱarse"), "assets/icons/icon.png", "shower", None), (_("Lavarse los dientes"), "assets/icons/icon.png", "brush_teeth", None), diff --git a/Saludame.activity/windows_controller.py b/Saludame.activity/windows_controller.py index f9dc2d7..120b79d 100755 --- a/Saludame.activity/windows_controller.py +++ b/Saludame.activity/windows_controller.py @@ -93,7 +93,12 @@ class WindowsController: ##### BACKGROUND ##### def set_environment(self, environment): - self.windows["kid"].set_environment(environment) + self.windows["kid"].set_environment(environment) + + ##### CLOTHES ##### + + def update_clothes(self): + self.windows["kid"].update_clothes() ##### Actions ##### def show_action_animation(self, action): |