diff --git a/resources/data/map/level_0.json b/resources/data/map/level_0.json index 10ce319..9e35fda 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":0, "map_y":4, "name":"ScreenDoorZombie"}, + {"time":0, "map_y":5, "name":"Zomboni"}, {"time":1000, "map_y":4, "name":"ScreenDoorZombie"}, {"time":2000, "map_y":4, "name":"ScreenDoorZombie"}, {"time":3100, "map_y":4, "name":"ScreenDoorZombie"}, diff --git a/resources/graphics/Plants/IceFrozenPlot/IceFrozenPlot_0.png b/resources/graphics/Plants/IceFrozenPlot/IceFrozenPlot_0.png new file mode 100644 index 0000000..cd48b3f Binary files /dev/null and b/resources/graphics/Plants/IceFrozenPlot/IceFrozenPlot_0.png differ diff --git a/source/component/plant.py b/source/component/plant.py index 26ba88b..143f431 100755 --- a/source/component/plant.py +++ b/source/component/plant.py @@ -842,9 +842,18 @@ class Spikeweed(Plant): self.hit_timer = self.current_time - 500 elif (self.current_time - self.attack_timer) >= 700: self.attack_timer = self.current_time + # 最后再来判断攻击是否要杀死自己 + killSelf = False for zombie in self.zombie_group: if self.canAttack(zombie): - zombie.setDamage(20, damageType=c.ZOMBIE_COMMON_DAMAGE) + # 有车的僵尸 + if zombie.name in {c.ZOMBONI}: + zombie.health = 0 + killSelf = True + else: + zombie.setDamage(20, damageType=c.ZOMBIE_COMMON_DAMAGE) + if killSelf: + self.health = 0 # 播放攻击音效,同子弹打击 pg.mixer.Sound(os.path.join(os.path.dirname(os.path.dirname(os.path.dirname(__file__))) ,"resources", "sound", "bulletExplode.ogg")).play() @@ -1704,3 +1713,6 @@ class FumeShroom(Plant): else: self.image.set_alpha(255) +class IceFrozenPlot(Plant): + def __init__(self, x, y): + Plant.__init__(self, x, y, c.ICE_FROZEN_PLOT, c.INF, None) \ No newline at end of file diff --git a/source/component/zombie.py b/source/component/zombie.py index 8df8481..8db0d5a 100755 --- a/source/component/zombie.py +++ b/source/component/zombie.py @@ -930,3 +930,82 @@ class PoleVaultingZombie(Zombie): self.image.set_alpha(255) else: self.image.set_alpha(192) + + +# 注意:冰车僵尸移动变速 +class Zomboni(Zombie): + def __init__(self, x, y, plant_group, map, IceFrozenPlot): + Zombie.__init__(self, x, y, c.ZOMBONI, bodyHealth=c.ZOMBONI_HEALTH) + self.plant_group = plant_group + self.map = map + self.IceFrozenPlot = IceFrozenPlot + + def loadImages(self): + self.walk_frames = [] + self.walk_damaged1_frames = [] + self.walk_damaged2_frames = [] + self.losthead_walk_frames = [] + self.die_frames = [] + self.boomdie_frames = [] + + walk_name = self.name + walk_damaged1_name = self.name + 'Damaged1' + walk_damaged2_name = self.name + 'Damaged2' + losthead_walk_name = self.name + 'Damaged2' + die_name = self.name + 'Die' + boomdie_name = self.name + 'BoomDie' + + frame_list = [ self.walk_frames, self.walk_damaged1_frames, + self.walk_damaged2_frames, self.losthead_walk_frames, + self.die_frames, self.boomdie_frames] + name_list = [ walk_name, walk_damaged1_name, + walk_damaged2_name, losthead_walk_name, + die_name, boomdie_name] + + for i, name in enumerate(name_list): + self.loadFrames(frame_list[i], name) + + self.frames = self.walk_frames + + def updateIceSlow(self): + # 冰车僵尸不可冰冻 + self.ice_slow_ratio = 1 + + def freezing(self): + # 冰车僵尸不可冰冻 + pass + + def walking(self): + if self.checkToDie(self.losthead_walk_frames): + return + + if self.health <= c.ZOMBONI_DAMAGED2_HEALTH: + self.changeFrames(self.walk_damaged2_frames) + elif self.health <= c.ZOMBONI_DAMAGED1_HEALTH: + self.changeFrames(self.walk_damaged1_frames) + + if (self.current_time - self.walk_timer) > (c.ZOMBIE_WALK_INTERVAL * self.getTimeRatio()): + self.walk_timer = self.current_time + if self.is_hypno: + self.rect.x += 1 + else: + self.rect.x -= 1 + + # 行进时碾压 + for plant in self.plant_group: + # 地刺和地刺王不用检验 + if ((plant.name not in {c.SPIKEWEED}) + and (self.rect.centerx <= plant.rect.right <= self.rect.right)): + # 扣除生命值为可能的最大有限生命值 + plant.setDamage(8000, self) + + # 造冰 + mapX, mapY = self.map.getMapIndex(self.rect.right, self.rect.bottom) + if 0 <= mapX < c.GRID_X_LEN: + if c.ICE_FROZEN_PLOT not in self.map.map[mapY][mapX]: + x, y = self.map.getMapGridPos(mapX, mapY) + self.plant_group.add(self.IceFrozenPlot(x, y)) + + + def handleState(self): + self.walking() \ No newline at end of file diff --git a/source/constants.py b/source/constants.py index 33e1562..46dd37f 100755 --- a/source/constants.py +++ b/source/constants.py @@ -312,6 +312,7 @@ CONEHEAD_DUCKY_TUBE_ZOMBIE = 'ConeheadDuckyTubeZombie' BUCKETHEAD_DUCKY_TUBE_ZOMBIE = 'BucketheadDuckyTubeZombie' SCREEN_DOOR_ZOMBIE = 'ScreenDoorZombie' POLE_VAULTING_ZOMBIE = 'PoleVaultingZombie' +ZOMBONI = 'Zomboni' BOOMDIE = 'BoomDie' @@ -325,9 +326,14 @@ ZOMBIE_WALLNUT_BOWLING_DANMAGE = 'wallnutBowlingDamage' # 坚果保龄球冲撞 # 僵尸生命值设置 # 有关本体 -LOSTHEAD_HEALTH = 70 NORMAL_HEALTH = 200 # 普通僵尸生命值 POLE_VAULTING_HEALTH = 333 +ZOMBONI_HEALTH = 1280 +# 冰车损坏点 +ZOMBONI_DAMAGED1_HEALTH = 2 * ZOMBONI_HEALTH // 3 + 70 +ZOMBONI_DAMAGED2_HEALTH = ZOMBONI_HEALTH // 3 + 70 +# 掉头后僵尸的生命值 +LOSTHEAD_HEALTH = 70 POLE_VAULTING_LOSTHEAD_HEALTH = 167 # 有关一类防具 CONEHEAD_HEALTH = 370 diff --git a/source/state/level.py b/source/state/level.py index 885c872..424c468 100644 --- a/source/state/level.py +++ b/source/state/level.py @@ -838,6 +838,8 @@ class Level(tool.State): elif name == c.POLE_VAULTING_ZOMBIE: # 撑杆跳生成位置不同 self.zombie_groups[map_y].add(zombie.PoleVaultingZombie(c.ZOMBIE_START_X + randint(70, 80) + hugeWaveMove, y, self.head_group)) + elif name == c.ZOMBONI: + self.zombie_groups[map_y].add(zombie.Zomboni(c.ZOMBIE_START_X + randint(0, 20) + hugeWaveMove, y, self.plant_groups[map_y], self.map, plant.IceFrozenPlot)) # 能否种植物的判断: # 先判断位置是否合法 isValid(map_x, map_y) @@ -1035,6 +1037,8 @@ class Level(tool.State): for i in range(self.map_y_len): hypo_zombies = [] for zombie in self.zombie_groups[i]: + if zombie.name == c.ZOMBONI: + continue if zombie.name in {c.POLE_VAULTING_ZOMBIE} and (not zombie.jumped): collided_func = pg.sprite.collide_rect_ratio(0.6) else: @@ -1104,7 +1108,7 @@ class Level(tool.State): if zombie.name in {c.POLE_VAULTING_ZOMBIE} and (not zombie.jumped): if not zombie.jumping: zombie.jumpMap_x, zombie.jumpMap_y = self.map.getMapIndex(targetPlant.rect.centerx, targetPlant.rect.centery) - zombie.jumpMap_x, zombie.jumpMap_y = min(c.GRID_X_LEN, zombie.jumpMap_x), min(self.map_y_len, zombie.jumpMap_y) + zombie.jumpMap_x, zombie.jumpMap_y = min(c.GRID_X_LEN - 1, zombie.jumpMap_x), min(self.map_y_len - 1, zombie.jumpMap_y) jumpX = targetPlant.rect.x - c.GRID_X_SIZE * 0.6 if c.TALLNUT in self.map.map[zombie.jumpMap_y][zombie.jumpMap_x][c.MAP_PLANT]: zombie.setJump(False, jumpX)