diff --git a/resources/data/map/level_0.json b/resources/data/map/level_0.json index 58007dd..f574436 100644 --- a/resources/data/map/level_0.json +++ b/resources/data/map/level_0.json @@ -1,5 +1,5 @@ { - "background_type":2, + "background_type":1, "init_sun_value":5000, "shovel":1, "spawn_zombies":"list", diff --git a/resources/graphics/Cards/card_gravebuster.png b/resources/graphics/Cards/card_gravebuster.png new file mode 100644 index 0000000..e411f2b Binary files /dev/null and b/resources/graphics/Cards/card_gravebuster.png differ diff --git a/resources/graphics/Plants/Grave/Grave_0.png b/resources/graphics/Plants/Grave/Grave_0.png new file mode 100644 index 0000000..c77efef Binary files /dev/null and b/resources/graphics/Plants/Grave/Grave_0.png differ diff --git a/resources/graphics/Plants/Grave/Grave_1.png b/resources/graphics/Plants/Grave/Grave_1.png new file mode 100644 index 0000000..d18f3d6 Binary files /dev/null and b/resources/graphics/Plants/Grave/Grave_1.png differ diff --git a/resources/graphics/Plants/Grave/Grave_2.png b/resources/graphics/Plants/Grave/Grave_2.png new file mode 100644 index 0000000..9918938 Binary files /dev/null and b/resources/graphics/Plants/Grave/Grave_2.png differ diff --git a/resources/graphics/Plants/GraveBuster/GraveBuster_0.png b/resources/graphics/Plants/GraveBuster/GraveBuster_0.png new file mode 100644 index 0000000..022aa35 Binary files /dev/null and b/resources/graphics/Plants/GraveBuster/GraveBuster_0.png differ diff --git a/resources/graphics/Plants/GraveBuster/GraveBuster_1.png b/resources/graphics/Plants/GraveBuster/GraveBuster_1.png new file mode 100644 index 0000000..022aa35 Binary files /dev/null and b/resources/graphics/Plants/GraveBuster/GraveBuster_1.png differ diff --git a/resources/graphics/Plants/GraveBuster/GraveBuster_10.png b/resources/graphics/Plants/GraveBuster/GraveBuster_10.png new file mode 100644 index 0000000..01a2b95 Binary files /dev/null and b/resources/graphics/Plants/GraveBuster/GraveBuster_10.png differ diff --git a/resources/graphics/Plants/GraveBuster/GraveBuster_11.png b/resources/graphics/Plants/GraveBuster/GraveBuster_11.png new file mode 100644 index 0000000..812caea Binary files /dev/null and b/resources/graphics/Plants/GraveBuster/GraveBuster_11.png differ diff --git a/resources/graphics/Plants/GraveBuster/GraveBuster_12.png b/resources/graphics/Plants/GraveBuster/GraveBuster_12.png new file mode 100644 index 0000000..4f923c0 Binary files /dev/null and b/resources/graphics/Plants/GraveBuster/GraveBuster_12.png differ diff --git a/resources/graphics/Plants/GraveBuster/GraveBuster_13.png b/resources/graphics/Plants/GraveBuster/GraveBuster_13.png new file mode 100644 index 0000000..f4db68e Binary files /dev/null and b/resources/graphics/Plants/GraveBuster/GraveBuster_13.png differ diff --git a/resources/graphics/Plants/GraveBuster/GraveBuster_14.png b/resources/graphics/Plants/GraveBuster/GraveBuster_14.png new file mode 100644 index 0000000..c1bc114 Binary files /dev/null and b/resources/graphics/Plants/GraveBuster/GraveBuster_14.png differ diff --git a/resources/graphics/Plants/GraveBuster/GraveBuster_15.png b/resources/graphics/Plants/GraveBuster/GraveBuster_15.png new file mode 100644 index 0000000..938534d Binary files /dev/null and b/resources/graphics/Plants/GraveBuster/GraveBuster_15.png differ diff --git a/resources/graphics/Plants/GraveBuster/GraveBuster_16.png b/resources/graphics/Plants/GraveBuster/GraveBuster_16.png new file mode 100644 index 0000000..78e7a9e Binary files /dev/null and b/resources/graphics/Plants/GraveBuster/GraveBuster_16.png differ diff --git a/resources/graphics/Plants/GraveBuster/GraveBuster_17.png b/resources/graphics/Plants/GraveBuster/GraveBuster_17.png new file mode 100644 index 0000000..4e65ce0 Binary files /dev/null and b/resources/graphics/Plants/GraveBuster/GraveBuster_17.png differ diff --git a/resources/graphics/Plants/GraveBuster/GraveBuster_18.png b/resources/graphics/Plants/GraveBuster/GraveBuster_18.png new file mode 100644 index 0000000..778a325 Binary files /dev/null and b/resources/graphics/Plants/GraveBuster/GraveBuster_18.png differ diff --git a/resources/graphics/Plants/GraveBuster/GraveBuster_19.png b/resources/graphics/Plants/GraveBuster/GraveBuster_19.png new file mode 100644 index 0000000..2b2c0a8 Binary files /dev/null and b/resources/graphics/Plants/GraveBuster/GraveBuster_19.png differ diff --git a/resources/graphics/Plants/GraveBuster/GraveBuster_2.png b/resources/graphics/Plants/GraveBuster/GraveBuster_2.png new file mode 100644 index 0000000..1afd955 Binary files /dev/null and b/resources/graphics/Plants/GraveBuster/GraveBuster_2.png differ diff --git a/resources/graphics/Plants/GraveBuster/GraveBuster_20.png b/resources/graphics/Plants/GraveBuster/GraveBuster_20.png new file mode 100644 index 0000000..67b292e Binary files /dev/null and b/resources/graphics/Plants/GraveBuster/GraveBuster_20.png differ diff --git a/resources/graphics/Plants/GraveBuster/GraveBuster_21.png b/resources/graphics/Plants/GraveBuster/GraveBuster_21.png new file mode 100644 index 0000000..1cc38c6 Binary files /dev/null and b/resources/graphics/Plants/GraveBuster/GraveBuster_21.png differ diff --git a/resources/graphics/Plants/GraveBuster/GraveBuster_22.png b/resources/graphics/Plants/GraveBuster/GraveBuster_22.png new file mode 100644 index 0000000..acbfef9 Binary files /dev/null and b/resources/graphics/Plants/GraveBuster/GraveBuster_22.png differ diff --git a/resources/graphics/Plants/GraveBuster/GraveBuster_23.png b/resources/graphics/Plants/GraveBuster/GraveBuster_23.png new file mode 100644 index 0000000..69047ce Binary files /dev/null and b/resources/graphics/Plants/GraveBuster/GraveBuster_23.png differ diff --git a/resources/graphics/Plants/GraveBuster/GraveBuster_24.png b/resources/graphics/Plants/GraveBuster/GraveBuster_24.png new file mode 100644 index 0000000..409e739 Binary files /dev/null and b/resources/graphics/Plants/GraveBuster/GraveBuster_24.png differ diff --git a/resources/graphics/Plants/GraveBuster/GraveBuster_25.png b/resources/graphics/Plants/GraveBuster/GraveBuster_25.png new file mode 100644 index 0000000..4787816 Binary files /dev/null and b/resources/graphics/Plants/GraveBuster/GraveBuster_25.png differ diff --git a/resources/graphics/Plants/GraveBuster/GraveBuster_26.png b/resources/graphics/Plants/GraveBuster/GraveBuster_26.png new file mode 100644 index 0000000..e16bc0e Binary files /dev/null and b/resources/graphics/Plants/GraveBuster/GraveBuster_26.png differ diff --git a/resources/graphics/Plants/GraveBuster/GraveBuster_27.png b/resources/graphics/Plants/GraveBuster/GraveBuster_27.png new file mode 100644 index 0000000..b41dd9b Binary files /dev/null and b/resources/graphics/Plants/GraveBuster/GraveBuster_27.png differ diff --git a/resources/graphics/Plants/GraveBuster/GraveBuster_28.png b/resources/graphics/Plants/GraveBuster/GraveBuster_28.png new file mode 100644 index 0000000..7a8ac20 Binary files /dev/null and b/resources/graphics/Plants/GraveBuster/GraveBuster_28.png differ diff --git a/resources/graphics/Plants/GraveBuster/GraveBuster_29.png b/resources/graphics/Plants/GraveBuster/GraveBuster_29.png new file mode 100644 index 0000000..ca54dd9 Binary files /dev/null and b/resources/graphics/Plants/GraveBuster/GraveBuster_29.png differ diff --git a/resources/graphics/Plants/GraveBuster/GraveBuster_3.png b/resources/graphics/Plants/GraveBuster/GraveBuster_3.png new file mode 100644 index 0000000..e45d48a Binary files /dev/null and b/resources/graphics/Plants/GraveBuster/GraveBuster_3.png differ diff --git a/resources/graphics/Plants/GraveBuster/GraveBuster_30.png b/resources/graphics/Plants/GraveBuster/GraveBuster_30.png new file mode 100644 index 0000000..cf42c8b Binary files /dev/null and b/resources/graphics/Plants/GraveBuster/GraveBuster_30.png differ diff --git a/resources/graphics/Plants/GraveBuster/GraveBuster_31.png b/resources/graphics/Plants/GraveBuster/GraveBuster_31.png new file mode 100644 index 0000000..ba48af0 Binary files /dev/null and b/resources/graphics/Plants/GraveBuster/GraveBuster_31.png differ diff --git a/resources/graphics/Plants/GraveBuster/GraveBuster_32.png b/resources/graphics/Plants/GraveBuster/GraveBuster_32.png new file mode 100644 index 0000000..f59befd Binary files /dev/null and b/resources/graphics/Plants/GraveBuster/GraveBuster_32.png differ diff --git a/resources/graphics/Plants/GraveBuster/GraveBuster_33.png b/resources/graphics/Plants/GraveBuster/GraveBuster_33.png new file mode 100644 index 0000000..cd18133 Binary files /dev/null and b/resources/graphics/Plants/GraveBuster/GraveBuster_33.png differ diff --git a/resources/graphics/Plants/GraveBuster/GraveBuster_34.png b/resources/graphics/Plants/GraveBuster/GraveBuster_34.png new file mode 100644 index 0000000..c6433fb Binary files /dev/null and b/resources/graphics/Plants/GraveBuster/GraveBuster_34.png differ diff --git a/resources/graphics/Plants/GraveBuster/GraveBuster_35.png b/resources/graphics/Plants/GraveBuster/GraveBuster_35.png new file mode 100644 index 0000000..9313c71 Binary files /dev/null and b/resources/graphics/Plants/GraveBuster/GraveBuster_35.png differ diff --git a/resources/graphics/Plants/GraveBuster/GraveBuster_36.png b/resources/graphics/Plants/GraveBuster/GraveBuster_36.png new file mode 100644 index 0000000..c8f04ad Binary files /dev/null and b/resources/graphics/Plants/GraveBuster/GraveBuster_36.png differ diff --git a/resources/graphics/Plants/GraveBuster/GraveBuster_37.png b/resources/graphics/Plants/GraveBuster/GraveBuster_37.png new file mode 100644 index 0000000..1b07a02 Binary files /dev/null and b/resources/graphics/Plants/GraveBuster/GraveBuster_37.png differ diff --git a/resources/graphics/Plants/GraveBuster/GraveBuster_38.png b/resources/graphics/Plants/GraveBuster/GraveBuster_38.png new file mode 100644 index 0000000..593fc0a Binary files /dev/null and b/resources/graphics/Plants/GraveBuster/GraveBuster_38.png differ diff --git a/resources/graphics/Plants/GraveBuster/GraveBuster_39.png b/resources/graphics/Plants/GraveBuster/GraveBuster_39.png new file mode 100644 index 0000000..3e4987e Binary files /dev/null and b/resources/graphics/Plants/GraveBuster/GraveBuster_39.png differ diff --git a/resources/graphics/Plants/GraveBuster/GraveBuster_4.png b/resources/graphics/Plants/GraveBuster/GraveBuster_4.png new file mode 100644 index 0000000..462491f Binary files /dev/null and b/resources/graphics/Plants/GraveBuster/GraveBuster_4.png differ diff --git a/resources/graphics/Plants/GraveBuster/GraveBuster_40.png b/resources/graphics/Plants/GraveBuster/GraveBuster_40.png new file mode 100644 index 0000000..5a7212b Binary files /dev/null and b/resources/graphics/Plants/GraveBuster/GraveBuster_40.png differ diff --git a/resources/graphics/Plants/GraveBuster/GraveBuster_41.png b/resources/graphics/Plants/GraveBuster/GraveBuster_41.png new file mode 100644 index 0000000..04563ee Binary files /dev/null and b/resources/graphics/Plants/GraveBuster/GraveBuster_41.png differ diff --git a/resources/graphics/Plants/GraveBuster/GraveBuster_42.png b/resources/graphics/Plants/GraveBuster/GraveBuster_42.png new file mode 100644 index 0000000..682d8ae Binary files /dev/null and b/resources/graphics/Plants/GraveBuster/GraveBuster_42.png differ diff --git a/resources/graphics/Plants/GraveBuster/GraveBuster_5.png b/resources/graphics/Plants/GraveBuster/GraveBuster_5.png new file mode 100644 index 0000000..92188fd Binary files /dev/null and b/resources/graphics/Plants/GraveBuster/GraveBuster_5.png differ diff --git a/resources/graphics/Plants/GraveBuster/GraveBuster_6.png b/resources/graphics/Plants/GraveBuster/GraveBuster_6.png new file mode 100644 index 0000000..693a93c Binary files /dev/null and b/resources/graphics/Plants/GraveBuster/GraveBuster_6.png differ diff --git a/resources/graphics/Plants/GraveBuster/GraveBuster_7.png b/resources/graphics/Plants/GraveBuster/GraveBuster_7.png new file mode 100644 index 0000000..7705473 Binary files /dev/null and b/resources/graphics/Plants/GraveBuster/GraveBuster_7.png differ diff --git a/resources/graphics/Plants/GraveBuster/GraveBuster_8.png b/resources/graphics/Plants/GraveBuster/GraveBuster_8.png new file mode 100644 index 0000000..41ec67a Binary files /dev/null and b/resources/graphics/Plants/GraveBuster/GraveBuster_8.png differ diff --git a/resources/graphics/Plants/GraveBuster/GraveBuster_9.png b/resources/graphics/Plants/GraveBuster/GraveBuster_9.png new file mode 100644 index 0000000..a1dfedb Binary files /dev/null and b/resources/graphics/Plants/GraveBuster/GraveBuster_9.png differ diff --git a/source/component/map.py b/source/component/map.py index cd5b760..237ce48 100755 --- a/source/component/map.py +++ b/source/component/map.py @@ -41,14 +41,21 @@ class Map(): # 由于紫卡植物需要移除以前的植物,所以可用另外定义一个函数 # 注意咖啡豆生效后需要同时将植物的睡眠状态和格子的睡眠记录改变 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 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 == 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 plantName not in {c.LILYPAD, c.SEASHROOM, c.TANGLEKLEP}: # 这里的集合也可以换成存储在某一文件中的常数的表达 diff --git a/source/component/menubar.py b/source/component/menubar.py index e6bc21d..91f6f28 100755 --- a/source/component/menubar.py +++ b/source/component/menubar.py @@ -45,6 +45,10 @@ plantInfo = (# 元组 (植物名称, 卡片名称, 阳光, 冷却时间) c.CARD_SUNSHROOM, 25, 7500), + (c.GRAVEBUSTER, + c.CARD_GRAVEBUSTER, + 75, + 7500), (c.HYPNOSHROOM, c.CARD_HYPNOSHROOM, 75, diff --git a/source/component/plant.py b/source/component/plant.py index 6eed6ee..5e6ee73 100755 --- a/source/component/plant.py +++ b/source/component/plant.py @@ -923,6 +923,8 @@ class IceShroom(Plant): return self.animate_timer = self.current_time else: + if self.state != c.SLEEP: + self.health = c.INF if (self.current_time - self.animate_timer) > 100: self.frame_index += 1 if self.frame_index >= self.frame_num: @@ -1431,4 +1433,44 @@ class Hole(Plant): self.frames = self.idle2_frames self.shallow = True elif self.current_time - self.timer >= 180000: - self.health = 0 \ No newline at end of file + 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) diff --git a/source/constants.py b/source/constants.py index d257a08..92204ce 100755 --- a/source/constants.py +++ b/source/constants.py @@ -104,6 +104,13 @@ BACKGROUND_WALLNUTBOWLING = 6 BACKGROUND_SINGLE = 7 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_AUTO = 'auto' @@ -207,6 +214,9 @@ TANGLEKLEP = 'TangleKlep' DOOMSHROOM = 'DoomShroom' ICE_FROZEN_PLOT = 'IceFrozenPlot' HOLE = 'Hole' +GRAVE = 'Grave' +GRAVEBUSTER = 'GraveBuster' + # 植物生命值 PLANT_HEALTH = 300 @@ -257,6 +267,7 @@ CARD_SEASHROOM = 'card_seashroom' CARD_TALLNUT = 'card_tallnut' CARD_TANGLEKLEP = 'card_tangleklep' CARD_DOOMSHROOM = 'card_doomshroom' +CARD_GRAVEBUSTER = 'card_gravebuster' # 子弹信息 # 子弹类型 diff --git a/source/state/level.py b/source/state/level.py index 1c3a610..e93b3dc 100644 --- a/source/state/level.py +++ b/source/state/level.py @@ -385,6 +385,33 @@ class Level(tool.State): self.setupHugeWaveApprochingImage() 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): @@ -491,7 +518,7 @@ class Level(tool.State): for i in self.plant_groups[map_y]: if (x >= i.rect.x and x <= i.rect.right and 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 # 优先移除花盆、睡莲上的植物而非花盆、睡莲本身 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) elif self.plant_name == c.DOOMSHROOM: 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}: @@ -930,7 +959,7 @@ class Level(tool.State): elif plant.name in {c.LILYPAD, "花盆(未实现)"}: 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) else: if attackableCommonPlants: @@ -1043,7 +1072,7 @@ class Level(tool.State): self.boomZombies(targetPlant.rect.centerx, map_y, targetPlant.explode_y_range, targetPlant.explode_x_range, effect=c.BULLET_EFFECT_UNICE) 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: zombie = targetPlant.kill_zombie zombie.setHypno() @@ -1235,7 +1264,7 @@ class Level(tool.State): for i in self.plant_groups[map_y]: if (x >= i.rect.x and x <= i.rect.right and 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 # 优先选中睡莲、花盆上的植物 if len(self.map.map[map_y][map_x][c.MAP_PLANT]) >= 2: