diff --git a/resources/graphics/Cards/card_seashroom.png b/resources/graphics/Cards/card_seashroom.png new file mode 100644 index 0000000..506de74 Binary files /dev/null and b/resources/graphics/Cards/card_seashroom.png differ diff --git a/resources/graphics/Plants/SeaShroom/SeaShroom/SeaShroom_0.png b/resources/graphics/Plants/SeaShroom/SeaShroom/SeaShroom_0.png new file mode 100644 index 0000000..54dc49c Binary files /dev/null and b/resources/graphics/Plants/SeaShroom/SeaShroom/SeaShroom_0.png differ diff --git a/resources/graphics/Plants/SeaShroom/SeaShroom/SeaShroom_1.png b/resources/graphics/Plants/SeaShroom/SeaShroom/SeaShroom_1.png new file mode 100644 index 0000000..96dd0de Binary files /dev/null and b/resources/graphics/Plants/SeaShroom/SeaShroom/SeaShroom_1.png differ diff --git a/resources/graphics/Plants/SeaShroom/SeaShroom/SeaShroom_10.png b/resources/graphics/Plants/SeaShroom/SeaShroom/SeaShroom_10.png new file mode 100644 index 0000000..8db4cd7 Binary files /dev/null and b/resources/graphics/Plants/SeaShroom/SeaShroom/SeaShroom_10.png differ diff --git a/resources/graphics/Plants/SeaShroom/SeaShroom/SeaShroom_11.png b/resources/graphics/Plants/SeaShroom/SeaShroom/SeaShroom_11.png new file mode 100644 index 0000000..74ec4ac Binary files /dev/null and b/resources/graphics/Plants/SeaShroom/SeaShroom/SeaShroom_11.png differ diff --git a/resources/graphics/Plants/SeaShroom/SeaShroom/SeaShroom_12.png b/resources/graphics/Plants/SeaShroom/SeaShroom/SeaShroom_12.png new file mode 100644 index 0000000..2f75945 Binary files /dev/null and b/resources/graphics/Plants/SeaShroom/SeaShroom/SeaShroom_12.png differ diff --git a/resources/graphics/Plants/SeaShroom/SeaShroom/SeaShroom_13.png b/resources/graphics/Plants/SeaShroom/SeaShroom/SeaShroom_13.png new file mode 100644 index 0000000..8f8d3ff Binary files /dev/null and b/resources/graphics/Plants/SeaShroom/SeaShroom/SeaShroom_13.png differ diff --git a/resources/graphics/Plants/SeaShroom/SeaShroom/SeaShroom_14.png b/resources/graphics/Plants/SeaShroom/SeaShroom/SeaShroom_14.png new file mode 100644 index 0000000..d2ae34c Binary files /dev/null and b/resources/graphics/Plants/SeaShroom/SeaShroom/SeaShroom_14.png differ diff --git a/resources/graphics/Plants/SeaShroom/SeaShroom/SeaShroom_15.png b/resources/graphics/Plants/SeaShroom/SeaShroom/SeaShroom_15.png new file mode 100644 index 0000000..3a34aef Binary files /dev/null and b/resources/graphics/Plants/SeaShroom/SeaShroom/SeaShroom_15.png differ diff --git a/resources/graphics/Plants/SeaShroom/SeaShroom/SeaShroom_16.png b/resources/graphics/Plants/SeaShroom/SeaShroom/SeaShroom_16.png new file mode 100644 index 0000000..3a34aef Binary files /dev/null and b/resources/graphics/Plants/SeaShroom/SeaShroom/SeaShroom_16.png differ diff --git a/resources/graphics/Plants/SeaShroom/SeaShroom/SeaShroom_17.png b/resources/graphics/Plants/SeaShroom/SeaShroom/SeaShroom_17.png new file mode 100644 index 0000000..bc48f4b Binary files /dev/null and b/resources/graphics/Plants/SeaShroom/SeaShroom/SeaShroom_17.png differ diff --git a/resources/graphics/Plants/SeaShroom/SeaShroom/SeaShroom_18.png b/resources/graphics/Plants/SeaShroom/SeaShroom/SeaShroom_18.png new file mode 100644 index 0000000..d56b0df Binary files /dev/null and b/resources/graphics/Plants/SeaShroom/SeaShroom/SeaShroom_18.png differ diff --git a/resources/graphics/Plants/SeaShroom/SeaShroom/SeaShroom_19.png b/resources/graphics/Plants/SeaShroom/SeaShroom/SeaShroom_19.png new file mode 100644 index 0000000..34b4a0e Binary files /dev/null and b/resources/graphics/Plants/SeaShroom/SeaShroom/SeaShroom_19.png differ diff --git a/resources/graphics/Plants/SeaShroom/SeaShroom/SeaShroom_2.png b/resources/graphics/Plants/SeaShroom/SeaShroom/SeaShroom_2.png new file mode 100644 index 0000000..96dd0de Binary files /dev/null and b/resources/graphics/Plants/SeaShroom/SeaShroom/SeaShroom_2.png differ diff --git a/resources/graphics/Plants/SeaShroom/SeaShroom/SeaShroom_20.png b/resources/graphics/Plants/SeaShroom/SeaShroom/SeaShroom_20.png new file mode 100644 index 0000000..b3895fc Binary files /dev/null and b/resources/graphics/Plants/SeaShroom/SeaShroom/SeaShroom_20.png differ diff --git a/resources/graphics/Plants/SeaShroom/SeaShroom/SeaShroom_21.png b/resources/graphics/Plants/SeaShroom/SeaShroom/SeaShroom_21.png new file mode 100644 index 0000000..99efbf2 Binary files /dev/null and b/resources/graphics/Plants/SeaShroom/SeaShroom/SeaShroom_21.png differ diff --git a/resources/graphics/Plants/SeaShroom/SeaShroom/SeaShroom_22.png b/resources/graphics/Plants/SeaShroom/SeaShroom/SeaShroom_22.png new file mode 100644 index 0000000..ba4b704 Binary files /dev/null and b/resources/graphics/Plants/SeaShroom/SeaShroom/SeaShroom_22.png differ diff --git a/resources/graphics/Plants/SeaShroom/SeaShroom/SeaShroom_23.png b/resources/graphics/Plants/SeaShroom/SeaShroom/SeaShroom_23.png new file mode 100644 index 0000000..8be25c1 Binary files /dev/null and b/resources/graphics/Plants/SeaShroom/SeaShroom/SeaShroom_23.png differ diff --git a/resources/graphics/Plants/SeaShroom/SeaShroom/SeaShroom_24.png b/resources/graphics/Plants/SeaShroom/SeaShroom/SeaShroom_24.png new file mode 100644 index 0000000..4c469ec Binary files /dev/null and b/resources/graphics/Plants/SeaShroom/SeaShroom/SeaShroom_24.png differ diff --git a/resources/graphics/Plants/SeaShroom/SeaShroom/SeaShroom_3.png b/resources/graphics/Plants/SeaShroom/SeaShroom/SeaShroom_3.png new file mode 100644 index 0000000..87762e5 Binary files /dev/null and b/resources/graphics/Plants/SeaShroom/SeaShroom/SeaShroom_3.png differ diff --git a/resources/graphics/Plants/SeaShroom/SeaShroom/SeaShroom_4.png b/resources/graphics/Plants/SeaShroom/SeaShroom/SeaShroom_4.png new file mode 100644 index 0000000..1439256 Binary files /dev/null and b/resources/graphics/Plants/SeaShroom/SeaShroom/SeaShroom_4.png differ diff --git a/resources/graphics/Plants/SeaShroom/SeaShroom/SeaShroom_5.png b/resources/graphics/Plants/SeaShroom/SeaShroom/SeaShroom_5.png new file mode 100644 index 0000000..e071302 Binary files /dev/null and b/resources/graphics/Plants/SeaShroom/SeaShroom/SeaShroom_5.png differ diff --git a/resources/graphics/Plants/SeaShroom/SeaShroom/SeaShroom_6.png b/resources/graphics/Plants/SeaShroom/SeaShroom/SeaShroom_6.png new file mode 100644 index 0000000..54ba80a Binary files /dev/null and b/resources/graphics/Plants/SeaShroom/SeaShroom/SeaShroom_6.png differ diff --git a/resources/graphics/Plants/SeaShroom/SeaShroom/SeaShroom_7.png b/resources/graphics/Plants/SeaShroom/SeaShroom/SeaShroom_7.png new file mode 100644 index 0000000..edf3fc4 Binary files /dev/null and b/resources/graphics/Plants/SeaShroom/SeaShroom/SeaShroom_7.png differ diff --git a/resources/graphics/Plants/SeaShroom/SeaShroom/SeaShroom_8.png b/resources/graphics/Plants/SeaShroom/SeaShroom/SeaShroom_8.png new file mode 100644 index 0000000..7107061 Binary files /dev/null and b/resources/graphics/Plants/SeaShroom/SeaShroom/SeaShroom_8.png differ diff --git a/resources/graphics/Plants/SeaShroom/SeaShroom/SeaShroom_9.png b/resources/graphics/Plants/SeaShroom/SeaShroom/SeaShroom_9.png new file mode 100644 index 0000000..024b580 Binary files /dev/null and b/resources/graphics/Plants/SeaShroom/SeaShroom/SeaShroom_9.png differ diff --git a/resources/graphics/Plants/SeaShroom/SeaShroomSleep/SeaShroomSleep_0.png b/resources/graphics/Plants/SeaShroom/SeaShroomSleep/SeaShroomSleep_0.png new file mode 100644 index 0000000..bae6600 Binary files /dev/null and b/resources/graphics/Plants/SeaShroom/SeaShroomSleep/SeaShroomSleep_0.png differ diff --git a/resources/graphics/Plants/SeaShroom/SeaShroomSleep/SeaShroomSleep_1.png b/resources/graphics/Plants/SeaShroom/SeaShroomSleep/SeaShroomSleep_1.png new file mode 100644 index 0000000..7a8dd83 Binary files /dev/null and b/resources/graphics/Plants/SeaShroom/SeaShroomSleep/SeaShroomSleep_1.png differ diff --git a/resources/graphics/Plants/SeaShroom/SeaShroomSleep/SeaShroomSleep_10.png b/resources/graphics/Plants/SeaShroom/SeaShroomSleep/SeaShroomSleep_10.png new file mode 100644 index 0000000..f5cfecb Binary files /dev/null and b/resources/graphics/Plants/SeaShroom/SeaShroomSleep/SeaShroomSleep_10.png differ diff --git a/resources/graphics/Plants/SeaShroom/SeaShroomSleep/SeaShroomSleep_11.png b/resources/graphics/Plants/SeaShroom/SeaShroomSleep/SeaShroomSleep_11.png new file mode 100644 index 0000000..f324ff2 Binary files /dev/null and b/resources/graphics/Plants/SeaShroom/SeaShroomSleep/SeaShroomSleep_11.png differ diff --git a/resources/graphics/Plants/SeaShroom/SeaShroomSleep/SeaShroomSleep_12.png b/resources/graphics/Plants/SeaShroom/SeaShroomSleep/SeaShroomSleep_12.png new file mode 100644 index 0000000..65e3673 Binary files /dev/null and b/resources/graphics/Plants/SeaShroom/SeaShroomSleep/SeaShroomSleep_12.png differ diff --git a/resources/graphics/Plants/SeaShroom/SeaShroomSleep/SeaShroomSleep_13.png b/resources/graphics/Plants/SeaShroom/SeaShroomSleep/SeaShroomSleep_13.png new file mode 100644 index 0000000..3dfa3e6 Binary files /dev/null and b/resources/graphics/Plants/SeaShroom/SeaShroomSleep/SeaShroomSleep_13.png differ diff --git a/resources/graphics/Plants/SeaShroom/SeaShroomSleep/SeaShroomSleep_14.png b/resources/graphics/Plants/SeaShroom/SeaShroomSleep/SeaShroomSleep_14.png new file mode 100644 index 0000000..e2c3e15 Binary files /dev/null and b/resources/graphics/Plants/SeaShroom/SeaShroomSleep/SeaShroomSleep_14.png differ diff --git a/resources/graphics/Plants/SeaShroom/SeaShroomSleep/SeaShroomSleep_15.png b/resources/graphics/Plants/SeaShroom/SeaShroomSleep/SeaShroomSleep_15.png new file mode 100644 index 0000000..4d0a83d Binary files /dev/null and b/resources/graphics/Plants/SeaShroom/SeaShroomSleep/SeaShroomSleep_15.png differ diff --git a/resources/graphics/Plants/SeaShroom/SeaShroomSleep/SeaShroomSleep_16.png b/resources/graphics/Plants/SeaShroom/SeaShroomSleep/SeaShroomSleep_16.png new file mode 100644 index 0000000..1d9831a Binary files /dev/null and b/resources/graphics/Plants/SeaShroom/SeaShroomSleep/SeaShroomSleep_16.png differ diff --git a/resources/graphics/Plants/SeaShroom/SeaShroomSleep/SeaShroomSleep_17.png b/resources/graphics/Plants/SeaShroom/SeaShroomSleep/SeaShroomSleep_17.png new file mode 100644 index 0000000..737041f Binary files /dev/null and b/resources/graphics/Plants/SeaShroom/SeaShroomSleep/SeaShroomSleep_17.png differ diff --git a/resources/graphics/Plants/SeaShroom/SeaShroomSleep/SeaShroomSleep_18.png b/resources/graphics/Plants/SeaShroom/SeaShroomSleep/SeaShroomSleep_18.png new file mode 100644 index 0000000..37e6a84 Binary files /dev/null and b/resources/graphics/Plants/SeaShroom/SeaShroomSleep/SeaShroomSleep_18.png differ diff --git a/resources/graphics/Plants/SeaShroom/SeaShroomSleep/SeaShroomSleep_19.png b/resources/graphics/Plants/SeaShroom/SeaShroomSleep/SeaShroomSleep_19.png new file mode 100644 index 0000000..df1e7f9 Binary files /dev/null and b/resources/graphics/Plants/SeaShroom/SeaShroomSleep/SeaShroomSleep_19.png differ diff --git a/resources/graphics/Plants/SeaShroom/SeaShroomSleep/SeaShroomSleep_2.png b/resources/graphics/Plants/SeaShroom/SeaShroomSleep/SeaShroomSleep_2.png new file mode 100644 index 0000000..148c03a Binary files /dev/null and b/resources/graphics/Plants/SeaShroom/SeaShroomSleep/SeaShroomSleep_2.png differ diff --git a/resources/graphics/Plants/SeaShroom/SeaShroomSleep/SeaShroomSleep_20.png b/resources/graphics/Plants/SeaShroom/SeaShroomSleep/SeaShroomSleep_20.png new file mode 100644 index 0000000..bfa998b Binary files /dev/null and b/resources/graphics/Plants/SeaShroom/SeaShroomSleep/SeaShroomSleep_20.png differ diff --git a/resources/graphics/Plants/SeaShroom/SeaShroomSleep/SeaShroomSleep_21.png b/resources/graphics/Plants/SeaShroom/SeaShroomSleep/SeaShroomSleep_21.png new file mode 100644 index 0000000..7d7361a Binary files /dev/null and b/resources/graphics/Plants/SeaShroom/SeaShroomSleep/SeaShroomSleep_21.png differ diff --git a/resources/graphics/Plants/SeaShroom/SeaShroomSleep/SeaShroomSleep_3.png b/resources/graphics/Plants/SeaShroom/SeaShroomSleep/SeaShroomSleep_3.png new file mode 100644 index 0000000..d958469 Binary files /dev/null and b/resources/graphics/Plants/SeaShroom/SeaShroomSleep/SeaShroomSleep_3.png differ diff --git a/resources/graphics/Plants/SeaShroom/SeaShroomSleep/SeaShroomSleep_4.png b/resources/graphics/Plants/SeaShroom/SeaShroomSleep/SeaShroomSleep_4.png new file mode 100644 index 0000000..4f073e1 Binary files /dev/null and b/resources/graphics/Plants/SeaShroom/SeaShroomSleep/SeaShroomSleep_4.png differ diff --git a/resources/graphics/Plants/SeaShroom/SeaShroomSleep/SeaShroomSleep_5.png b/resources/graphics/Plants/SeaShroom/SeaShroomSleep/SeaShroomSleep_5.png new file mode 100644 index 0000000..87d0a48 Binary files /dev/null and b/resources/graphics/Plants/SeaShroom/SeaShroomSleep/SeaShroomSleep_5.png differ diff --git a/resources/graphics/Plants/SeaShroom/SeaShroomSleep/SeaShroomSleep_6.png b/resources/graphics/Plants/SeaShroom/SeaShroomSleep/SeaShroomSleep_6.png new file mode 100644 index 0000000..2329d45 Binary files /dev/null and b/resources/graphics/Plants/SeaShroom/SeaShroomSleep/SeaShroomSleep_6.png differ diff --git a/resources/graphics/Plants/SeaShroom/SeaShroomSleep/SeaShroomSleep_7.png b/resources/graphics/Plants/SeaShroom/SeaShroomSleep/SeaShroomSleep_7.png new file mode 100644 index 0000000..70d847f Binary files /dev/null and b/resources/graphics/Plants/SeaShroom/SeaShroomSleep/SeaShroomSleep_7.png differ diff --git a/resources/graphics/Plants/SeaShroom/SeaShroomSleep/SeaShroomSleep_8.png b/resources/graphics/Plants/SeaShroom/SeaShroomSleep/SeaShroomSleep_8.png new file mode 100644 index 0000000..6d60ef4 Binary files /dev/null and b/resources/graphics/Plants/SeaShroom/SeaShroomSleep/SeaShroomSleep_8.png differ diff --git a/resources/graphics/Plants/SeaShroom/SeaShroomSleep/SeaShroomSleep_9.png b/resources/graphics/Plants/SeaShroom/SeaShroomSleep/SeaShroomSleep_9.png new file mode 100644 index 0000000..7cf4ec5 Binary files /dev/null and b/resources/graphics/Plants/SeaShroom/SeaShroomSleep/SeaShroomSleep_9.png differ diff --git a/source/component/map.py b/source/component/map.py index 93da45a..4f069ce 100755 --- a/source/component/map.py +++ b/source/component/map.py @@ -49,7 +49,7 @@ class Map(): return False if self.map[map_y][map_x][c.MAP_PLOT_TYPE] == c.MAP_GRASS: # 草地 # 首先需要判断植物是否是水生植物,水生植物不能种植在陆地上 - if plantName not in {c.LILYPAD, '海蘑菇(未实现)', '缠绕水草(未实现)'}: # 这里的集合也可以换成存储在某一文件中的常数的表达 + if plantName not in {c.LILYPAD, c.SEASHROOM, '缠绕水草(未实现)'}: # 这里的集合也可以换成存储在某一文件中的常数的表达 if not self.map[map_y][map_x][c.MAP_PLANT]: # 没有植物肯定可以种植 return True elif ((self.map[map_y][map_x][c.MAP_PLANT] | {'花盆(未实现)', '南瓜头(未实现)'} == {'花盆(未实现)', '南瓜头(未实现)'}) @@ -61,7 +61,7 @@ class Map(): return False elif self.map[map_y][map_x][c.MAP_PLOT_TYPE] == c.MAP_TILE: # 屋顶 # 首先需要判断植物是否是水生植物,水生植物不能种植在陆地上 - if plantName not in {c.LILYPAD, '海蘑菇(未实现)', '缠绕水草(未实现)'}: # 这里的集合也可以换成存储在某一文件中的常数的表达 + if plantName not in {c.LILYPAD, c.SEASHROOM, '缠绕水草(未实现)'}: # 这里的集合也可以换成存储在某一文件中的常数的表达 if '花盆(未实现)' in self.map[map_y][map_x][c.MAP_PLANT]: if ((self.map[map_y][map_x][c.MAP_PLANT] | {'花盆(未实现)', '南瓜头(未实现)'} == {'花盆(未实现)', '南瓜头(未实现)'}) and (plantName not in self.map[map_y][map_x][c.MAP_PLANT])): # 例外植物:集合中填花盆和南瓜头,只要这里没有这种植物就能种植;判断方法:并集 @@ -76,7 +76,7 @@ class Map(): else: return False elif self.map[map_y][map_x][c.MAP_PLOT_TYPE] == c.MAP_WATER: # 水里 - if plantName in {c.LILYPAD, '海蘑菇(未实现)', '缠绕水草(未实现)'}: # 是水生植物 + if plantName in {c.LILYPAD, c.SEASHROOM, '缠绕水草(未实现)'}: # 是水生植物 if not self.map[map_y][map_x][c.MAP_PLANT]: # 只有无植物时才能在水里种植水生植物 return True else: diff --git a/source/component/menubar.py b/source/component/menubar.py index dc77346..642a0c5 100755 --- a/source/component/menubar.py +++ b/source/component/menubar.py @@ -81,6 +81,10 @@ plantInfo = (# 元组 (植物名称, 卡片名称, 阳光, 冷却时间) c.CARD_TORCHWOOD, 175, 7500), + (c.SEASHROOM, + c.CARD_SEASHROOM, + 125, + 7500), (c.STARFRUIT, c.CARD_STARFRUIT, 125, diff --git a/source/component/plant.py b/source/component/plant.py index fd9aea7..b0ae5f8 100755 --- a/source/component/plant.py +++ b/source/component/plant.py @@ -1189,4 +1189,37 @@ class CoffeeBean(Plant): plant.changeFrames(plant.idle_frames) self.mapContent[c.MAP_PLANT].remove(self.name) self.kill() - \ No newline at end of file + + +class SeaShroom(Plant): + def __init__(self, x, y, bullet_group): + Plant.__init__(self, x, y, c.SEASHROOM, c.PLANT_HEALTH, bullet_group) + self.can_sleep = True + self.shoot_timer = 0 + + def loadImages(self, name, scale): + self.idle_frames = [] + self.sleep_frames = [] + + idle_name = name + sleep_name = name + 'Sleep' + + frame_list = [self.idle_frames, self.sleep_frames] + name_list = [idle_name, sleep_name] + + for i, name in enumerate(name_list): + self.loadFrames(frame_list[i], name, 1) + + self.frames = self.idle_frames + + def attacking(self): + if (self.current_time - self.shoot_timer) > 1400: + self.bullet_group.add(Bullet(self.rect.right, self.rect.y + 10, self.rect.y + 10, + c.BULLET_MUSHROOM, c.BULLET_DAMAGE_NORMAL, effect=False)) + self.shoot_timer = self.current_time + + def canAttack(self, zombie): + if (self.rect.x <= zombie.rect.right and + (self.rect.x + c.GRID_X_SIZE * 3.5 >= zombie.rect.x) and (zombie.rect.left <= c.SCREEN_WIDTH + 10)): + return True + return False \ No newline at end of file diff --git a/source/constants.py b/source/constants.py index 0a360d3..96c8844 100755 --- a/source/constants.py +++ b/source/constants.py @@ -204,6 +204,7 @@ LILYPAD = 'LilyPad' TORCHWOOD = 'TorchWood' STARFRUIT = 'StarFruit' COFFEEBEAN = 'CoffeeBean' +SEASHROOM = 'SeaShroom' # 植物生命值 PLANT_HEALTH = 300 @@ -247,6 +248,7 @@ CARD_LILYPAD = 'card_lilypad' CARD_TORCHWOOD = 'card_torchwood' CARD_STARFRUIT = 'card_starfruit' CARD_COFFEEBEAN = 'card_coffeebean' +CARD_SEASHROOM = 'card_seashroom' # 子弹信息 # 子弹类型 diff --git a/source/state/level.py b/source/state/level.py index 4cd878a..b3141f6 100644 --- a/source/state/level.py +++ b/source/state/level.py @@ -751,6 +751,8 @@ class Level(tool.State): new_plant = plant.StarFruit(x, y, self.bullet_groups[map_y], self) elif self.plant_name == c.COFFEEBEAN: new_plant = plant.CoffeeBean(x, y, self.plant_groups[map_y], self.map.map[map_y][map_x]) + elif self.plant_name == c.SEASHROOM: + new_plant = plant.SeaShroom(x, y, self.bullet_groups[map_y]) if new_plant.can_sleep and self.background_type in {c.BACKGROUND_DAY, c.BACKGROUND_POOL, c.BACKGROUND_ROOF, c.BACKGROUND_WALLNUTBOWLING, c.BACKGROUND_SINGLE, c.BACKGROUND_TRIPLE}: new_plant.setSleep()