diff --git a/source/component/plant.py b/source/component/plant.py index bea2d0c..782a0d2 100755 --- a/source/component/plant.py +++ b/source/component/plant.py @@ -128,6 +128,8 @@ class Plant(pg.sprite.Sprite): self.animate_timer = 0 self.animate_interval = 70 # 帧播放间隔 self.hit_timer = 0 + # 被铲子指向时间 + self.highlightTime = 0 def loadFrames(self, frames, name, scale, color=c.BLACK): frame_list = tool.GFX[name] @@ -188,10 +190,10 @@ class Plant(pg.sprite.Sprite): self.animate_timer = self.current_time self.image = self.frames[self.frame_index] - if (self.current_time - self.hit_timer) >= 200: - self.image.set_alpha(255) + if ((self.current_time - self.hit_timer) < 200) or (self.current_time - self.highlightTime < 200): + self.image.set_alpha(180) else: - self.image.set_alpha(192) + self.image.set_alpha(255) def canAttack(self, zombie): if (self.state != c.SLEEP and zombie.state != c.DIE and (not zombie.lostHead) and diff --git a/source/state/level.py b/source/state/level.py index 1f16618..f379da7 100644 --- a/source/state/level.py +++ b/source/state/level.py @@ -809,10 +809,17 @@ class Level(tool.State): self.mouse_rect.centery = y surface.blit(self.mouse_image, self.mouse_rect) - def drawMouseShowPlus(self, surface): + def drawMouseShowPlus(self, surface): # 拖动铲子时的显示 x, y = pg.mouse.get_pos() self.shovel_rect.centerx = x self.shovel_rect.centery = y + map_x, map_y = self.map.getMapIndex(x, y) + 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): + i.highlightTime = self.current_time + else: + i.highlight = False surface.blit(self.shovel, self.shovel_rect) def drawZombieFreezeTrap(self, i, surface):