diff --git a/resources/graphics/Cards/card_pumpkinhead.png b/resources/graphics/Cards/card_pumpkinhead.png new file mode 100644 index 0000000..8762718 Binary files /dev/null and b/resources/graphics/Cards/card_pumpkinhead.png differ diff --git a/resources/graphics/Cards/card_pumpkinhead_move.png b/resources/graphics/Cards/card_pumpkinhead_move.png new file mode 100644 index 0000000..a3be4f1 Binary files /dev/null and b/resources/graphics/Cards/card_pumpkinhead_move.png differ diff --git a/resources/graphics/Plants/PumpkinHead/PumpkinHead/PumpkinHead_0.png b/resources/graphics/Plants/PumpkinHead/PumpkinHead/PumpkinHead_0.png new file mode 100644 index 0000000..8876df8 Binary files /dev/null and b/resources/graphics/Plants/PumpkinHead/PumpkinHead/PumpkinHead_0.png differ diff --git a/resources/graphics/Plants/PumpkinHead/PumpkinHead/PumpkinHead_1.png b/resources/graphics/Plants/PumpkinHead/PumpkinHead/PumpkinHead_1.png new file mode 100644 index 0000000..83c46f0 Binary files /dev/null and b/resources/graphics/Plants/PumpkinHead/PumpkinHead/PumpkinHead_1.png differ diff --git a/resources/graphics/Plants/PumpkinHead/PumpkinHead/PumpkinHead_2.png b/resources/graphics/Plants/PumpkinHead/PumpkinHead/PumpkinHead_2.png new file mode 100644 index 0000000..c362447 Binary files /dev/null and b/resources/graphics/Plants/PumpkinHead/PumpkinHead/PumpkinHead_2.png differ diff --git a/resources/graphics/Plants/PumpkinHead/PumpkinHead/PumpkinHead_3.png b/resources/graphics/Plants/PumpkinHead/PumpkinHead/PumpkinHead_3.png new file mode 100644 index 0000000..65ae2ec Binary files /dev/null and b/resources/graphics/Plants/PumpkinHead/PumpkinHead/PumpkinHead_3.png differ diff --git a/resources/graphics/Plants/PumpkinHead/PumpkinHead/PumpkinHead_4.png b/resources/graphics/Plants/PumpkinHead/PumpkinHead/PumpkinHead_4.png new file mode 100644 index 0000000..c123426 Binary files /dev/null and b/resources/graphics/Plants/PumpkinHead/PumpkinHead/PumpkinHead_4.png differ diff --git a/resources/graphics/Plants/PumpkinHead/PumpkinHead/PumpkinHead_5.png b/resources/graphics/Plants/PumpkinHead/PumpkinHead/PumpkinHead_5.png new file mode 100644 index 0000000..00f1ddc Binary files /dev/null and b/resources/graphics/Plants/PumpkinHead/PumpkinHead/PumpkinHead_5.png differ diff --git a/resources/graphics/Plants/PumpkinHead/PumpkinHead/PumpkinHead_6.png b/resources/graphics/Plants/PumpkinHead/PumpkinHead/PumpkinHead_6.png new file mode 100644 index 0000000..f567de6 Binary files /dev/null and b/resources/graphics/Plants/PumpkinHead/PumpkinHead/PumpkinHead_6.png differ diff --git a/resources/graphics/Plants/PumpkinHead/PumpkinHead/PumpkinHead_7.png b/resources/graphics/Plants/PumpkinHead/PumpkinHead/PumpkinHead_7.png new file mode 100644 index 0000000..09be209 Binary files /dev/null and b/resources/graphics/Plants/PumpkinHead/PumpkinHead/PumpkinHead_7.png differ diff --git a/resources/graphics/Plants/PumpkinHead/PumpkinHead_cracked1/PumpkinHead_cracked1_0.png b/resources/graphics/Plants/PumpkinHead/PumpkinHead_cracked1/PumpkinHead_cracked1_0.png new file mode 100644 index 0000000..7446ea8 Binary files /dev/null and b/resources/graphics/Plants/PumpkinHead/PumpkinHead_cracked1/PumpkinHead_cracked1_0.png differ diff --git a/resources/graphics/Plants/PumpkinHead/PumpkinHead_cracked2/PumpkinHead_cracked2_0.png b/resources/graphics/Plants/PumpkinHead/PumpkinHead_cracked2/PumpkinHead_cracked2_0.png new file mode 100644 index 0000000..9ee4d16 Binary files /dev/null and b/resources/graphics/Plants/PumpkinHead/PumpkinHead_cracked2/PumpkinHead_cracked2_0.png differ diff --git a/source/component/map.py b/source/component/map.py index 56d02de..2631478 100755 --- a/source/component/map.py +++ b/source/component/map.py @@ -62,7 +62,7 @@ class Map(): if plantName not in c.WATER_PLANTS: if not self.map[map_y][map_x][c.MAP_PLANT]: # 没有植物肯定可以种植 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])): # 例外植物:集合中填花盆和南瓜头,只要这里没有这种植物就能种植;判断方法:并集 return True else: @@ -73,7 +73,7 @@ class Map(): # 首先需要判断植物是否是水生植物,水生植物不能种植在陆地上 if plantName not in c.WATER_PLANTS: 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])): # 例外植物:集合中填花盆和南瓜头,只要这里没有这种植物就能种植;判断方法:并集 if plantName in {c.SPIKEWEED}: # 不能在花盆上种植的植物 return False @@ -93,7 +93,7 @@ class Map(): return False else: # 非水生植物,依赖睡莲 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])): if plantName in {c.SPIKEWEED, c.POTATOMINE, '花盆(未实现)'}: # 不能在睡莲上种植的植物 return False diff --git a/source/component/plant.py b/source/component/plant.py index 33c0381..20129c6 100755 --- a/source/component/plant.py +++ b/source/component/plant.py @@ -1807,3 +1807,29 @@ class Garlic(Plant): elif (not self.cracked2) and self.health <= c.GARLIC_CRACKED2_HEALTH: self.changeFrames(self.cracked2_frames) 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 diff --git a/source/constants.py b/source/constants.py index fba31bf..ec7cee0 100755 --- a/source/constants.py +++ b/source/constants.py @@ -255,6 +255,7 @@ GRAVE = 'Grave' GRAVEBUSTER = 'GraveBuster' FUMESHROOM = 'FumeShroom' GARLIC = 'Garlic' +PUMPKINHEAD = 'PumpkinHead' # 植物集体属性集合 @@ -319,6 +320,7 @@ PLANT_NON_CHECK_ATTACK_STATE = ( # 这里运用了集合运算 SUNSHROOM, COFFEEBEAN, GRAVEBUSTER, LILYPAD, HYPNOSHROOM, GARLIC, + PUMPKINHEAD, } | # 非植物类 NON_PLANT_OBJECTS @@ -387,6 +389,7 @@ CARD_DOOMSHROOM = 'card_doomshroom' CARD_GRAVEBUSTER = 'card_gravebuster' CARD_FUMESHROOM = 'card_fumeshroom' CARD_GARLIC = 'card_garlic' +CARD_PUMPKINHEAD = 'card_pumpkinhead' # 植物卡片信息汇总(包括植物名称, 卡片名称, 阳光, 冷却时间) @@ -495,6 +498,10 @@ PLANT_CARD_INFO = (# 元组 (植物名称, 卡片名称, 阳光, 冷却时间) CARD_STARFRUIT, 125, 7500), + (PUMPKINHEAD, + CARD_PUMPKINHEAD, + 125, + 30000), (COFFEEBEAN, CARD_COFFEEBEAN, 75, diff --git a/source/state/level.py b/source/state/level.py index 9deebf9..e715449 100644 --- a/source/state/level.py +++ b/source/state/level.py @@ -932,6 +932,8 @@ class Level(tool.State): new_plant = plant.FumeShroom(x, y, self.bullet_groups[map_y], self.zombie_groups[map_y]) elif self.plant_name == c.GARLIC: 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: @@ -1061,7 +1063,7 @@ class Level(tool.State): # 如果被攻击植物是睡莲和花盆,同一格种了植物必然刷新 # 如果被攻击植物不是睡莲和花盆,同一格种了南瓜头才刷新 if ((zombie.prey.name not in {c.LILYPAD, "花盆(未实现)"}) - and (self.newPlantAndPositon[0] != "南瓜头(未实现)")): + and (self.newPlantAndPositon[0] != c.PUMPKINHEAD)): continue else: continue @@ -1077,7 +1079,7 @@ class Level(tool.State): for plant in self.plant_groups[i]: if collided_func(plant, zombie): # 优先攻击南瓜头 - if plant.name == "南瓜头(未实现)": + if plant.name == c.PUMPKINHEAD: targetPlant = plant break # 衬底植物情形 @@ -1102,7 +1104,7 @@ class Level(tool.State): for actualTargetPlant in self.plant_groups[i]: # 检测同一格的其他植物 if self.map.getMapIndex(actualTargetPlant.rect.centerx, actualTargetPlant.rect.bottom) == (map_x, map_y): - if actualTargetPlant.name == "南瓜头(未实现)": + if actualTargetPlant.name == c.PUMPKINHEAD: targetPlant = actualTargetPlant break elif actualTargetPlant.name not in {c.LILYPAD, "花盆(未实现)"}: