维护清理
This commit is contained in:
parent
b8a7fc0a66
commit
1dd0894adf
@ -165,7 +165,7 @@ class Level(tool.State):
|
|||||||
zombieList.append(newZombie)
|
zombieList.append(newZombie)
|
||||||
volume -= c.CREATE_ZOMBIE_DICT[newZombie][0]
|
volume -= c.CREATE_ZOMBIE_DICT[newZombie][0]
|
||||||
waves.append(zombieList)
|
waves.append(zombieList)
|
||||||
#print(wave, zombieList, len(zombieList))
|
# print(wave, zombieList, len(zombieList))
|
||||||
|
|
||||||
self.waves = waves
|
self.waves = waves
|
||||||
|
|
||||||
@ -214,7 +214,7 @@ class Level(tool.State):
|
|||||||
for i in self.plant_groups[mapY]:
|
for i in self.plant_groups[mapY]:
|
||||||
checkMapX, _ = self.map.getMapIndex(i.rect.centerx, i.rect.bottom)
|
checkMapX, _ = self.map.getMapIndex(i.rect.centerx, i.rect.bottom)
|
||||||
if mapX == checkMapX:
|
if mapX == checkMapX:
|
||||||
# 不能杀死毁灭菇坑和冰道
|
# 不杀死毁灭菇坑和冰道
|
||||||
if i.name not in exceptionObjects:
|
if i.name not in exceptionObjects:
|
||||||
i.health = 0
|
i.health = 0
|
||||||
self.plant_groups[mapY].add(plant.Grave(posX, posY))
|
self.plant_groups[mapY].add(plant.Grave(posX, posY))
|
||||||
@ -417,7 +417,7 @@ class Level(tool.State):
|
|||||||
|
|
||||||
self.removeMouseImage()
|
self.removeMouseImage()
|
||||||
self.setupGroups()
|
self.setupGroups()
|
||||||
if (c.ZOMBIE_LIST in self.map_data) and self.map_data[c.SPAWN_ZOMBIES] == c.SPAWN_ZOMBIES_LIST:
|
if self.map_data[c.SPAWN_ZOMBIES] == c.SPAWN_ZOMBIES_LIST:
|
||||||
self.setupZombies()
|
self.setupZombies()
|
||||||
else:
|
else:
|
||||||
# 僵尸波数数据及僵尸生成数据
|
# 僵尸波数数据及僵尸生成数据
|
||||||
@ -656,7 +656,7 @@ class Level(tool.State):
|
|||||||
self.pauseAndCheckLittleMenuOptions(mouse_pos, mouse_click)
|
self.pauseAndCheckLittleMenuOptions(mouse_pos, mouse_click)
|
||||||
return
|
return
|
||||||
|
|
||||||
if (c.ZOMBIE_LIST in self.map_data) and self.map_data[c.SPAWN_ZOMBIES] == c.SPAWN_ZOMBIES_LIST:
|
if self.map_data[c.SPAWN_ZOMBIES] == c.SPAWN_ZOMBIES_LIST:
|
||||||
# 旧僵尸生成方式
|
# 旧僵尸生成方式
|
||||||
if self.zombie_start_time == 0:
|
if self.zombie_start_time == 0:
|
||||||
self.zombie_start_time = self.current_time
|
self.zombie_start_time = self.current_time
|
||||||
@ -778,7 +778,7 @@ class Level(tool.State):
|
|||||||
# 情况复杂:分水路和陆路,不能简单实现,需要另外加判断
|
# 情况复杂:分水路和陆路,不能简单实现,需要另外加判断
|
||||||
# 0, 1, 4, 5路为陆路,2, 3路为水路
|
# 0, 1, 4, 5路为陆路,2, 3路为水路
|
||||||
if self.map_data[c.BACKGROUND_TYPE] in c.POOL_EQUIPPED_BACKGROUNDS:
|
if self.map_data[c.BACKGROUND_TYPE] in c.POOL_EQUIPPED_BACKGROUNDS:
|
||||||
if name in c.WATER_ZOMBIE: # 水生僵尸集合
|
if name in c.WATER_ZOMBIE:
|
||||||
map_y = random.randint(2, 3)
|
map_y = random.randint(2, 3)
|
||||||
elif name == '这里应该换成气球僵尸的名字(最好写调用的变量名,最好不要直接写,保持风格统一)':
|
elif name == '这里应该换成气球僵尸的名字(最好写调用的变量名,最好不要直接写,保持风格统一)':
|
||||||
map_y = random.randint(0, 5)
|
map_y = random.randint(0, 5)
|
||||||
@ -793,7 +793,7 @@ class Level(tool.State):
|
|||||||
else:
|
else:
|
||||||
map_y = random.randint(0, 4)
|
map_y = random.randint(0, 4)
|
||||||
|
|
||||||
if not ((c.ZOMBIE_LIST in self.map_data) and self.map_data[c.SPAWN_ZOMBIES] == c.SPAWN_ZOMBIES_LIST):
|
if self.map_data[c.SPAWN_ZOMBIES] == c.SPAWN_ZOMBIES_AUTO:
|
||||||
# 旗帜波出生点右移
|
# 旗帜波出生点右移
|
||||||
if self.waveNum % 10:
|
if self.waveNum % 10:
|
||||||
hugeWaveMove = 0
|
hugeWaveMove = 0
|
||||||
@ -802,6 +802,7 @@ class Level(tool.State):
|
|||||||
else:
|
else:
|
||||||
hugeWaveMove = 0
|
hugeWaveMove = 0
|
||||||
x, y = self.map.getMapGridPos(0, map_y)
|
x, y = self.map.getMapGridPos(0, map_y)
|
||||||
|
|
||||||
# 新增的僵尸也需要在这里声明
|
# 新增的僵尸也需要在这里声明
|
||||||
if name == c.NORMAL_ZOMBIE:
|
if name == c.NORMAL_ZOMBIE:
|
||||||
self.zombie_groups[map_y].add(zombie.NormalZombie(c.ZOMBIE_START_X + random.randint(-20, 20) + hugeWaveMove, y, self.head_group))
|
self.zombie_groups[map_y].add(zombie.NormalZombie(c.ZOMBIE_START_X + random.randint(-20, 20) + hugeWaveMove, y, self.head_group))
|
||||||
@ -830,6 +831,7 @@ class Level(tool.State):
|
|||||||
# 冰车僵尸生成位置不同
|
# 冰车僵尸生成位置不同
|
||||||
self.zombie_groups[map_y].add(zombie.Zomboni(c.ZOMBIE_START_X + random.randint(0, 10) + hugeWaveMove, y, self.plant_groups[map_y], self.map, plant.IceFrozenPlot))
|
self.zombie_groups[map_y].add(zombie.Zomboni(c.ZOMBIE_START_X + random.randint(0, 10) + hugeWaveMove, y, self.plant_groups[map_y], self.map, plant.IceFrozenPlot))
|
||||||
elif name == c.SNORKELZOMBIE:
|
elif name == c.SNORKELZOMBIE:
|
||||||
|
# 潜水僵尸生成位置不同
|
||||||
self.zombie_groups[map_y].add(zombie.SnorkelZombie(c.ZOMBIE_START_X + random.randint(0, 10) + hugeWaveMove, y, self.head_group))
|
self.zombie_groups[map_y].add(zombie.SnorkelZombie(c.ZOMBIE_START_X + random.randint(0, 10) + hugeWaveMove, y, self.head_group))
|
||||||
|
|
||||||
# 能否种植物的判断:
|
# 能否种植物的判断:
|
||||||
@ -925,7 +927,7 @@ class Level(tool.State):
|
|||||||
mushroomSleep = False
|
mushroomSleep = False
|
||||||
self.plant_groups[map_y].add(new_plant)
|
self.plant_groups[map_y].add(new_plant)
|
||||||
# 种植植物后应当刷新僵尸的攻击对象
|
# 种植植物后应当刷新僵尸的攻击对象
|
||||||
# 这里用植物名称代替布尔值,保存更多信息
|
# 用元组表示植物的名称和格子坐标
|
||||||
self.newPlantAndPositon = (new_plant.name, (map_x, map_y))
|
self.newPlantAndPositon = (new_plant.name, (map_x, map_y))
|
||||||
if self.bar_type == c.CHOOSEBAR_STATIC:
|
if self.bar_type == c.CHOOSEBAR_STATIC:
|
||||||
self.menubar.decreaseSunValue(self.select_plant.sun_cost)
|
self.menubar.decreaseSunValue(self.select_plant.sun_cost)
|
||||||
@ -933,8 +935,8 @@ class Level(tool.State):
|
|||||||
else:
|
else:
|
||||||
self.menubar.deleateCard(self.select_plant)
|
self.menubar.deleateCard(self.select_plant)
|
||||||
|
|
||||||
if self.bar_type != c.CHOSSEBAR_BOWLING:
|
if self.bar_type != c.CHOSSEBAR_BOWLING: # 坚果保龄球关卡无需考虑格子被占用的情况
|
||||||
self.map.addMapPlant(map_x, map_y, self.plant_name, sleep=mushroomSleep)
|
self.map.addMapPlant(map_x, map_y, self.plant_name, sleep=mushroomSleep)
|
||||||
self.removeMouseImage()
|
self.removeMouseImage()
|
||||||
|
|
||||||
# print(self.newPlantAndPositon)
|
# print(self.newPlantAndPositon)
|
||||||
@ -1135,8 +1137,8 @@ class Level(tool.State):
|
|||||||
for hypno_zombie in self.hypno_zombie_groups[i]:
|
for hypno_zombie in self.hypno_zombie_groups[i]:
|
||||||
if hypno_zombie.health <= 0:
|
if hypno_zombie.health <= 0:
|
||||||
continue
|
continue
|
||||||
zombie_list = pg.sprite.spritecollide(hypno_zombie,
|
zombie_list = pg.sprite.spritecollide( hypno_zombie, self.zombie_groups[i],
|
||||||
self.zombie_groups[i], False,collided_func)
|
False, collided_func)
|
||||||
for zombie in zombie_list:
|
for zombie in zombie_list:
|
||||||
if zombie.state == c.DIE:
|
if zombie.state == c.DIE:
|
||||||
continue
|
continue
|
||||||
@ -1358,7 +1360,7 @@ class Level(tool.State):
|
|||||||
self.killPlant(plant)
|
self.killPlant(plant)
|
||||||
|
|
||||||
def checkVictory(self):
|
def checkVictory(self):
|
||||||
if (c.ZOMBIE_LIST in self.map_data) and self.map_data[c.SPAWN_ZOMBIES] == c.SPAWN_ZOMBIES_LIST:
|
if self.map_data[c.SPAWN_ZOMBIES] == c.SPAWN_ZOMBIES_LIST:
|
||||||
if len(self.zombie_list) > 0:
|
if len(self.zombie_list) > 0:
|
||||||
return False
|
return False
|
||||||
for i in range(self.map_y_len):
|
for i in range(self.map_y_len):
|
||||||
@ -1508,7 +1510,7 @@ class Level(tool.State):
|
|||||||
surface.blit(self.restart_button, self.restart_button_rect)
|
surface.blit(self.restart_button, self.restart_button_rect)
|
||||||
surface.blit(self.mainMenu_button, self.mainMenu_button_rect)
|
surface.blit(self.mainMenu_button, self.mainMenu_button_rect)
|
||||||
|
|
||||||
if not ((c.ZOMBIE_LIST in self.map_data) and self.map_data[c.SPAWN_ZOMBIES] == c.SPAWN_ZOMBIES_LIST):
|
if self.map_data[c.SPAWN_ZOMBIES] == c.SPAWN_ZOMBIES_AUTO:
|
||||||
self.showLevelProgress(surface)
|
self.showLevelProgress(surface)
|
||||||
if self.current_time - self.showHugeWaveApprochingTime <= 2000:
|
if self.current_time - self.showHugeWaveApprochingTime <= 2000:
|
||||||
surface.blit(self.huge_wave_approching_image, self.huge_wave_approching_image_rect)
|
surface.blit(self.huge_wave_approching_image, self.huge_wave_approching_image_rect)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user