diff --git a/source/component/plant.py b/source/component/plant.py index 4afbc5a..854b5aa 100755 --- a/source/component/plant.py +++ b/source/component/plant.py @@ -312,7 +312,7 @@ class Plant(pg.sprite.Sprite): self.image = self.frames[self.frame_index] self.mask = pg.mask.from_surface(self.image) - if (self.current_time - self.highlightTime < 200): + if (self.current_time - self.highlightTime < 100): self.image.set_alpha(150) elif ((self.current_time - self.hit_timer) < 200): self.image.set_alpha(192) @@ -576,8 +576,15 @@ class CherryBomb(Plant): return self.animate_timer = self.current_time - self.image = self.frames[self.frame_index] - self.mask = pg.mask.from_surface(self.image) + self.image = self.frames[self.frame_index] + self.mask = pg.mask.from_surface(self.image) + + if (self.current_time - self.highlightTime < 100): + self.image.set_alpha(150) + elif ((self.current_time - self.hit_timer) < 200): + self.image.set_alpha(192) + else: + self.image.set_alpha(255) class Chomper(Plant): @@ -908,6 +915,13 @@ class Jalapeno(Plant): self.image = self.frames[self.frame_index] self.mask = pg.mask.from_surface(self.image) + if (self.current_time - self.highlightTime < 100): + self.image.set_alpha(150) + elif ((self.current_time - self.hit_timer) < 200): + self.image.set_alpha(192) + else: + self.image.set_alpha(255) + def getPosition(self): return self.orig_pos @@ -1068,6 +1082,13 @@ class IceShroom(Plant): self.image = self.frames[self.frame_index] self.mask = pg.mask.from_surface(self.image) + if (self.current_time - self.highlightTime < 100): + self.image.set_alpha(150) + elif ((self.current_time - self.hit_timer) < 200): + self.image.set_alpha(192) + else: + self.image.set_alpha(255) + def getPosition(self): return self.orig_pos @@ -1349,7 +1370,7 @@ class CoffeeBean(Plant): self.image = self.frames[self.frame_index] self.mask = pg.mask.from_surface(self.image) - if (self.current_time - self.highlightTime < 200): + if (self.current_time - self.highlightTime < 100): self.image.set_alpha(150) elif ((self.current_time - self.hit_timer) < 200): self.image.set_alpha(192) @@ -1488,7 +1509,7 @@ class DoomShroom(Plant): if mapContent[c.MAP_PLOT_TYPE] == c.MAP_GRASS: self.explode_y_range = 2 else: - self.explode_y_range = 2 + self.explode_y_range = 3 self.explode_x_range = c.GRID_X_SIZE * 2.5 self.start_boom = False self.boomed = False @@ -1549,6 +1570,13 @@ class DoomShroom(Plant): self.image = self.frames[self.frame_index] self.mask = pg.mask.from_surface(self.image) + if (self.current_time - self.highlightTime < 100): + self.image.set_alpha(150) + elif ((self.current_time - self.hit_timer) < 200): + self.image.set_alpha(192) + else: + self.image.set_alpha(255) + # 用于描述毁灭菇的坑 class Hole(Plant): def __init__(self, x, y, plotType): @@ -1642,7 +1670,8 @@ class GraveBuster(Plant): self.image = self.frames[self.frame_index] self.mask = pg.mask.from_surface(self.image) - if (self.current_time - self.highlightTime < 200): + + if (self.current_time - self.highlightTime < 100): self.image.set_alpha(150) elif ((self.current_time - self.hit_timer) < 200): self.image.set_alpha(192) @@ -1716,7 +1745,8 @@ class FumeShroom(Plant): self.image = self.frames[self.frame_index] self.mask = pg.mask.from_surface(self.image) - if (self.current_time - self.highlightTime < 200): + + if (self.current_time - self.highlightTime < 100): self.image.set_alpha(150) elif ((self.current_time - self.hit_timer) < 200): self.image.set_alpha(192) diff --git a/source/state/level.py b/source/state/level.py index 656a08c..3b3df51 100644 --- a/source/state/level.py +++ b/source/state/level.py @@ -616,6 +616,9 @@ class Level(tool.State): y >= i.rect.y and y <= i.rect.bottom): if i.name in c.NON_PLANT_OBJECTS: continue + if i.name in c.SKIP_ZOMBIE_COLLISION_CHECK_WHEN_WORKING: + if i.start_boom: + continue # 优先移除花盆、睡莲上的植物而非花盆、睡莲本身 if len(self.map.map[map_y][map_x][c.MAP_PLANT]) >= 2: if c.LILYPAD in self.map.map[map_y][map_x][c.MAP_PLANT]: @@ -1316,7 +1319,7 @@ class Level(tool.State): if item.name == c.ICE_FROZEN_PLOT: item.health = 0 elif targetPlant.name == c.ICESHROOM: - self.freezeZombies(targetPlant) + self.freezeZombies(targetPlant) targetPlant.boomed = True else: can_attack = False @@ -1345,14 +1348,13 @@ class Level(tool.State): for i in range(self.map_y_len): if len(self.zombie_groups[i]) > 0: return False - return True else: if self.waveNum < self.map_data[c.NUM_FLAGS] * 10: return False for i in range(self.map_y_len): if len(self.zombie_groups[i]) > 0: return False - return True + return True def checkLose(self): for i in range(self.map_y_len): @@ -1398,6 +1400,9 @@ class Level(tool.State): y >= i.rect.y and y <= i.rect.bottom): if i.name in c.NON_PLANT_OBJECTS: continue + if i.name in c.SKIP_ZOMBIE_COLLISION_CHECK_WHEN_WORKING: + if i.start_boom: + continue # 优先选中睡莲、花盆上的植物 if len(self.map.map[map_y][map_x][c.MAP_PLANT]) >= 2: if c.LILYPAD in self.map.map[map_y][map_x][c.MAP_PLANT]: