From bf6a81885ea993600b14aa0511147fc54483d009 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, 4 May 2022 12:53:17 +0800 Subject: [PATCH] =?UTF-8?q?=E5=9F=BA=E6=9C=AC=E5=AE=9E=E7=8E=B0=E9=B8=AD?= =?UTF-8?q?=E5=AD=90=E6=95=91=E7=94=9F=E5=9C=88=E5=83=B5=E5=B0=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- resources/data/map/level_0.json | 2 +- source/component/zombie.py | 15 +++++++++++++++ source/constants.py | 2 +- source/state/level.py | 2 ++ 4 files changed, 19 insertions(+), 2 deletions(-) diff --git a/resources/data/map/level_0.json b/resources/data/map/level_0.json index 140f069..69ec35b 100644 --- a/resources/data/map/level_0.json +++ b/resources/data/map/level_0.json @@ -4,7 +4,7 @@ "shovel":1, "spawn_zombies":"list", "zombie_list":[ - {"time":1000, "map_y":2, "name":"DuckyTubeZombie"}, + {"time":0, "map_y":3, "name":"DuckyTubeZombie"}, {"time":60000, "map_y":2, "name":"Zombie"} ] } \ No newline at end of file diff --git a/source/component/zombie.py b/source/component/zombie.py index 9e87151..ea31d48 100755 --- a/source/component/zombie.py +++ b/source/component/zombie.py @@ -24,6 +24,8 @@ class Zombie(pg.sprite.Sprite): self.damage = damage self.dead = False self.lostHead = False + self.canSwim = canSwim + self.swimming = False self.helmet = (self.helmetHealth > 0) self.helmetType2 = (self.helmetType2Health > 0) self.head_group = head_group @@ -104,6 +106,13 @@ class Zombie(pg.sprite.Sprite): if self.name == c.NEWSPAPER_ZOMBIE: self.speed = 2.5 + if self.canSwim: + if self.rect.right <= c.MAP_POOL_FRONT_X: + if not self.swimming: + self.changeFrames(self.swim_frames) + self.swimming = True + # 待写带有盔甲的水生僵尸丢盔甲的判断 + if (self.current_time - self.walk_timer) > (c.ZOMBIE_WALK_INTERVAL * self.getTimeRatio()): self.walk_timer = self.current_time if self.is_hypno: @@ -305,6 +314,12 @@ class Zombie(pg.sprite.Sprite): else: self.changeFrames(self.walk_frames) + if self.canSwim: + if self.rect.right <= c.MAP_POOL_FRONT_X: + self.changeFrames(self.swim_frames) + self.swimming = True + # 待写带有盔甲的水生僵尸丢盔甲的判断 + def setAttack(self, prey, is_plant=True): self.prey = prey # prey can be plant or other zombies self.prey_is_plant = is_plant diff --git a/source/constants.py b/source/constants.py index adc1f82..513c0a2 100755 --- a/source/constants.py +++ b/source/constants.py @@ -142,7 +142,7 @@ MAP_ROOF_OFFSET_X = 35 # 暂时还不清楚数据 MAP_ROOF_OFFSET_Y = 105 # 暂时还不清楚数据 # 泳池前端陆地部分 -MAP_POOL_FRONT_X = 770 +MAP_POOL_FRONT_X = SCREEN_WIDTH - 15 # 植物选择菜单栏、传送带菜单栏等类型设定 CHOOSEBAR_TYPE = 'choosebar_type' diff --git a/source/state/level.py b/source/state/level.py index 96f6a39..7b2adfa 100644 --- a/source/state/level.py +++ b/source/state/level.py @@ -833,6 +833,8 @@ class Level(tool.State): if zombie.state != c.WALK: if not self.refreshZombieAttack: continue + if zombie.canSwim and (not zombie.swimming): + continue plant = pg.sprite.spritecollideany(zombie, self.plant_groups[i], collided_func) if plant: if plant.name == c.WALLNUTBOWLING: