更改小推车设定

This commit is contained in:
星外之神 2022-05-10 21:20:26 +08:00
parent 44adb8f7fc
commit 235b467205
30 changed files with 70 additions and 10 deletions

View File

@ -14,6 +14,7 @@
{"time":7000, "map_y":4, "name":"ScreenDoorZombie"},
{"time":8000, "map_y":4, "name":"ScreenDoorZombie"},
{"time":0, "map_y":1, "name":"NewspaperZombie"},
{"time":0, "map_y":0, "name":"PoleVaultingZombie"},
{"time":0, "map_y":2, "name":"ConeheadDuckyTubeZombie"},
{"time":80000, "map_y":2, "name":"ConeheadDuckyTubeZombie"}
]

View File

@ -149,6 +149,14 @@ class Zombie(pg.sprite.Sprite):
self.helmetType2 = False
else:
self.changeFrames(self.helmet_walk_frames)
if self.helmet:
if self.helmetHealth <= 0:
self.helmet = False
self.changeFrames(self.walk_frames)
if self.helmetType2:
if self.helmetType2Health <= 0:
self.helmetType2 = False
self.changeFrames(self.walk_frames)
elif self.is_hypno and self.rect.right > c.MAP_POOL_FRONT_X + 55: # 常数拟合暂时缺乏检验
if self.swimming:
self.changeFrames(self.walk_frames)
@ -836,3 +844,44 @@ class ScreenDoorZombie(Zombie):
self.loadFrames(frame_list[i], name)
self.frames = self.helmet_walk_frames
class PoleVaultingZombie(Zombie):
def __init__(self, x, y, head_group):
Zombie.__init__(self, x, y, c.POLE_VAULTING_ZOMBIE, head_group=head_group)
self.speed = 1.88
self.jumped = False
def loadImages(self):
self.walk_frames = []
self.attack_frames = []
self.losthead_walk_frames = []
self.losthead_attack_frames = []
self.die_frames = []
self.boomdie_frames = []
self.walk_after_jump_frames = []
self.jump_frames = []
walk_name = self.name
attack_name = self.name + 'Attack'
losthead_walk_name = self.name + 'LostHead'
losthead_attack_name = self.name + 'LostHeadAttack'
die_name = self.name + 'Die'
boomdie_name = c.BOOMDIE
walk_after_jump_name = self.name + 'WalkAfterJump'
jump_name = self.name + 'Jump'
frame_list = [self.walk_frames, self.attack_frames, self.losthead_walk_frames,
self.losthead_attack_frames, self.die_frames, self.boomdie_frames,
self.walk_after_jump_frames, self.jump_frames]
name_list = [walk_name, attack_name, losthead_walk_name,
losthead_attack_name, die_name, boomdie_name,
walk_after_jump_name, jump_name]
for i, name in enumerate(name_list):
self.loadFrames(frame_list[i], name)
self.frames = self.walk_frames
def setJump(self):
self.changeFrames(self.jump_frames)

View File

@ -311,6 +311,7 @@ DUCKY_TUBE_ZOMBIE = 'DuckyTubeZombie'
CONEHEAD_DUCKY_TUBE_ZOMBIE = 'ConeheadDuckyTubeZombie'
BUCKETHEAD_DUCKY_TUBE_ZOMBIE = 'BucketheadDuckyTubeZombie'
SCREEN_DOOR_ZOMBIE = 'ScreenDoorZombie'
POLE_VAULTING_ZOMBIE = 'PoleVaultingZombie'
BOOMDIE = 'BoomDie'
@ -326,6 +327,7 @@ ZOMBIE_WALLNUT_BOWLING_DANMAGE = 'wallnutBowlingDamage' # 坚果保龄球冲撞
# 有关本体
LOSTHEAD_HEALTH = 70
NORMAL_HEALTH = 200 # 普通僵尸生命值
POLE_VAULTING_HEALTH = 333
# 有关一类防具
CONEHEAD_HEALTH = 370
BUCKETHEAD_HEALTH = 1100

View File

@ -311,7 +311,7 @@ class Level(tool.State):
self.cars = []
for i in range(self.map_y_len):
_, y = self.map.getMapGridPos(0, i)
self.cars.append(plant.Car(-25, y+20, i))
self.cars.append(plant.Car(-40, y+20, i))
# 更新函数每帧被调用,将鼠标事件传入给状态处理函数
def update(self, surface, current_time, mouse_pos, mouse_click):
@ -820,6 +820,9 @@ class Level(tool.State):
self.zombie_groups[map_y].add(zombie.BucketHeadDuckyTubeZombie(c.ZOMBIE_START_X + randint(-20, 20) + hugeWaveMove, y, self.head_group))
elif name == c.SCREEN_DOOR_ZOMBIE:
self.zombie_groups[map_y].add(zombie.ScreenDoorZombie(c.ZOMBIE_START_X + randint(-20, 20) + hugeWaveMove, y, self.head_group))
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))
# 能否种植物的判断:
# 先判断位置是否合法 isValid(map_x, map_y)
@ -1063,6 +1066,11 @@ class Level(tool.State):
targetPlant = None
if targetPlant:
# 撑杆跳的特殊情况
if zombie.name == c.POLE_VAULTING_ZOMBIE and (not zombie.jumped):
zombie.setJump()
continue
if targetPlant.name == c.WALLNUTBOWLING:
if targetPlant.canHit(i):
zombie.setDamage(c.WALLNUT_BOWLING_DAMAGE, damageType=c.ZOMBIE_WALLNUT_BOWLING_DANMAGE)
@ -1096,9 +1104,9 @@ class Level(tool.State):
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.x <= 0:
if zombie and zombie.state != c.DIE and (not zombie.lostHead) and zombie.rect.centerx <= 0:
car.setWalk()
if zombie.rect.x <= car.rect.x:
if zombie.rect.centerx <= car.rect.x:
zombie.health = 0
zombie.kill()
if car.dead:
@ -1307,7 +1315,7 @@ class Level(tool.State):
def checkLose(self):
for i in range(self.map_y_len):
for zombie in self.zombie_groups[i]:
if zombie.rect.right < -10 and (not zombie.lostHead):
if zombie.rect.right < -20 and (not zombie.lostHead) and zombie.state != c.DIE:
return True
return False