加入墓碑和墓碑吞噬者
@ -1,5 +1,5 @@
|
|||||||
{
|
{
|
||||||
"background_type":2,
|
"background_type":1,
|
||||||
"init_sun_value":5000,
|
"init_sun_value":5000,
|
||||||
"shovel":1,
|
"shovel":1,
|
||||||
"spawn_zombies":"list",
|
"spawn_zombies":"list",
|
||||||
|
|||||||
BIN
resources/graphics/Cards/card_gravebuster.png
Normal file
|
After Width: | Height: | Size: 35 KiB |
BIN
resources/graphics/Plants/Grave/Grave_0.png
Normal file
|
After Width: | Height: | Size: 8.8 KiB |
BIN
resources/graphics/Plants/Grave/Grave_1.png
Normal file
|
After Width: | Height: | Size: 9.0 KiB |
BIN
resources/graphics/Plants/Grave/Grave_2.png
Normal file
|
After Width: | Height: | Size: 8.0 KiB |
BIN
resources/graphics/Plants/GraveBuster/GraveBuster_0.png
Normal file
|
After Width: | Height: | Size: 4.0 KiB |
BIN
resources/graphics/Plants/GraveBuster/GraveBuster_1.png
Normal file
|
After Width: | Height: | Size: 4.0 KiB |
BIN
resources/graphics/Plants/GraveBuster/GraveBuster_10.png
Normal file
|
After Width: | Height: | Size: 4.4 KiB |
BIN
resources/graphics/Plants/GraveBuster/GraveBuster_11.png
Normal file
|
After Width: | Height: | Size: 4.4 KiB |
BIN
resources/graphics/Plants/GraveBuster/GraveBuster_12.png
Normal file
|
After Width: | Height: | Size: 4.3 KiB |
BIN
resources/graphics/Plants/GraveBuster/GraveBuster_13.png
Normal file
|
After Width: | Height: | Size: 4.4 KiB |
BIN
resources/graphics/Plants/GraveBuster/GraveBuster_14.png
Normal file
|
After Width: | Height: | Size: 4.4 KiB |
BIN
resources/graphics/Plants/GraveBuster/GraveBuster_15.png
Normal file
|
After Width: | Height: | Size: 4.3 KiB |
BIN
resources/graphics/Plants/GraveBuster/GraveBuster_16.png
Normal file
|
After Width: | Height: | Size: 4.4 KiB |
BIN
resources/graphics/Plants/GraveBuster/GraveBuster_17.png
Normal file
|
After Width: | Height: | Size: 4.4 KiB |
BIN
resources/graphics/Plants/GraveBuster/GraveBuster_18.png
Normal file
|
After Width: | Height: | Size: 4.4 KiB |
BIN
resources/graphics/Plants/GraveBuster/GraveBuster_19.png
Normal file
|
After Width: | Height: | Size: 4.3 KiB |
BIN
resources/graphics/Plants/GraveBuster/GraveBuster_2.png
Normal file
|
After Width: | Height: | Size: 4.1 KiB |
BIN
resources/graphics/Plants/GraveBuster/GraveBuster_20.png
Normal file
|
After Width: | Height: | Size: 4.4 KiB |
BIN
resources/graphics/Plants/GraveBuster/GraveBuster_21.png
Normal file
|
After Width: | Height: | Size: 4.4 KiB |
BIN
resources/graphics/Plants/GraveBuster/GraveBuster_22.png
Normal file
|
After Width: | Height: | Size: 4.5 KiB |
BIN
resources/graphics/Plants/GraveBuster/GraveBuster_23.png
Normal file
|
After Width: | Height: | Size: 4.4 KiB |
BIN
resources/graphics/Plants/GraveBuster/GraveBuster_24.png
Normal file
|
After Width: | Height: | Size: 4.5 KiB |
BIN
resources/graphics/Plants/GraveBuster/GraveBuster_25.png
Normal file
|
After Width: | Height: | Size: 4.6 KiB |
BIN
resources/graphics/Plants/GraveBuster/GraveBuster_26.png
Normal file
|
After Width: | Height: | Size: 4.5 KiB |
BIN
resources/graphics/Plants/GraveBuster/GraveBuster_27.png
Normal file
|
After Width: | Height: | Size: 4.4 KiB |
BIN
resources/graphics/Plants/GraveBuster/GraveBuster_28.png
Normal file
|
After Width: | Height: | Size: 4.5 KiB |
BIN
resources/graphics/Plants/GraveBuster/GraveBuster_29.png
Normal file
|
After Width: | Height: | Size: 4.4 KiB |
BIN
resources/graphics/Plants/GraveBuster/GraveBuster_3.png
Normal file
|
After Width: | Height: | Size: 4.3 KiB |
BIN
resources/graphics/Plants/GraveBuster/GraveBuster_30.png
Normal file
|
After Width: | Height: | Size: 4.4 KiB |
BIN
resources/graphics/Plants/GraveBuster/GraveBuster_31.png
Normal file
|
After Width: | Height: | Size: 4.5 KiB |
BIN
resources/graphics/Plants/GraveBuster/GraveBuster_32.png
Normal file
|
After Width: | Height: | Size: 4.5 KiB |
BIN
resources/graphics/Plants/GraveBuster/GraveBuster_33.png
Normal file
|
After Width: | Height: | Size: 4.5 KiB |
BIN
resources/graphics/Plants/GraveBuster/GraveBuster_34.png
Normal file
|
After Width: | Height: | Size: 4.4 KiB |
BIN
resources/graphics/Plants/GraveBuster/GraveBuster_35.png
Normal file
|
After Width: | Height: | Size: 4.5 KiB |
BIN
resources/graphics/Plants/GraveBuster/GraveBuster_36.png
Normal file
|
After Width: | Height: | Size: 4.5 KiB |
BIN
resources/graphics/Plants/GraveBuster/GraveBuster_37.png
Normal file
|
After Width: | Height: | Size: 4.5 KiB |
BIN
resources/graphics/Plants/GraveBuster/GraveBuster_38.png
Normal file
|
After Width: | Height: | Size: 4.3 KiB |
BIN
resources/graphics/Plants/GraveBuster/GraveBuster_39.png
Normal file
|
After Width: | Height: | Size: 4.5 KiB |
BIN
resources/graphics/Plants/GraveBuster/GraveBuster_4.png
Normal file
|
After Width: | Height: | Size: 4.3 KiB |
BIN
resources/graphics/Plants/GraveBuster/GraveBuster_40.png
Normal file
|
After Width: | Height: | Size: 4.3 KiB |
BIN
resources/graphics/Plants/GraveBuster/GraveBuster_41.png
Normal file
|
After Width: | Height: | Size: 4.4 KiB |
BIN
resources/graphics/Plants/GraveBuster/GraveBuster_42.png
Normal file
|
After Width: | Height: | Size: 4.3 KiB |
BIN
resources/graphics/Plants/GraveBuster/GraveBuster_5.png
Normal file
|
After Width: | Height: | Size: 4.4 KiB |
BIN
resources/graphics/Plants/GraveBuster/GraveBuster_6.png
Normal file
|
After Width: | Height: | Size: 4.4 KiB |
BIN
resources/graphics/Plants/GraveBuster/GraveBuster_7.png
Normal file
|
After Width: | Height: | Size: 4.4 KiB |
BIN
resources/graphics/Plants/GraveBuster/GraveBuster_8.png
Normal file
|
After Width: | Height: | Size: 4.4 KiB |
BIN
resources/graphics/Plants/GraveBuster/GraveBuster_9.png
Normal file
|
After Width: | Height: | Size: 4.4 KiB |
@ -41,14 +41,21 @@ class Map():
|
|||||||
# 由于紫卡植物需要移除以前的植物,所以可用另外定义一个函数
|
# 由于紫卡植物需要移除以前的植物,所以可用另外定义一个函数
|
||||||
# 注意咖啡豆生效后需要同时将植物的睡眠状态和格子的睡眠记录改变
|
# 注意咖啡豆生效后需要同时将植物的睡眠状态和格子的睡眠记录改变
|
||||||
def isAvailable(self, map_x, map_y, plantName):
|
def isAvailable(self, map_x, map_y, plantName):
|
||||||
# 咖啡豆的判别最为特殊
|
# 咖啡豆和墓碑吞噬者的判别最为特殊
|
||||||
if (c.HOLE in self.map[map_y][map_x][c.MAP_PLANT]) or (c.ICE_FROZEN_PLOT in self.map[map_y][map_x][c.MAP_PLANT]):
|
|
||||||
return False
|
|
||||||
if plantName == c.COFFEEBEAN:
|
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]):
|
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
|
return True
|
||||||
else:
|
else:
|
||||||
return False
|
return False
|
||||||
|
if plantName == c.GRAVEBUSTER:
|
||||||
|
if (c.GRAVE in self.map[map_y][map_x][c.MAP_PLANT]):
|
||||||
|
return True
|
||||||
|
else:
|
||||||
|
return False
|
||||||
|
if ((c.HOLE in self.map[map_y][map_x][c.MAP_PLANT]) or
|
||||||
|
(c.ICE_FROZEN_PLOT in self.map[map_y][map_x][c.MAP_PLANT]) or
|
||||||
|
(c.GRAVE in self.map[map_y][map_x][c.MAP_PLANT])):
|
||||||
|
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, c.SEASHROOM, c.TANGLEKLEP}: # 这里的集合也可以换成存储在某一文件中的常数的表达
|
if plantName not in {c.LILYPAD, c.SEASHROOM, c.TANGLEKLEP}: # 这里的集合也可以换成存储在某一文件中的常数的表达
|
||||||
|
|||||||
@ -45,6 +45,10 @@ plantInfo = (# 元组 (植物名称, 卡片名称, 阳光, 冷却时间)
|
|||||||
c.CARD_SUNSHROOM,
|
c.CARD_SUNSHROOM,
|
||||||
25,
|
25,
|
||||||
7500),
|
7500),
|
||||||
|
(c.GRAVEBUSTER,
|
||||||
|
c.CARD_GRAVEBUSTER,
|
||||||
|
75,
|
||||||
|
7500),
|
||||||
(c.HYPNOSHROOM,
|
(c.HYPNOSHROOM,
|
||||||
c.CARD_HYPNOSHROOM,
|
c.CARD_HYPNOSHROOM,
|
||||||
75,
|
75,
|
||||||
|
|||||||
@ -923,6 +923,8 @@ class IceShroom(Plant):
|
|||||||
return
|
return
|
||||||
self.animate_timer = self.current_time
|
self.animate_timer = self.current_time
|
||||||
else:
|
else:
|
||||||
|
if self.state != c.SLEEP:
|
||||||
|
self.health = c.INF
|
||||||
if (self.current_time - self.animate_timer) > 100:
|
if (self.current_time - self.animate_timer) > 100:
|
||||||
self.frame_index += 1
|
self.frame_index += 1
|
||||||
if self.frame_index >= self.frame_num:
|
if self.frame_index >= self.frame_num:
|
||||||
@ -1432,3 +1434,43 @@ class Hole(Plant):
|
|||||||
self.shallow = True
|
self.shallow = True
|
||||||
elif self.current_time - self.timer >= 180000:
|
elif self.current_time - self.timer >= 180000:
|
||||||
self.health = 0
|
self.health = 0
|
||||||
|
|
||||||
|
|
||||||
|
class Grave(Plant):
|
||||||
|
def __init__(self, x, y):
|
||||||
|
Plant.__init__(self, x, y, c.GRAVE, c.INF, None)
|
||||||
|
self.frame_index = randint(0, self.frame_num - 1)
|
||||||
|
self.image = self.frames[self.frame_index]
|
||||||
|
|
||||||
|
def animation(self):
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
class GraveBuster(Plant):
|
||||||
|
def __init__(self, x, y, plant_group, map, map_x):
|
||||||
|
Plant.__init__(self, x, y, c.GRAVEBUSTER, c.PLANT_HEALTH, None)
|
||||||
|
self.map = map
|
||||||
|
self.map_x = map_x
|
||||||
|
self.plant_group = plant_group
|
||||||
|
self.animate_interval = 100
|
||||||
|
|
||||||
|
def animation(self):
|
||||||
|
if (self.current_time - self.animate_timer) > self.animate_interval:
|
||||||
|
self.frame_index += 1
|
||||||
|
if self.frame_index >= self.frame_num:
|
||||||
|
self.frame_index = self.frame_num - 1
|
||||||
|
for item in self.plant_group:
|
||||||
|
if item.name == c.GRAVE:
|
||||||
|
itemMapX, _ = self.map.getMapIndex(item.rect.centerx, item.rect.bottom)
|
||||||
|
if itemMapX == self.map_x:
|
||||||
|
item.health = 0
|
||||||
|
self.health = 0
|
||||||
|
self.animate_timer = self.current_time
|
||||||
|
|
||||||
|
self.image = self.frames[self.frame_index]
|
||||||
|
if (self.current_time - self.highlightTime < 200):
|
||||||
|
self.image.set_alpha(150)
|
||||||
|
elif ((self.current_time - self.hit_timer) < 200):
|
||||||
|
self.image.set_alpha(192)
|
||||||
|
else:
|
||||||
|
self.image.set_alpha(255)
|
||||||
|
|||||||
@ -104,6 +104,13 @@ BACKGROUND_WALLNUTBOWLING = 6
|
|||||||
BACKGROUND_SINGLE = 7
|
BACKGROUND_SINGLE = 7
|
||||||
BACKGROUND_TRIPLE = 8
|
BACKGROUND_TRIPLE = 8
|
||||||
|
|
||||||
|
# 夜晚地图的墓碑数量等级
|
||||||
|
GRADE_GRAVES = 'grade_graves'
|
||||||
|
GRADE0_GRAVES = 0 # 无墓碑
|
||||||
|
GRADE1_GRAVES = 1 # 少量墓碑
|
||||||
|
GRADE2_GRAVES = 2 # 中等数量墓碑
|
||||||
|
GRADE3_GRAVES = 3 # 大量墓碑
|
||||||
|
|
||||||
# 僵尸生成方式
|
# 僵尸生成方式
|
||||||
SPAWN_ZOMBIES = 'spawn_zombies'
|
SPAWN_ZOMBIES = 'spawn_zombies'
|
||||||
SPAWN_ZOMBIES_AUTO = 'auto'
|
SPAWN_ZOMBIES_AUTO = 'auto'
|
||||||
@ -207,6 +214,9 @@ TANGLEKLEP = 'TangleKlep'
|
|||||||
DOOMSHROOM = 'DoomShroom'
|
DOOMSHROOM = 'DoomShroom'
|
||||||
ICE_FROZEN_PLOT = 'IceFrozenPlot'
|
ICE_FROZEN_PLOT = 'IceFrozenPlot'
|
||||||
HOLE = 'Hole'
|
HOLE = 'Hole'
|
||||||
|
GRAVE = 'Grave'
|
||||||
|
GRAVEBUSTER = 'GraveBuster'
|
||||||
|
|
||||||
|
|
||||||
# 植物生命值
|
# 植物生命值
|
||||||
PLANT_HEALTH = 300
|
PLANT_HEALTH = 300
|
||||||
@ -257,6 +267,7 @@ CARD_SEASHROOM = 'card_seashroom'
|
|||||||
CARD_TALLNUT = 'card_tallnut'
|
CARD_TALLNUT = 'card_tallnut'
|
||||||
CARD_TANGLEKLEP = 'card_tangleklep'
|
CARD_TANGLEKLEP = 'card_tangleklep'
|
||||||
CARD_DOOMSHROOM = 'card_doomshroom'
|
CARD_DOOMSHROOM = 'card_doomshroom'
|
||||||
|
CARD_GRAVEBUSTER = 'card_gravebuster'
|
||||||
|
|
||||||
# 子弹信息
|
# 子弹信息
|
||||||
# 子弹类型
|
# 子弹类型
|
||||||
|
|||||||
@ -385,6 +385,33 @@ class Level(tool.State):
|
|||||||
self.setupHugeWaveApprochingImage()
|
self.setupHugeWaveApprochingImage()
|
||||||
self.showHugeWaveApprochingTime = -2000 # 防止设置为0时刚刚打开游戏就已经启动红字
|
self.showHugeWaveApprochingTime = -2000 # 防止设置为0时刚刚打开游戏就已经启动红字
|
||||||
|
|
||||||
|
if self.map_data[c.BACKGROUND_TYPE] == c.BACKGROUND_NIGHT:
|
||||||
|
if c.GRADE_GRAVES in self.map_data:
|
||||||
|
gradeGraves = self.map_data[c.GRADE_GRAVES]
|
||||||
|
# 缺省为少量墓碑
|
||||||
|
else:
|
||||||
|
gradeGraves = c.GRADE1_GRAVES
|
||||||
|
|
||||||
|
if gradeGraves == c.GRADE1_GRAVES:
|
||||||
|
graveVolume = 4
|
||||||
|
elif gradeGraves == c.GRADE2_GRAVES:
|
||||||
|
graveVolume = 7
|
||||||
|
elif gradeGraves >= c.GRADE3_GRAVES:
|
||||||
|
graveVolume = 11
|
||||||
|
else:
|
||||||
|
graveVolume = 0
|
||||||
|
graveSet = set()
|
||||||
|
while len(graveSet) < graveVolume:
|
||||||
|
mapX = randint(4, 8) # 注意是从0开始编号
|
||||||
|
mapY = randint(0, 4)
|
||||||
|
graveSet.add((mapX, mapY))
|
||||||
|
if graveSet:
|
||||||
|
for i in graveSet:
|
||||||
|
mapX, mapY = i
|
||||||
|
posX, posY = self.map.getMapGridPos(mapX, mapY)
|
||||||
|
self.plant_groups[mapY].add(plant.Grave(posX, posY))
|
||||||
|
self.map.map[mapY][mapX][c.MAP_PLANT].add(c.GRAVE)
|
||||||
|
|
||||||
|
|
||||||
# 小菜单
|
# 小菜单
|
||||||
def setupLittleMenu(self):
|
def setupLittleMenu(self):
|
||||||
@ -491,7 +518,7 @@ class Level(tool.State):
|
|||||||
for i in self.plant_groups[map_y]:
|
for i in self.plant_groups[map_y]:
|
||||||
if (x >= i.rect.x and x <= i.rect.right and
|
if (x >= i.rect.x and x <= i.rect.right and
|
||||||
y >= i.rect.y and y <= i.rect.bottom):
|
y >= i.rect.y and y <= i.rect.bottom):
|
||||||
if i.name in {c.HOLE, c.ICE_FROZEN_PLOT}:
|
if i.name in {c.HOLE, c.ICE_FROZEN_PLOT, c.GRAVE}:
|
||||||
continue
|
continue
|
||||||
# 优先移除花盆、睡莲上的植物而非花盆、睡莲本身
|
# 优先移除花盆、睡莲上的植物而非花盆、睡莲本身
|
||||||
if len(self.map.map[map_y][map_x][c.MAP_PLANT]) >= 2:
|
if len(self.map.map[map_y][map_x][c.MAP_PLANT]) >= 2:
|
||||||
@ -794,6 +821,8 @@ class Level(tool.State):
|
|||||||
new_plant = plant.TangleKlep(x, y)
|
new_plant = plant.TangleKlep(x, y)
|
||||||
elif self.plant_name == c.DOOMSHROOM:
|
elif self.plant_name == c.DOOMSHROOM:
|
||||||
new_plant = plant.DoomShroom(x, y, self.map.map[map_y][map_x])
|
new_plant = plant.DoomShroom(x, y, self.map.map[map_y][map_x])
|
||||||
|
elif self.plant_name == c.GRAVEBUSTER:
|
||||||
|
new_plant = plant.GraveBuster(x, y, self.plant_groups[map_y], self.map, 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}:
|
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}:
|
||||||
@ -930,7 +959,7 @@ class Level(tool.State):
|
|||||||
elif plant.name in {c.LILYPAD, "花盆(未实现)"}:
|
elif plant.name in {c.LILYPAD, "花盆(未实现)"}:
|
||||||
attackableBackupPlant.append(plant)
|
attackableBackupPlant.append(plant)
|
||||||
# 注意要剔除掉两个“假植物”,以及不能被啃的地刺
|
# 注意要剔除掉两个“假植物”,以及不能被啃的地刺
|
||||||
elif plant.name not in {c.HOLE, c.ICE_FROZEN_PLOT, c.SPIKEWEED}:
|
elif plant.name not in {c.HOLE, c.ICE_FROZEN_PLOT, c.GRAVE, c.SPIKEWEED}:
|
||||||
attackableCommonPlants.append(plant)
|
attackableCommonPlants.append(plant)
|
||||||
else:
|
else:
|
||||||
if attackableCommonPlants:
|
if attackableCommonPlants:
|
||||||
@ -1043,7 +1072,7 @@ class Level(tool.State):
|
|||||||
self.boomZombies(targetPlant.rect.centerx, map_y, targetPlant.explode_y_range,
|
self.boomZombies(targetPlant.rect.centerx, map_y, targetPlant.explode_y_range,
|
||||||
targetPlant.explode_x_range, effect=c.BULLET_EFFECT_UNICE)
|
targetPlant.explode_x_range, effect=c.BULLET_EFFECT_UNICE)
|
||||||
elif targetPlant.name == c.ICESHROOM and targetPlant.state != c.SLEEP:
|
elif targetPlant.name == c.ICESHROOM and targetPlant.state != c.SLEEP:
|
||||||
self.freezeZombies(plant)
|
self.freezeZombies(targetPlant)
|
||||||
elif targetPlant.name == c.HYPNOSHROOM and targetPlant.state != c.SLEEP:
|
elif targetPlant.name == c.HYPNOSHROOM and targetPlant.state != c.SLEEP:
|
||||||
zombie = targetPlant.kill_zombie
|
zombie = targetPlant.kill_zombie
|
||||||
zombie.setHypno()
|
zombie.setHypno()
|
||||||
@ -1235,7 +1264,7 @@ class Level(tool.State):
|
|||||||
for i in self.plant_groups[map_y]:
|
for i in self.plant_groups[map_y]:
|
||||||
if (x >= i.rect.x and x <= i.rect.right and
|
if (x >= i.rect.x and x <= i.rect.right and
|
||||||
y >= i.rect.y and y <= i.rect.bottom):
|
y >= i.rect.y and y <= i.rect.bottom):
|
||||||
if i.name in {c.HOLE, c.ICE_FROZEN_PLOT}:
|
if i.name in {c.HOLE, c.ICE_FROZEN_PLOT, c.GRAVE}:
|
||||||
continue
|
continue
|
||||||
# 优先选中睡莲、花盆上的植物
|
# 优先选中睡莲、花盆上的植物
|
||||||
if len(self.map.map[map_y][map_x][c.MAP_PLANT]) >= 2:
|
if len(self.map.map[map_y][map_x][c.MAP_PLANT]) >= 2:
|
||||||
|
|||||||