From 992aae306e86198a571d03cf0cc8c4965c83f9ce Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=98=9F=E5=A4=96=E4=B9=8B=E7=A5=9E?= Date: Sat, 30 Apr 2022 11:57:23 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A4=A7=E6=B3=A2=E5=85=88=E7=94=9F=E6=88=90?= =?UTF-8?q?=E6=97=97=E5=B8=9C=E5=83=B5=E5=B0=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- source/state/level.py | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/source/state/level.py b/source/state/level.py index dc4a07b..f04bb88 100644 --- a/source/state/level.py +++ b/source/state/level.py @@ -4,6 +4,7 @@ import sys import pygame as pg from random import randint from random import choices +from random import uniform from .. import tool from .. import constants as c from ..component import map, plant, zombie, menubar @@ -120,10 +121,16 @@ class Level(tool.State): # 按照原版pvz设计的僵尸容量函数,是从无尽解析的,但是普通关卡也可以遵循 for wave in range(1, 10 * numFlags + 1): volume = int(int((wave + survivalRounds*20)*0.8)/2) + 1 - if wave % 10 == 0: - volume = int(volume*2.5) zombieList = [] + # 大波僵尸情况 + if wave % 10 == 0: + # 容量增大至2.5倍 + volume = int(volume*2.5) + # 先生成旗帜僵尸 + zombieList.append(c.FLAG_ZOMBIE) + volume -= self.createZombieInfo[c.FLAG_ZOMBIE][0] + if inevitableZombieDict and (str(wave) in inevitableZombieDict.keys()): for newZombie in inevitableZombieDict[str(wave)]: zombieList.append(newZombie) @@ -168,12 +175,10 @@ class Level(tool.State): self.waveZombies = self.waves[self.waveNum - 1] self.numZombie = len(self.waveZombies) return - - numZombies = 0 for i in range(self.map_y_len): numZombies += len(self.zombie_groups[i]) - if numZombies / self.numZombie < 0.15: + if numZombies / self.numZombie < uniform(0.15, 0.25): self.waveNum += 1 self.waveTime = current_time self.waveZombies = self.waves[self.waveNum - 1]