实现了一个较为劣质的南瓜头
BIN
resources/graphics/Cards/card_pumpkinhead.png
Normal file
|
After Width: | Height: | Size: 35 KiB |
BIN
resources/graphics/Cards/card_pumpkinhead_move.png
Normal file
|
After Width: | Height: | Size: 34 KiB |
|
After Width: | Height: | Size: 2.6 KiB |
|
After Width: | Height: | Size: 2.6 KiB |
|
After Width: | Height: | Size: 2.6 KiB |
|
After Width: | Height: | Size: 2.6 KiB |
|
After Width: | Height: | Size: 2.6 KiB |
|
After Width: | Height: | Size: 2.7 KiB |
|
After Width: | Height: | Size: 2.6 KiB |
|
After Width: | Height: | Size: 2.5 KiB |
|
After Width: | Height: | Size: 2.5 KiB |
|
After Width: | Height: | Size: 2.6 KiB |
@ -62,7 +62,7 @@ class Map():
|
|||||||
if plantName not in c.WATER_PLANTS:
|
if plantName not in c.WATER_PLANTS:
|
||||||
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 (all((i in {'花盆(未实现)', '南瓜头(未实现)'}) for i in self.map[map_y][map_x][c.MAP_PLANT])
|
elif (all((i in {'花盆(未实现)', c.PUMPKINHEAD}) for i in 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])): # 例外植物:集合中填花盆和南瓜头,只要这里没有这种植物就能种植;判断方法:并集
|
||||||
return True
|
return True
|
||||||
else:
|
else:
|
||||||
@ -73,7 +73,7 @@ class Map():
|
|||||||
# 首先需要判断植物是否是水生植物,水生植物不能种植在陆地上
|
# 首先需要判断植物是否是水生植物,水生植物不能种植在陆地上
|
||||||
if plantName not in c.WATER_PLANTS:
|
if plantName not in c.WATER_PLANTS:
|
||||||
if '花盆(未实现)' in self.map[map_y][map_x][c.MAP_PLANT]:
|
if '花盆(未实现)' in self.map[map_y][map_x][c.MAP_PLANT]:
|
||||||
if (all((i in {'花盆(未实现)', '南瓜头(未实现)'}) for i in self.map[map_y][map_x][c.MAP_PLANT])
|
if (all((i in {'花盆(未实现)', c.PUMPKINHEAD}) for i in 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])): # 例外植物:集合中填花盆和南瓜头,只要这里没有这种植物就能种植;判断方法:并集
|
||||||
if plantName in {c.SPIKEWEED}: # 不能在花盆上种植的植物
|
if plantName in {c.SPIKEWEED}: # 不能在花盆上种植的植物
|
||||||
return False
|
return False
|
||||||
@ -93,7 +93,7 @@ class Map():
|
|||||||
return False
|
return False
|
||||||
else: # 非水生植物,依赖睡莲
|
else: # 非水生植物,依赖睡莲
|
||||||
if c.LILYPAD in self.map[map_y][map_x][c.MAP_PLANT]:
|
if c.LILYPAD in self.map[map_y][map_x][c.MAP_PLANT]:
|
||||||
if (all((i in {c.LILYPAD, '南瓜头(未实现)'}) for i in self.map[map_y][map_x][c.MAP_PLANT])
|
if (all((i in {c.LILYPAD, c.PUMPKINHEAD}) for i in 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])):
|
||||||
if plantName in {c.SPIKEWEED, c.POTATOMINE, '花盆(未实现)'}: # 不能在睡莲上种植的植物
|
if plantName in {c.SPIKEWEED, c.POTATOMINE, '花盆(未实现)'}: # 不能在睡莲上种植的植物
|
||||||
return False
|
return False
|
||||||
|
|||||||
@ -1807,3 +1807,29 @@ class Garlic(Plant):
|
|||||||
elif (not self.cracked2) and self.health <= c.GARLIC_CRACKED2_HEALTH:
|
elif (not self.cracked2) and self.health <= c.GARLIC_CRACKED2_HEALTH:
|
||||||
self.changeFrames(self.cracked2_frames)
|
self.changeFrames(self.cracked2_frames)
|
||||||
self.cracked2 = True
|
self.cracked2 = True
|
||||||
|
|
||||||
|
class PumpkinHead(Plant):
|
||||||
|
def __init__(self, x, y):
|
||||||
|
Plant.__init__(self, x, y, c.PUMPKINHEAD, c.WALLNUT_HEALTH, None)
|
||||||
|
self.load_images()
|
||||||
|
self.cracked1 = False
|
||||||
|
self.cracked2 = False
|
||||||
|
self.animate_interval = 140
|
||||||
|
|
||||||
|
def load_images(self):
|
||||||
|
self.cracked1_frames = []
|
||||||
|
self.cracked2_frames = []
|
||||||
|
|
||||||
|
cracked1_frames_name = self.name + '_cracked1'
|
||||||
|
cracked2_frames_name = self.name + '_cracked2'
|
||||||
|
|
||||||
|
self.loadFrames(self.cracked1_frames, cracked1_frames_name, 1)
|
||||||
|
self.loadFrames(self.cracked2_frames, cracked2_frames_name, 1)
|
||||||
|
|
||||||
|
def idling(self):
|
||||||
|
if not self.cracked1 and self.health <= c.WALLNUT_CRACKED1_HEALTH:
|
||||||
|
self.changeFrames(self.cracked1_frames)
|
||||||
|
self.cracked1 = True
|
||||||
|
elif not self.cracked2 and self.health <= c.WALLNUT_CRACKED2_HEALTH:
|
||||||
|
self.changeFrames(self.cracked2_frames)
|
||||||
|
self.cracked2 = True
|
||||||
|
|||||||
@ -255,6 +255,7 @@ GRAVE = 'Grave'
|
|||||||
GRAVEBUSTER = 'GraveBuster'
|
GRAVEBUSTER = 'GraveBuster'
|
||||||
FUMESHROOM = 'FumeShroom'
|
FUMESHROOM = 'FumeShroom'
|
||||||
GARLIC = 'Garlic'
|
GARLIC = 'Garlic'
|
||||||
|
PUMPKINHEAD = 'PumpkinHead'
|
||||||
|
|
||||||
|
|
||||||
# 植物集体属性集合
|
# 植物集体属性集合
|
||||||
@ -319,6 +320,7 @@ PLANT_NON_CHECK_ATTACK_STATE = ( # 这里运用了集合运算
|
|||||||
SUNSHROOM, COFFEEBEAN,
|
SUNSHROOM, COFFEEBEAN,
|
||||||
GRAVEBUSTER, LILYPAD,
|
GRAVEBUSTER, LILYPAD,
|
||||||
HYPNOSHROOM, GARLIC,
|
HYPNOSHROOM, GARLIC,
|
||||||
|
PUMPKINHEAD,
|
||||||
} |
|
} |
|
||||||
# 非植物类
|
# 非植物类
|
||||||
NON_PLANT_OBJECTS
|
NON_PLANT_OBJECTS
|
||||||
@ -387,6 +389,7 @@ CARD_DOOMSHROOM = 'card_doomshroom'
|
|||||||
CARD_GRAVEBUSTER = 'card_gravebuster'
|
CARD_GRAVEBUSTER = 'card_gravebuster'
|
||||||
CARD_FUMESHROOM = 'card_fumeshroom'
|
CARD_FUMESHROOM = 'card_fumeshroom'
|
||||||
CARD_GARLIC = 'card_garlic'
|
CARD_GARLIC = 'card_garlic'
|
||||||
|
CARD_PUMPKINHEAD = 'card_pumpkinhead'
|
||||||
|
|
||||||
|
|
||||||
# 植物卡片信息汇总(包括植物名称, 卡片名称, 阳光, 冷却时间)
|
# 植物卡片信息汇总(包括植物名称, 卡片名称, 阳光, 冷却时间)
|
||||||
@ -495,6 +498,10 @@ PLANT_CARD_INFO = (# 元组 (植物名称, 卡片名称, 阳光, 冷却时间)
|
|||||||
CARD_STARFRUIT,
|
CARD_STARFRUIT,
|
||||||
125,
|
125,
|
||||||
7500),
|
7500),
|
||||||
|
(PUMPKINHEAD,
|
||||||
|
CARD_PUMPKINHEAD,
|
||||||
|
125,
|
||||||
|
30000),
|
||||||
(COFFEEBEAN,
|
(COFFEEBEAN,
|
||||||
CARD_COFFEEBEAN,
|
CARD_COFFEEBEAN,
|
||||||
75,
|
75,
|
||||||
|
|||||||
@ -932,6 +932,8 @@ class Level(tool.State):
|
|||||||
new_plant = plant.FumeShroom(x, y, self.bullet_groups[map_y], self.zombie_groups[map_y])
|
new_plant = plant.FumeShroom(x, y, self.bullet_groups[map_y], self.zombie_groups[map_y])
|
||||||
elif self.plant_name == c.GARLIC:
|
elif self.plant_name == c.GARLIC:
|
||||||
new_plant = plant.Garlic(x, y)
|
new_plant = plant.Garlic(x, y)
|
||||||
|
elif self.plant_name == c.PUMPKINHEAD:
|
||||||
|
new_plant = plant.PumpkinHead(x, y)
|
||||||
|
|
||||||
|
|
||||||
if new_plant.can_sleep and self.background_type in c.DAYTIME_BACKGROUNDS:
|
if new_plant.can_sleep and self.background_type in c.DAYTIME_BACKGROUNDS:
|
||||||
@ -1061,7 +1063,7 @@ class Level(tool.State):
|
|||||||
# 如果被攻击植物是睡莲和花盆,同一格种了植物必然刷新
|
# 如果被攻击植物是睡莲和花盆,同一格种了植物必然刷新
|
||||||
# 如果被攻击植物不是睡莲和花盆,同一格种了南瓜头才刷新
|
# 如果被攻击植物不是睡莲和花盆,同一格种了南瓜头才刷新
|
||||||
if ((zombie.prey.name not in {c.LILYPAD, "花盆(未实现)"})
|
if ((zombie.prey.name not in {c.LILYPAD, "花盆(未实现)"})
|
||||||
and (self.newPlantAndPositon[0] != "南瓜头(未实现)")):
|
and (self.newPlantAndPositon[0] != c.PUMPKINHEAD)):
|
||||||
continue
|
continue
|
||||||
else:
|
else:
|
||||||
continue
|
continue
|
||||||
@ -1077,7 +1079,7 @@ class Level(tool.State):
|
|||||||
for plant in self.plant_groups[i]:
|
for plant in self.plant_groups[i]:
|
||||||
if collided_func(plant, zombie):
|
if collided_func(plant, zombie):
|
||||||
# 优先攻击南瓜头
|
# 优先攻击南瓜头
|
||||||
if plant.name == "南瓜头(未实现)":
|
if plant.name == c.PUMPKINHEAD:
|
||||||
targetPlant = plant
|
targetPlant = plant
|
||||||
break
|
break
|
||||||
# 衬底植物情形
|
# 衬底植物情形
|
||||||
@ -1102,7 +1104,7 @@ class Level(tool.State):
|
|||||||
for actualTargetPlant in self.plant_groups[i]:
|
for actualTargetPlant in self.plant_groups[i]:
|
||||||
# 检测同一格的其他植物
|
# 检测同一格的其他植物
|
||||||
if self.map.getMapIndex(actualTargetPlant.rect.centerx, actualTargetPlant.rect.bottom) == (map_x, map_y):
|
if self.map.getMapIndex(actualTargetPlant.rect.centerx, actualTargetPlant.rect.bottom) == (map_x, map_y):
|
||||||
if actualTargetPlant.name == "南瓜头(未实现)":
|
if actualTargetPlant.name == c.PUMPKINHEAD:
|
||||||
targetPlant = actualTargetPlant
|
targetPlant = actualTargetPlant
|
||||||
break
|
break
|
||||||
elif actualTargetPlant.name not in {c.LILYPAD, "花盆(未实现)"}:
|
elif actualTargetPlant.name not in {c.LILYPAD, "花盆(未实现)"}:
|
||||||
|
|||||||