修复僵尸啃食的bug
This commit is contained in:
parent
c3dc470dae
commit
2af6371a10
@ -433,7 +433,7 @@ class Zombie(pg.sprite.Sprite):
|
|||||||
self.health -= damage
|
self.health -= damage
|
||||||
else:
|
else:
|
||||||
print('警告:植物攻击类型错误,现在默认进行类豌豆射手型攻击')
|
print('警告:植物攻击类型错误,现在默认进行类豌豆射手型攻击')
|
||||||
setDamage(damage, effect=effect, damageType=c.ZOMBIE_DEAFULT_DAMAGE)
|
self.setDamage(damage, effect=effect, damageType=c.ZOMBIE_DEAFULT_DAMAGE)
|
||||||
|
|
||||||
# 记录攻击时间
|
# 记录攻击时间
|
||||||
self.hit_timer = self.current_time
|
self.hit_timer = self.current_time
|
||||||
|
|||||||
@ -1041,7 +1041,7 @@ class Level(tool.State):
|
|||||||
# 被攻击对象是植物时才可能刷新
|
# 被攻击对象是植物时才可能刷新
|
||||||
if zombie.prey_is_plant:
|
if zombie.prey_is_plant:
|
||||||
# 新植物种在被攻击植物同一格时才可能刷新
|
# 新植物种在被攻击植物同一格时才可能刷新
|
||||||
if (mapX, mapY) == self.newPlantAndPositon[1]:
|
if (zombie.preyMapX, zombie.preyMapY) == self.newPlantAndPositon[1]:
|
||||||
# 如果被攻击植物是睡莲和花盆,同一格种了植物必然刷新
|
# 如果被攻击植物是睡莲和花盆,同一格种了植物必然刷新
|
||||||
# 如果被攻击植物不是睡莲和花盆,同一格种了南瓜头才刷新
|
# 如果被攻击植物不是睡莲和花盆,同一格种了南瓜头才刷新
|
||||||
if ((zombie.prey.name not in {c.LILYPAD, "花盆(未实现)"})
|
if ((zombie.prey.name not in {c.LILYPAD, "花盆(未实现)"})
|
||||||
@ -1098,11 +1098,11 @@ class Level(tool.State):
|
|||||||
targetPlant = None
|
targetPlant = None
|
||||||
|
|
||||||
if targetPlant:
|
if targetPlant:
|
||||||
|
zombie.preyMapX, zombie.preyMapY = self.map.getMapIndex(targetPlant.rect.centerx, targetPlant.rect.centery)
|
||||||
# 撑杆跳的特殊情况
|
# 撑杆跳的特殊情况
|
||||||
if zombie.name in {c.POLE_VAULTING_ZOMBIE} and (not zombie.jumped):
|
if zombie.name in {c.POLE_VAULTING_ZOMBIE} and (not zombie.jumped):
|
||||||
if not zombie.jumping:
|
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 - 1, zombie.preyMapX), min(self.map_y_len - 1, zombie.preyMapY)
|
||||||
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
|
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]:
|
if c.TALLNUT in self.map.map[zombie.jumpMap_y][zombie.jumpMap_x][c.MAP_PLANT]:
|
||||||
zombie.setJump(False, jumpX)
|
zombie.setJump(False, jumpX)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user