diff --git a/resources/data/map/level_0.json b/resources/data/map/level_0.json index 9e35fda..1e51b9e 100644 --- a/resources/data/map/level_0.json +++ b/resources/data/map/level_0.json @@ -17,6 +17,6 @@ {"time":0, "map_y":0, "name":"PoleVaultingZombie"}, {"time":6000, "map_y":0, "name":"FootballZombie"}, {"time":0, "map_y":2, "name":"ConeheadDuckyTubeZombie"}, - {"time":80000, "map_y":2, "name":"ConeheadDuckyTubeZombie"} + {"time":90000, "map_y":2, "name":"ConeheadDuckyTubeZombie"} ] } \ No newline at end of file diff --git a/source/component/plant.py b/source/component/plant.py index d9106bd..176e7ad 100755 --- a/source/component/plant.py +++ b/source/component/plant.py @@ -340,7 +340,9 @@ class Plant(pg.sprite.Sprite): if not zombie.lostHead: self.health -= damage self.hit_timer = self.current_time - if (self.name == c.HYPNOSHROOM) and (self.state != c.SLEEP) and (zombie.name not in {"投石车僵尸(未实现)"}): + if ((self.name == c.HYPNOSHROOM) and + (self.state != c.SLEEP) and + (zombie.name not in {c.ZOMBONI, "投石车僵尸(未实现)", "加刚特尔(未实现)"})): self.zombie_to_hypno = zombie def getPosition(self): @@ -1254,13 +1256,13 @@ class TorchWood(Plant): if i.name == c.BULLET_PEA: if i.passedTorchWood != self.rect.centerx: if abs(i.rect.centerx - self.rect.centerx) <= 20: - self.bullet_group.add(Bullet(i.rect.x, i.rect.y, i.rect.y, + self.bullet_group.add(Bullet(i.rect.x, i.rect.y, i.dest_y, c.BULLET_FIREBALL, c.BULLET_DAMAGE_FIREBALL_BODY, effect=c.BULLET_EFFECT_UNICE, passedTorchWood=self.rect.centerx)) i.kill() elif i.name == c.BULLET_PEA_ICE: if i.passedTorchWood != self.rect.centerx: if abs(i.rect.centerx - self.rect.centerx) <= 20: - self.bullet_group.add(Bullet(i.rect.x, i.rect.y, i.rect.y, + self.bullet_group.add(Bullet(i.rect.x, i.rect.y, i.dest_y, c.BULLET_PEA, c.BULLET_DAMAGE_NORMAL, effect=None, passedTorchWood=self.rect.centerx)) i.kill() diff --git a/source/component/zombie.py b/source/component/zombie.py index 6d62bad..adeaf7a 100755 --- a/source/component/zombie.py +++ b/source/component/zombie.py @@ -1001,7 +1001,7 @@ class Zomboni(Zombie): if ((plant.name not in {c.SPIKEWEED}) and (self.rect.centerx <= plant.rect.right <= self.rect.right)): # 扣除生命值为可能的最大有限生命值 - plant.setDamage(8000, self) + plant.health -= 8000 # 造冰 mapX, mapY = self.map.getMapIndex(self.rect.right - 20, self.rect.bottom) diff --git a/source/state/level.py b/source/state/level.py index bfd4b15..cc0093a 100644 --- a/source/state/level.py +++ b/source/state/level.py @@ -771,7 +771,8 @@ class Level(tool.State): self.shovelRemovePlant(mouse_pos) for car in self.cars: - car.update(self.game_info) + if car: + car.update(self.game_info) self.menubar.update(self.current_time) @@ -1154,15 +1155,16 @@ class Level(tool.State): self.newPlantAndPositon = None # 生效后需要解除刷新设置 def checkCarCollisions(self): - for car in self.cars: - for zombie in self.zombie_groups[car.map_y]: - if zombie and zombie.state != c.DIE and (not zombie.lostHead) and (zombie.rect.centerx <= 0): - car.setWalk() - if zombie.rect.centerx <= car.rect.x: - zombie.health = 0 - zombie.kill() - if car.dead: - self.cars.remove(car) + for i in range(len(self.cars)): + if self.cars[i]: + for zombie in self.zombie_groups[i]: + if zombie and zombie.state != c.DIE and (not zombie.lostHead) and (zombie.rect.centerx <= 0): + self.cars[i].setWalk() + if zombie.rect.centerx <= self.cars[i].rect.x: + zombie.health = 0 + zombie.kill() + if self.cars[i].dead: + self.cars[i] = None def boomZombies(self, x, map_y, y_range, x_range, effect=None): for i in range(self.map_y_len): @@ -1217,11 +1219,12 @@ class Level(tool.State): elif targetPlant.name == c.ICESHROOM and targetPlant.state != c.SLEEP: self.freezeZombies(targetPlant) elif targetPlant.name == c.HYPNOSHROOM and targetPlant.state != c.SLEEP: - zombie = targetPlant.zombie_to_hypno - zombie.setHypno() - _, map_y = self.map.getMapIndex(zombie.rect.centerx, zombie.rect.bottom) - self.zombie_groups[map_y].remove(zombie) - self.hypno_zombie_groups[map_y].add(zombie) + if targetPlant.zombie_to_hypno: + zombie = targetPlant.zombie_to_hypno + zombie.setHypno() + _, map_y = self.map.getMapIndex(zombie.rect.centerx, zombie.rect.bottom) + self.zombie_groups[map_y].remove(zombie) + self.hypno_zombie_groups[map_y].add(zombie) elif (targetPlant.name == c.POTATOMINE and not targetPlant.is_init): # 土豆雷不是灰烬植物,不能用Boom for zombie in self.zombie_groups[map_y]: # 双判断:发生碰撞或在攻击范围内 @@ -1488,14 +1491,14 @@ class Level(tool.State): surface.blit(self.little_menu, self.little_menu_rect) self.menubar.draw(surface) - for car in self.cars: - car.draw(surface) for i in range(self.map_y_len): self.plant_groups[i].draw(surface) self.zombie_groups[i].draw(surface) self.hypno_zombie_groups[i].draw(surface) self.bullet_groups[i].draw(surface) self.drawZombieFreezeTrap(i, surface) + if self.cars[i]: + self.cars[i].draw(surface) self.head_group.draw(surface) self.sun_group.draw(surface)