Browse Source

weapon man position matching with gui move type

Bastien Sevajol 7 years ago
parent
commit
ddb1a41e77
3 changed files with 22 additions and 12 deletions
  1. 11 3
      opencombat/gui/actor.py
  2. 2 2
      opencombat/gui/const.py
  3. 9 7
      opencombat/gui/weapon.py

+ 11 - 3
opencombat/gui/actor.py View File

9
 from opencombat.exception import UnknownWeapon
9
 from opencombat.exception import UnknownWeapon
10
 from opencombat.gui.animation import ANIMATION_CRAWL
10
 from opencombat.gui.animation import ANIMATION_CRAWL
11
 from opencombat.gui.animation import ANIMATION_WALK
11
 from opencombat.gui.animation import ANIMATION_WALK
12
-from opencombat.gui.const import MAN_STAND_UP
12
+from opencombat.gui.const import POSITION_MAN_STAND_UP
13
+from opencombat.gui.const import POSITION_MAN_CRAWLING
13
 from opencombat.gui.weapon import RIFFLE
14
 from opencombat.gui.weapon import RIFFLE
14
 from opencombat.gui.weapon import WeaponImageApplier
15
 from opencombat.gui.weapon import WeaponImageApplier
15
 
16
 
16
 
17
 
17
 class BaseActor(Actor):
18
 class BaseActor(Actor):
19
+    position_matching = {
20
+        ANIMATION_WALK: POSITION_MAN_STAND_UP,
21
+        ANIMATION_CRAWL: POSITION_MAN_CRAWLING,
22
+    }
23
+
18
     def __init__(
24
     def __init__(
19
         self,
25
         self,
20
         image_path: str,
26
         image_path: str,
21
         config: Config,
27
         config: Config,
22
         subject: Subject,
28
         subject: Subject,
23
     ) -> None:
29
     ) -> None:
24
-        self._mode = MAN_STAND_UP
30
+        self._mode = POSITION_MAN_STAND_UP
25
         self.weapon_image_applier = WeaponImageApplier(config, self)
31
         self.weapon_image_applier = WeaponImageApplier(config, self)
26
         super().__init__(image_path, subject=subject, config=config)
32
         super().__init__(image_path, subject=subject, config=config)
27
 
33
 
52
         if not self.weapons:
58
         if not self.weapons:
53
             return []
59
             return []
54
 
60
 
61
+        position = self.position_matching[animation_name]
62
+
55
         try:
63
         try:
56
             return [
64
             return [
57
                 self.weapon_image_applier.get_animation_image_for_weapon(
65
                 self.weapon_image_applier.get_animation_image_for_weapon(
58
-                    animation_name,
66
+                    position,
59
                     self.weapons[0],
67
                     self.weapons[0],
60
                     animation_position,
68
                     animation_position,
61
                 )
69
                 )

+ 2 - 2
opencombat/gui/const.py View File

1
 # coding: utf-8
1
 # coding: utf-8
2
 
2
 
3
-MAN_STAND_UP = 'MAN_STAND_UP'
4
-MAN_CRAWLING = 'MAN_CRAWLING'
3
+POSITION_MAN_STAND_UP = 'POSITION_MAN_STAND_UP'
4
+POSITION_MAN_CRAWLING = 'POSITION_MAN_CRAWLING'
5
 FLAG_DE = 'DE'
5
 FLAG_DE = 'DE'
6
 FLAG_COLORS = {
6
 FLAG_COLORS = {
7
     FLAG_DE
7
     FLAG_DE

+ 9 - 7
opencombat/gui/weapon.py View File

6
 from synergine2_cocos2d.util import PathManager
6
 from synergine2_cocos2d.util import PathManager
7
 
7
 
8
 from opencombat.exception import UnknownWeapon
8
 from opencombat.exception import UnknownWeapon
9
-from opencombat.gui.const import MAN_STAND_UP
10
-from opencombat.gui.const import MAN_CRAWLING
9
+from opencombat.gui.const import POSITION_MAN_STAND_UP
10
+from opencombat.gui.const import POSITION_MAN_CRAWLING
11
 
11
 
12
 if typing.TYPE_CHECKING:
12
 if typing.TYPE_CHECKING:
13
     from opencombat.gui.actor import BaseActor
13
     from opencombat.gui.actor import BaseActor
30
         self.path_manager = PathManager(config.resolve('global.include_path.graphics'))
30
         self.path_manager = PathManager(config.resolve('global.include_path.graphics'))
31
         self._cache = {}  # type: typing.Dict[str, Image.Image]
31
         self._cache = {}  # type: typing.Dict[str, Image.Image]
32
 
32
 
33
-    def get_images_scheme(self) -> typing.Dict[str, typing.Dict[str, str]]:
33
+    def get_images_scheme(self) -> typing.Dict[str, typing.Dict[str, typing.List[str]]]:
34
         return {
34
         return {
35
-            MAN_STAND_UP: {
35
+            POSITION_MAN_STAND_UP: {
36
                 RIFFLE: [
36
                 RIFFLE: [
37
                     'actors/man_weap1.png'
37
                     'actors/man_weap1.png'
38
                 ],
38
                 ],
39
             },
39
             },
40
-            # FIXME NOW
41
-            # MAN_CRAWLING: {
42
-            'CRAWL': {
40
+            POSITION_MAN_CRAWLING: {
43
                 RIFFLE: [
41
                 RIFFLE: [
44
                     'actors/man_c1_weap1.png',
42
                     'actors/man_c1_weap1.png',
45
                     'actors/man_c2_weap1.png',
43
                     'actors/man_c2_weap1.png',
84
             raise UnknownWeapon(
82
             raise UnknownWeapon(
85
                 'Unknown weapon "{}" for mode "{}"'.format(weapon_type, mode),
83
                 'Unknown weapon "{}" for mode "{}"'.format(weapon_type, mode),
86
             )
84
             )
85
+        except IndexError:
86
+            raise UnknownWeapon(
87
+                'Unknown weapon "{}" for mode "{}"'.format(weapon_type, mode),
88
+            )
87
 
89