加入海蘑菇

This commit is contained in:
星外之神 2022-05-05 08:55:06 +08:00
parent 72a47dfcdc
commit 110c5a47c4
53 changed files with 45 additions and 4 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 33 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

View File

@ -49,7 +49,7 @@ class Map():
return False return False
if self.map[map_y][map_x][c.MAP_PLOT_TYPE] == c.MAP_GRASS: # 草地 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]: # 没有植物肯定可以种植 if not self.map[map_y][map_x][c.MAP_PLANT]: # 没有植物肯定可以种植
return True return True
elif ((self.map[map_y][map_x][c.MAP_PLANT] | {'花盆(未实现)', '南瓜头(未实现)'} == {'花盆(未实现)', '南瓜头(未实现)'}) elif ((self.map[map_y][map_x][c.MAP_PLANT] | {'花盆(未实现)', '南瓜头(未实现)'} == {'花盆(未实现)', '南瓜头(未实现)'})
@ -61,7 +61,7 @@ class Map():
return False return False
elif self.map[map_y][map_x][c.MAP_PLOT_TYPE] == c.MAP_TILE: # 屋顶 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 '花盆(未实现)' in self.map[map_y][map_x][c.MAP_PLANT]:
if ((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])): # 例外植物:集合中填花盆和南瓜头,只要这里没有这种植物就能种植;判断方法:并集 and (plantName not in self.map[map_y][map_x][c.MAP_PLANT])): # 例外植物:集合中填花盆和南瓜头,只要这里没有这种植物就能种植;判断方法:并集
@ -76,7 +76,7 @@ class Map():
else: else:
return False return False
elif self.map[map_y][map_x][c.MAP_PLOT_TYPE] == c.MAP_WATER: # 水里 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]: # 只有无植物时才能在水里种植水生植物 if not self.map[map_y][map_x][c.MAP_PLANT]: # 只有无植物时才能在水里种植水生植物
return True return True
else: else:

View File

@ -81,6 +81,10 @@ plantInfo = (# 元组 (植物名称, 卡片名称, 阳光, 冷却时间)
c.CARD_TORCHWOOD, c.CARD_TORCHWOOD,
175, 175,
7500), 7500),
(c.SEASHROOM,
c.CARD_SEASHROOM,
125,
7500),
(c.STARFRUIT, (c.STARFRUIT,
c.CARD_STARFRUIT, c.CARD_STARFRUIT,
125, 125,

View File

@ -1189,4 +1189,37 @@ class CoffeeBean(Plant):
plant.changeFrames(plant.idle_frames) plant.changeFrames(plant.idle_frames)
self.mapContent[c.MAP_PLANT].remove(self.name) self.mapContent[c.MAP_PLANT].remove(self.name)
self.kill() self.kill()
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

View File

@ -204,6 +204,7 @@ LILYPAD = 'LilyPad'
TORCHWOOD = 'TorchWood' TORCHWOOD = 'TorchWood'
STARFRUIT = 'StarFruit' STARFRUIT = 'StarFruit'
COFFEEBEAN = 'CoffeeBean' COFFEEBEAN = 'CoffeeBean'
SEASHROOM = 'SeaShroom'
# 植物生命值 # 植物生命值
PLANT_HEALTH = 300 PLANT_HEALTH = 300
@ -247,6 +248,7 @@ CARD_LILYPAD = 'card_lilypad'
CARD_TORCHWOOD = 'card_torchwood' CARD_TORCHWOOD = 'card_torchwood'
CARD_STARFRUIT = 'card_starfruit' CARD_STARFRUIT = 'card_starfruit'
CARD_COFFEEBEAN = 'card_coffeebean' CARD_COFFEEBEAN = 'card_coffeebean'
CARD_SEASHROOM = 'card_seashroom'
# 子弹信息 # 子弹信息
# 子弹类型 # 子弹类型

View File

@ -751,6 +751,8 @@ class Level(tool.State):
new_plant = plant.StarFruit(x, y, self.bullet_groups[map_y], self) new_plant = plant.StarFruit(x, y, self.bullet_groups[map_y], self)
elif self.plant_name == c.COFFEEBEAN: elif self.plant_name == c.COFFEEBEAN:
new_plant = plant.CoffeeBean(x, y, self.plant_groups[map_y], self.map.map[map_y][map_x]) 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}: 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() new_plant.setSleep()