From 46780ee81e8fad7faf6d9337108d0a6388f0b2b7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=98=9F=E5=A4=96=E4=B9=8B=E7=A5=9E?= Date: Wed, 11 May 2022 13:13:18 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=9C=9F=E8=B1=86=E9=9B=B7?= =?UTF-8?q?=E5=AF=B9=E6=92=91=E6=9D=86=E8=B7=B3=E7=9A=84=E6=A3=80=E6=9F=A5?= =?UTF-8?q?=E6=9C=BA=E5=88=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- source/component/map.py | 2 +- source/component/plant.py | 4 +++- source/state/level.py | 29 +++++++++++++---------------- 3 files changed, 17 insertions(+), 18 deletions(-) diff --git a/source/component/map.py b/source/component/map.py index bc4745d..1f65f97 100755 --- a/source/component/map.py +++ b/source/component/map.py @@ -144,7 +144,7 @@ class Map(): self.map[map_y][map_x][c.MAP_SLEEP] = sleep def removeMapPlant(self, map_x, map_y, plantName): - self.map[map_y][map_x][c.MAP_PLANT].remove(plantName) + self.map[map_y][map_x][c.MAP_PLANT].discard(plantName) def getRandomMapIndex(self): map_x = random.randint(0, self.width-1) diff --git a/source/component/plant.py b/source/component/plant.py index 10c586e..422e122 100755 --- a/source/component/plant.py +++ b/source/component/plant.py @@ -705,7 +705,9 @@ class PotatoMine(Plant): self.is_init = False def canAttack(self, zombie): - if (pg.sprite.collide_circle_ratio(0.55)(zombie, self) and + if (self.name == c.POLE_VAULTING_ZOMBIE and (not self.jumped)): + return False + elif (pg.sprite.collide_circle_ratio(0.55)(zombie, self) and (not self.is_init) and (not zombie.lostHead)): return True return False diff --git a/source/state/level.py b/source/state/level.py index 2675802..df1d3dc 100644 --- a/source/state/level.py +++ b/source/state/level.py @@ -408,18 +408,18 @@ class Level(tool.State): self.numZombie = 0 # 新的僵尸生成机制:级别——权重生成 self.createZombieInfo = {# 生成僵尸:(级别, 权重) - c.NORMAL_ZOMBIE:(1, 4000), - c.FLAG_ZOMBIE:(1, 0), - c.CONEHEAD_ZOMBIE:(2, 4000), - c.BUCKETHEAD_ZOMBIE:(4, 3000), - c.NEWSPAPER_ZOMBIE:(2, 1000), - c.FOOTBALL_ZOMBIE:(7, 2000), - c.DUCKY_TUBE_ZOMBIE:(1, 0), # 作为变种,不主动生成 - c.CONEHEAD_DUCKY_TUBE_ZOMBIE:(2, 0), # 作为变种,不主动生成 - c.BUCKETHEAD_DUCKY_TUBE_ZOMBIE:(4, 0), # 作为变种,不主动生成 - c.SCREEN_DOOR_ZOMBIE:(4, 3500), - c.POLE_VAULTING_ZOMBIE:(2, 2000), - } + c.NORMAL_ZOMBIE:(1, 4000), + c.FLAG_ZOMBIE:(1, 0), + c.CONEHEAD_ZOMBIE:(2, 4000), + c.BUCKETHEAD_ZOMBIE:(4, 3000), + c.NEWSPAPER_ZOMBIE:(2, 1000), + c.FOOTBALL_ZOMBIE:(7, 2000), + c.DUCKY_TUBE_ZOMBIE:(1, 0), # 作为变种,不主动生成 + c.CONEHEAD_DUCKY_TUBE_ZOMBIE:(2, 0), # 作为变种,不主动生成 + c.BUCKETHEAD_DUCKY_TUBE_ZOMBIE:(4, 0), # 作为变种,不主动生成 + c.SCREEN_DOOR_ZOMBIE:(4, 3500), + c.POLE_VAULTING_ZOMBIE:(2, 2000), + } # 将僵尸与水上变种对应 self.convertZombieInPool = {c.NORMAL_ZOMBIE:c.DUCKY_TUBE_ZOMBIE, c.CONEHEAD_ZOMBIE:c.CONEHEAD_DUCKY_TUBE_ZOMBIE, @@ -1191,10 +1191,7 @@ class Level(tool.State): # 整理地图信息 if self.bar_type != c.CHOSSEBAR_BOWLING: - try: # 避免炸弹等本身就不在集合里面的问题 - self.map.removeMapPlant(map_x, map_y, targetPlant.name) - except KeyError: - pass + self.map.removeMapPlant(map_x, map_y, targetPlant.name) # 将睡眠植物移除后更新睡眠状态 if targetPlant.state == c.SLEEP: self.map.map[map_y][map_x][c.MAP_SLEEP] = False