加入咖啡豆
This commit is contained in:
parent
41b65c8635
commit
33d10028ae
BIN
resources/graphics/Cards/card_coffeebean.png
Normal file
BIN
resources/graphics/Cards/card_coffeebean.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 34 KiB |
@ -43,19 +43,27 @@ class Map():
|
||||
def isAvailable(self, map_x, map_y, plantName):
|
||||
if self.map[map_y][map_x][c.MAP_PLOT_TYPE] == c.MAP_GRASS: # 草地
|
||||
# 首先需要判断植物是否是水生植物,水生植物不能种植在陆地上
|
||||
if plantName == c.COFFEEBEAN:
|
||||
if self.map[map_y][map_x][c.MAP_SLEEP] and (plantName not in self.map[map_y][map_x][c.MAP_PLANT]):
|
||||
return True
|
||||
else:
|
||||
return False
|
||||
if plantName not in {c.LILYPAD, '海蘑菇(未实现)', '缠绕水草(未实现)'}: # 这里的集合也可以换成存储在某一文件中的常数的表达
|
||||
if not self.map[map_y][map_x][c.MAP_PLANT]: # 没有植物肯定可以种植
|
||||
return True
|
||||
elif ((self.map[map_y][map_x][c.MAP_PLANT] | {'花盆(未实现)', '南瓜头(未实现)'} == {'花盆(未实现)', '南瓜头(未实现)'})
|
||||
and (plantName not in self.map[map_y][map_x][c.MAP_PLANT])): # 例外植物:集合中填花盆和南瓜头,只要这里没有这种植物就能种植;判断方法:并集
|
||||
return True
|
||||
elif plantName == '咖啡豆(未实现)' and self.map[map_y][map_x][c.MAP_SLEEP]:
|
||||
return True
|
||||
else:
|
||||
return False
|
||||
else:
|
||||
return False
|
||||
elif self.map[map_y][map_x][c.MAP_PLOT_TYPE] == c.MAP_TILE: # 屋顶
|
||||
if plantName == c.COFFEEBEAN:
|
||||
if self.map[map_y][map_x][c.MAP_SLEEP] and (plantName not in self.map[map_y][map_x][c.MAP_PLANT]):
|
||||
return True
|
||||
else:
|
||||
return False
|
||||
# 首先需要判断植物是否是水生植物,水生植物不能种植在陆地上
|
||||
if plantName not in {c.LILYPAD, '海蘑菇(未实现)', '缠绕水草(未实现)'}: # 这里的集合也可以换成存储在某一文件中的常数的表达
|
||||
if '花盆(未实现)' in self.map[map_y][map_x][c.MAP_PLANT]:
|
||||
@ -67,13 +75,16 @@ class Map():
|
||||
return True
|
||||
elif plantName == '花盆(未实现)': # 这一格本来没有花盆而且新来的植物是花盆,可以种
|
||||
return True
|
||||
elif plantName == '咖啡豆(未实现)' and self.map[map_y][map_x][c.MAP_SLEEP]:
|
||||
return True
|
||||
else:
|
||||
return False
|
||||
else:
|
||||
return False
|
||||
elif self.map[map_y][map_x][c.MAP_PLOT_TYPE] == c.MAP_WATER: # 水里
|
||||
if plantName == c.COFFEEBEAN:
|
||||
if self.map[map_y][map_x][c.MAP_SLEEP] and (plantName not in self.map[map_y][map_x][c.MAP_PLANT]):
|
||||
return True
|
||||
else:
|
||||
return False
|
||||
if plantName in {c.LILYPAD, '海蘑菇(未实现)', '缠绕水草(未实现)'}: # 是水生植物
|
||||
if not self.map[map_y][map_x][c.MAP_PLANT]: # 只有无植物时才能在水里种植水生植物
|
||||
return True
|
||||
|
||||
@ -85,6 +85,10 @@ plantInfo = (# 元组 (植物名称, 卡片名称, 阳光, 冷却时间)
|
||||
c.CARD_STARFRUIT,
|
||||
125,
|
||||
7500),
|
||||
(c.COFFEEBEAN,
|
||||
c.CARD_COFFEEBEAN,
|
||||
75,
|
||||
7500),
|
||||
# 应当保证这两个在一般模式下不可选的特殊植物恒在最后
|
||||
(c.WALLNUTBOWLING,
|
||||
c.CARD_WALLNUT,
|
||||
|
||||
@ -949,7 +949,7 @@ class IceShroom(Plant):
|
||||
|
||||
class HypnoShroom(Plant):
|
||||
def __init__(self, x, y):
|
||||
Plant.__init__(self, x, y, c.HYPNOSHROOM, 1, None)
|
||||
Plant.__init__(self, x, y, c.HYPNOSHROOM, c.PLANT_HEALTH, None)
|
||||
self.can_sleep = True
|
||||
self.animate_interval = 200
|
||||
|
||||
@ -1167,3 +1167,20 @@ class StarFruit(Plant):
|
||||
self.bullet_group.add(StarBullet(self.rect.right - 5, self.rect.y - 10, c.BULLET_DAMAGE_NORMAL, c.STAR_FORWARD_UP, self.level))
|
||||
self.shoot_timer = self.current_time
|
||||
|
||||
|
||||
class CoffeeBean(Plant):
|
||||
def __init__(self, x, y, plant_group, mapContent):
|
||||
Plant.__init__(self, x, y, c.COFFEEBEAN, c.PLANT_HEALTH, None)
|
||||
self.plant_group = plant_group
|
||||
self.mapContent = mapContent
|
||||
|
||||
def idling(self):
|
||||
if (self.frame_index + 1) == self.frame_num:
|
||||
self.mapContent[c.MAP_SLEEP] = True
|
||||
for plant in self.plant_group:
|
||||
if plant.can_sleep:
|
||||
if plant.state == c.SLEEP:
|
||||
plant.setIdle()
|
||||
self.mapContent[c.MAP_PLANT].remove(self.name)
|
||||
self.kill()
|
||||
|
||||
@ -203,6 +203,7 @@ REDWALLNUTBOWLING = 'RedWallNutBowling'
|
||||
LILYPAD = 'LilyPad'
|
||||
TORCHWOOD = 'TorchWood'
|
||||
STARFRUIT = 'StarFruit'
|
||||
COFFEEBEAN = 'CoffeeBean'
|
||||
|
||||
# 植物生命值
|
||||
PLANT_HEALTH = 300
|
||||
@ -245,6 +246,7 @@ CARD_REDWALLNUT = 'card_redwallnut'
|
||||
CARD_LILYPAD = 'card_lilypad'
|
||||
CARD_TORCHWOOD = 'card_torchwood'
|
||||
CARD_STARFRUIT = 'card_starfruit'
|
||||
CARD_COFFEEBEAN = 'card_coffeebean'
|
||||
|
||||
# 子弹信息
|
||||
# 子弹类型
|
||||
|
||||
@ -749,6 +749,8 @@ class Level(tool.State):
|
||||
new_plant = plant.TorchWood(x, y, self.bullet_groups[map_y])
|
||||
elif self.plant_name == c.STARFRUIT:
|
||||
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])
|
||||
|
||||
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()
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user