diff --git a/source/component/map.py b/source/component/map.py index 7330a6a..8fbb0ca 100755 --- a/source/component/map.py +++ b/source/component/map.py @@ -35,7 +35,7 @@ class Map(): map_y < 0 or map_y >= self.height): return False return True - + # 判断位置是否可用 # 暂时没有写紫卡植物的判断方法 # 由于紫卡植物需要移除以前的植物,所以可用另外定义一个函数 diff --git a/source/component/plant.py b/source/component/plant.py index 854b5aa..a3a8c37 100755 --- a/source/component/plant.py +++ b/source/component/plant.py @@ -1500,17 +1500,13 @@ class TangleKlep(Plant): # 坑形态的毁灭菇同地刺一样不可以被啃食 # 爆炸时杀死同一格的所有植物 class DoomShroom(Plant): - def __init__(self, x, y, mapContent): + def __init__(self, x, y, mapPlantsSet, explode_y_range): Plant.__init__(self, x, y, c.DOOMSHROOM, c.PLANT_HEALTH, None) self.can_sleep = True - self.mapContent = mapContent + self.mapPlantSet = mapPlantsSet self.bomb_timer = 0 - # 不同场景由于格子的长不同,范围有变化 - if mapContent[c.MAP_PLOT_TYPE] == c.MAP_GRASS: - self.explode_y_range = 2 - else: - self.explode_y_range = 3 - self.explode_x_range = c.GRID_X_SIZE * 2.5 + self.explode_y_range = explode_y_range + self.explode_x_range = 250 self.start_boom = False self.boomed = False self.originalX = x @@ -1550,7 +1546,7 @@ class DoomShroom(Plant): if self.frame_index >= self.frame_num: self.health = 0 self.frame_index = self.frame_num - 1 - self.mapContent[c.MAP_PLANT].add(c.HOLE) + self.mapPlantSet.add(c.HOLE) # 睡觉状态 elif self.state == c.SLEEP: if (self.current_time - self.animate_timer) > self.animate_interval: diff --git a/source/state/level.py b/source/state/level.py index ea1b23b..c3d62e0 100644 --- a/source/state/level.py +++ b/source/state/level.py @@ -896,7 +896,11 @@ class Level(tool.State): elif self.plant_name == c.TANGLEKLEP: 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]) + if ((self.map_data[c.BACKGROUND_TYPE] in c.ON_ROOF_BACKGROUNDS) or + (self.map_data[c.BACKGROUND_TYPE] in c.POOL_EQUIPPED_BACKGROUNDS)): + new_plant = plant.DoomShroom(x, y, self.map.map[map_y][map_x][c.MAP_PLANT], explode_y_range=3) + else: + new_plant = plant.DoomShroom(x, y, self.map.map[map_y][map_x][c.MAP_PLANT], explode_y_range=2) elif self.plant_name == c.GRAVEBUSTER: new_plant = plant.GraveBuster(x, y, self.plant_groups[map_y], self.map, map_x) elif self.plant_name == c.FUMESHROOM: