From d495aef2f90c4cf867e7d56aff7e04f6c5bcb1c9 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, 13 Apr 2022 23:16:19 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E5=83=B5=E5=B0=B8=E7=8A=B6?= =?UTF-8?q?=E6=80=81=E6=A3=80=E6=9F=A5bug=EF=BC=9B=E6=9B=B4=E6=94=B9?= =?UTF-8?q?=E8=B4=B4=E5=9B=BE=E4=BD=8D=E7=BD=AE=EF=BC=9B=E6=94=B9=E5=8F=98?= =?UTF-8?q?=E5=83=B5=E5=B0=B8=E5=8A=A8=E7=94=BB=E5=B8=A7=E7=8E=87=EF=BC=9B?= =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E9=93=B2=E5=AD=90=E5=AF=BC=E5=85=A5=E6=A3=80?= =?UTF-8?q?=E6=9F=A5=EF=BC=9B=E4=BF=AE=E5=A4=8D=E5=96=B7=E8=8F=87=E5=AD=90?= =?UTF-8?q?=E5=BC=B9=E6=9C=89=E5=86=B0=E5=86=BB=E7=9A=84bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- resources/data/map/level_0.json | 2 +- source/component/menubar.py | 2 +- source/component/plant.py | 4 ++-- source/component/zombie.py | 18 ++++-------------- source/state/level.py | 15 ++++++++------- 5 files changed, 16 insertions(+), 25 deletions(-) diff --git a/resources/data/map/level_0.json b/resources/data/map/level_0.json index 6d65538..0a52643 100644 --- a/resources/data/map/level_0.json +++ b/resources/data/map/level_0.json @@ -3,7 +3,7 @@ "init_sun_value":5000, "shovel":1, "zombie_list":[ - {"time":1000, "map_y":2, "name":"Zombie"}, + {"time":1000, "map_y":2, "name":"NewspaperZombie"}, {"time":60000, "map_y":2, "name":"Zombie"} ] } \ No newline at end of file diff --git a/source/component/menubar.py b/source/component/menubar.py index 8179e6a..2ed9d3c 100755 --- a/source/component/menubar.py +++ b/source/component/menubar.py @@ -136,7 +136,7 @@ class MenuBar(): self.rect.y = 0 self.sun_value = sun_value - self.card_offset_x = 32 + self.card_offset_x = 23 self.setupCards(card_list) def loadFrame(self, name): diff --git a/source/component/plant.py b/source/component/plant.py index 40988eb..8769993 100755 --- a/source/component/plant.py +++ b/source/component/plant.py @@ -494,7 +494,7 @@ class PuffShroom(Plant): def attacking(self): if (self.current_time - self.shoot_timer) > 1400: self.bullet_group.add(Bullet(self.rect.right, self.rect.y + 10, self.rect.y + 10, - c.BULLET_MUSHROOM, c.BULLET_DAMAGE_NORMAL, True)) + c.BULLET_MUSHROOM, c.BULLET_DAMAGE_NORMAL, False)) self.shoot_timer = self.current_time def canAttack(self, zombie): @@ -744,7 +744,7 @@ class ScaredyShroom(Plant): def attacking(self): if (self.current_time - self.shoot_timer) > 1400: self.bullet_group.add(Bullet(self.rect.right - 15, self.rect.y + 40, self.rect.y + 40, - c.BULLET_MUSHROOM, c.BULLET_DAMAGE_NORMAL, True)) + c.BULLET_MUSHROOM, c.BULLET_DAMAGE_NORMAL, False)) self.shoot_timer = self.current_time diff --git a/source/component/zombie.py b/source/component/zombie.py index 525c943..671d5b6 100755 --- a/source/component/zombie.py +++ b/source/component/zombie.py @@ -89,7 +89,6 @@ class Zombie(pg.sprite.Sprite): self.helmetType2 = False if self.name == c.NEWSPAPER_ZOMBIE: self.speed = 2.5 - self.animate_interval = 300 # 因为加速了时间间隔要除以倍率,所以减小动画帧率 if (self.current_time - self.walk_timer) > (c.ZOMBIE_WALK_INTERVAL * self.getTimeRatio()): self.walk_timer = self.current_time @@ -107,6 +106,8 @@ class Zombie(pg.sprite.Sprite): if self.helmetType2Health <= 0 and self.helmetType2: self.changeFrames(self.attack_frames) self.helmetType2 = False + if self.name == c.NEWSPAPER_ZOMBIE: + self.speed = 2.5 if (self.current_time - self.attack_timer) > (c.ATTACK_INTERVAL * self.getAttackTimeRatio()): if self.prey.health > 0: if self.prey_is_plant: @@ -134,8 +135,8 @@ class Zombie(pg.sprite.Sprite): def setLostHead(self): self.losthead_timer = self.current_time self.lostHead = True - self.animate_interval = 180 self.speed = 0.5 + self.animate_interval = 180 if self.head_group is not None: self.head_group.add(ZombieHead(self.rect.centerx, self.rect.bottom)) @@ -204,12 +205,10 @@ class Zombie(pg.sprite.Sprite): if self.helmetType2: self.helmetType2Health -= damage if self.helmetType2Health <= 0: - self.helmetType2 = False if self.helmet: self.helmetHealth += self.helmetType2Health # 注意self.helmetType2Health已经带有正负 self.helmetType2Health = 0 # 注意合并后清零 if self.helmetHealth <= 0: - self.helmet = False self.health += self.helmetHealth self.helmetHealth = 0 # 注意合并后清零 else: @@ -218,7 +217,6 @@ class Zombie(pg.sprite.Sprite): elif self.helmet: # 不存在二类防具,但是存在一类防具 self.helmetHealth -= damage if self.helmetHealth <= 0: - self.helmet = False self.health += self.helmetHealth self.helmetHealth = 0 # 注意合并后清零 else: # 没有防具 @@ -227,7 +225,6 @@ class Zombie(pg.sprite.Sprite): if self.helmet: # 存在一类防具 self.helmetHealth -= damage if self.helmetHealth <= 0: - self.helmet = False self.health += self.helmetHealth self.helmetHealth = 0 # 注意合并后清零 else: # 没有一类防具 @@ -237,13 +234,11 @@ class Zombie(pg.sprite.Sprite): if self.helmetType2: self.helmetType2Health -= damage if self.helmetType2Health <= 0: - self.helmetType2 = False if self.helmet: self.helmetHealth -= damage # 注意范围伤害中这里还有一个攻击 self.helmetHealth += self.helmetType2Health # 注意self.helmetType2Health已经带有正负 self.helmetType2Health = 0 # 注意合并后清零 if self.helmetHealth <= 0: - self.helmet = False self.health += self.helmetHealth self.helmetHealth = 0 # 注意合并后清零 else: @@ -253,7 +248,6 @@ class Zombie(pg.sprite.Sprite): elif self.helmet: # 不存在二类防具,但是存在一类防具 self.helmetHealth -= damage if self.helmetHealth <= 0: - self.helmet = False self.health += self.helmetHealth self.helmetHealth = 0 # 注意合并后清零 else: # 没有防具 @@ -265,12 +259,8 @@ class Zombie(pg.sprite.Sprite): # 以后增设铁门后可能需要设置侧面冲撞特殊性 if self.helmetType2: self.helmetType2Health -= damage - if self.helmetType2Health <= 0: - self.helmetType2 = False elif self.helmet: # 不存在二类防具,但是存在一类防具 self.helmetHealth -= damage - if self.helmetHealth <= 0: - self.helmet = False else: # 没有防具 self.health -= damage else: @@ -307,7 +297,7 @@ class Zombie(pg.sprite.Sprite): def setDie(self): self.state = c.DIE - self.animate_interval = 100 + self.animate_interval = 80 self.changeFrames(self.die_frames) def setBoomDie(self): diff --git a/source/state/level.py b/source/state/level.py index 8ce07b2..f2219f4 100644 --- a/source/state/level.py +++ b/source/state/level.py @@ -289,8 +289,9 @@ class Level(tool.State): # 方便放回去 def checkShovelClick(self, mouse_pos): x, y = mouse_pos - if(x >= self.shovel_box_rect.x and x <= self.shovel_box_rect.right and - y >= self.shovel_box_rect.y and y <= self.shovel_box_rect.bottom): + if( self.hasShovel and + x >= self.shovel_box_rect.x and x <= self.shovel_box_rect.right and + y >= self.shovel_box_rect.y and y <= self.shovel_box_rect.bottom): return True return False @@ -422,13 +423,11 @@ class Level(tool.State): def createZombie(self, name, map_y=None): # 有指定时按照指定生成,无指定时随机位置生成 - # 0:白天 1:夜晚 2:泳池 3:浓雾 4:屋顶 5:月夜 + # 0:白天 1:夜晚 2:泳池 3:浓雾 4:屋顶 5:月夜 6:坚果保龄球 if map_y == None: - if self.map_data[c.BACKGROUND_TYPE] in {0, 1, 4, 5}: - map_y = randint(0, 4) # 情况复杂:分水路和陆路,不能简单实现,需要另外加判断 # 0, 1, 4, 5路为陆路,2, 3路为水路 - elif self.map_data[c.BACKGROUND_TYPE] in {2, 3}: + if self.map_data[c.BACKGROUND_TYPE] in {2, 3}: if name in {}: # 这里还没填,以后加了泳池模式填:水生僵尸集合 map_y = randint(2, 3) elif name == '这里应该换成气球僵尸的名字(最好写调用的变量名,最好不要直接写,保持风格统一)': @@ -437,6 +436,8 @@ class Level(tool.State): map_y = randint(0, 3) if map_y >= 2: # 后两路的map_y应当+2 map_y += 2 + else: + map_y = randint(0, 4) # 新增的僵尸也需要在这里声明 x, y = self.map.getMapGridPos(0, map_y) @@ -588,7 +589,7 @@ class Level(tool.State): if bullet.state == c.FLY: zombie = pg.sprite.spritecollideany(bullet, self.zombie_groups[i], collided_func) if zombie and zombie.state != c.DIE: - zombie.setDamage(bullet.damage, bullet.ice, damageType=c.ZOMBIE_DEAFULT_DAMAGE) + zombie.setDamage(bullet.damage, ice=bullet.ice, damageType=c.ZOMBIE_DEAFULT_DAMAGE) bullet.setExplode() def checkZombieCollisions(self):