含泳池的模式最后一波从水中生成3个僵尸

This commit is contained in:
星外之神 2022-05-08 22:59:39 +08:00
parent 7dbd6f0b77
commit 13389bae23
2 changed files with 24 additions and 1 deletions

View File

@ -4,7 +4,7 @@
**本项目为个人python语言学习的练习项目仅供个人学习和研究使用不得用于其他用途。如果这个游戏侵犯了版权请联系我删除** **本项目为个人python语言学习的练习项目仅供个人学习和研究使用不得用于其他用途。如果这个游戏侵犯了版权请联系我删除**
* 已有的植物:向日葵,豌豆射手,坚果墙,寒冰射手,樱桃炸弹,三线射手,大嘴花,小喷菇,土豆雷,地刺,胆小菇,倭瓜,火爆辣椒,阳光菇,寒冰菇,魅惑菇,火炬树桩,睡莲,杨桃,咖啡豆,海蘑菇,高坚果,缠绕水草,毁灭菇 * 已有的植物:向日葵,豌豆射手,坚果墙,寒冰射手,樱桃炸弹,三线射手,大嘴花,小喷菇,土豆雷,地刺,胆小菇,倭瓜,火爆辣椒,阳光菇,寒冰菇,魅惑菇,火炬树桩,睡莲,杨桃,咖啡豆,海蘑菇,高坚果,缠绕水草,毁灭菇,墓碑吞噬者
* 已有的僵尸:普通僵尸,旗帜僵尸,路障僵尸,铁桶僵尸,读报僵尸,橄榄球僵尸,鸭子救生圈僵尸,铁门僵尸 * 已有的僵尸:普通僵尸,旗帜僵尸,路障僵尸,铁桶僵尸,读报僵尸,橄榄球僵尸,鸭子救生圈僵尸,铁门僵尸
* 使用 JSON 文件记录关卡信息数据 * 使用 JSON 文件记录关卡信息数据
* 支持选择植物卡片 * 支持选择植物卡片
@ -16,6 +16,8 @@
* 支持用小铲子移除植物 * 支持用小铲子移除植物
* 支持分波生成僵尸 * 支持分波生成僵尸
* 支持“关卡进程”进度条显示 * 支持“关卡进程”进度条显示
* 夜晚模式支持墓碑以及从墓碑生成僵尸
* 含有泳池的模式也支持在最后一波时从泳池中自动冒出僵尸
## 环境要求 ## 环境要求

View File

@ -166,6 +166,10 @@ class Level(tool.State):
self.waves = waves self.waves = waves
# 针对有泳池的关卡
# 表示尚未生成最后一波中从水里冒出来的僵尸
self.createdZombieFromPool = False
# 僵尸的刷新机制 # 僵尸的刷新机制
def refreshWaves(self, current_time, survivalRounds=0): def refreshWaves(self, current_time, survivalRounds=0):
@ -180,6 +184,23 @@ class Level(tool.State):
itemX, itemY = self.map.getMapGridPos(*item) itemX, itemY = self.map.getMapGridPos(*item)
self.zombie_groups[item[1]].add(zombie.NormalZombie(itemX, itemY, self.head_group)) self.zombie_groups[item[1]].add(zombie.NormalZombie(itemX, itemY, self.head_group))
self.graveZombieCreated = True self.graveZombieCreated = True
elif self.map_data[c.BACKGROUND_TYPE] in {c.BACKGROUND_POOL, c.BACKGROUND_FOG}:
if not self.createdZombieFromPool:
if current_time - self.waveTime > 1500:
for i in range(3):
# 水中倒数四列内可以在此时产生僵尸。共产生3个
mapX, mapY = randint(5, 8), randint(2, 3)
itemX, itemY = self.map.getMapGridPos(mapX, mapY)
# 用随机数指定产生的僵尸类型
# 带有权重
zombieType = randint(1, 6)
if zombieType == 1:
self.zombie_groups[mapY].add(zombie.BucketHeadDuckyTubeZombie(itemX, itemY, self.head_group))
elif zombieType <= 3:
self.zombie_groups[mapY].add(zombie.ConeHeadDuckyTubeZombie(itemX, itemY, self.head_group))
else:
self.zombie_groups[mapY].add(zombie.DuckyTubeZombie(itemX, itemY, self.head_group))
self.createdZombieFromPool = True
return return
# 还未开始出现僵尸 # 还未开始出现僵尸