切换到Python 3.10

This commit is contained in:
wszqkzqk 2022-12-11 14:29:09 +08:00
parent ac392595b0
commit 17de44a773

View File

@ -435,10 +435,10 @@ class Level(tool.State):
# 地图有铲子才添加铲子 # 地图有铲子才添加铲子
if self.has_shovel: if self.has_shovel:
# 导入小铲子 # 导入小铲子
frame_rect = [0, 0, 71, 67] frame_rect = (0, 0, 71, 67)
self.shovel = tool.get_image_alpha(tool.GFX[c.SHOVEL], *frame_rect, c.BLACK, 1.1) self.shovel = tool.get_image_alpha(tool.GFX[c.SHOVEL], *frame_rect, c.BLACK, 1.1)
self.shovel_rect = self.shovel.get_rect() self.shovel_rect = self.shovel.get_rect()
frame_rect = [0, 0, 77, 75] frame_rect = (0, 0, 77, 75)
self.shovel_positon = (608, 1) self.shovel_positon = (608, 1)
self.shovel_box = tool.get_image_alpha(tool.GFX[c.SHOVEL_BOX], *frame_rect, c.BLACK, 1.1) self.shovel_box = tool.get_image_alpha(tool.GFX[c.SHOVEL_BOX], *frame_rect, c.BLACK, 1.1)
self.shovel_box_rect = self.shovel_box.get_rect() self.shovel_box_rect = self.shovel_box.get_rect()
@ -806,33 +806,34 @@ class Level(tool.State):
x, y = self.map.getMapGridPos(0, map_y) x, y = self.map.getMapGridPos(0, map_y)
# 新增的僵尸也需要在这里声明 # 新增的僵尸也需要在这里声明
if name == c.NORMAL_ZOMBIE: match name:
case c.NORMAL_ZOMBIE:
self.zombie_groups[map_y].add(zombie.NormalZombie(c.ZOMBIE_START_X + random.randint(-20, 20) + huge_wave_move, y, self.head_group)) self.zombie_groups[map_y].add(zombie.NormalZombie(c.ZOMBIE_START_X + random.randint(-20, 20) + huge_wave_move, y, self.head_group))
elif name == c.CONEHEAD_ZOMBIE: case c.CONEHEAD_ZOMBIE:
self.zombie_groups[map_y].add(zombie.ConeHeadZombie(c.ZOMBIE_START_X + random.randint(-20, 20) + huge_wave_move, y, self.head_group)) self.zombie_groups[map_y].add(zombie.ConeHeadZombie(c.ZOMBIE_START_X + random.randint(-20, 20) + huge_wave_move, y, self.head_group))
elif name == c.BUCKETHEAD_ZOMBIE: case c.BUCKETHEAD_ZOMBIE:
self.zombie_groups[map_y].add(zombie.BucketHeadZombie(c.ZOMBIE_START_X + random.randint(-20, 20) + huge_wave_move, y, self.head_group)) self.zombie_groups[map_y].add(zombie.BucketHeadZombie(c.ZOMBIE_START_X + random.randint(-20, 20) + huge_wave_move, y, self.head_group))
elif name == c.FLAG_ZOMBIE: case c.FLAG_ZOMBIE:
self.zombie_groups[map_y].add(zombie.FlagZombie(c.ZOMBIE_START_X, y, self.head_group)) self.zombie_groups[map_y].add(zombie.FlagZombie(c.ZOMBIE_START_X, y, self.head_group))
elif name == c.NEWSPAPER_ZOMBIE: case c.NEWSPAPER_ZOMBIE:
self.zombie_groups[map_y].add(zombie.NewspaperZombie(c.ZOMBIE_START_X + random.randint(-20, 20) + huge_wave_move, y, self.head_group)) self.zombie_groups[map_y].add(zombie.NewspaperZombie(c.ZOMBIE_START_X + random.randint(-20, 20) + huge_wave_move, y, self.head_group))
elif name == c.FOOTBALL_ZOMBIE: case c.FOOTBALL_ZOMBIE:
self.zombie_groups[map_y].add(zombie.FootballZombie(c.ZOMBIE_START_X + random.randint(-20, 20) + huge_wave_move, y, self.head_group)) self.zombie_groups[map_y].add(zombie.FootballZombie(c.ZOMBIE_START_X + random.randint(-20, 20) + huge_wave_move, y, self.head_group))
elif name == c.DUCKY_TUBE_ZOMBIE: case c.DUCKY_TUBE_ZOMBIE:
self.zombie_groups[map_y].add(zombie.DuckyTubeZombie(c.ZOMBIE_START_X + random.randint(-20, 20) + huge_wave_move, y, self.head_group)) self.zombie_groups[map_y].add(zombie.DuckyTubeZombie(c.ZOMBIE_START_X + random.randint(-20, 20) + huge_wave_move, y, self.head_group))
elif name == c.CONEHEAD_DUCKY_TUBE_ZOMBIE: case c.CONEHEAD_DUCKY_TUBE_ZOMBIE:
self.zombie_groups[map_y].add(zombie.ConeHeadDuckyTubeZombie(c.ZOMBIE_START_X + random.randint(-20, 20) + huge_wave_move, y, self.head_group)) self.zombie_groups[map_y].add(zombie.ConeHeadDuckyTubeZombie(c.ZOMBIE_START_X + random.randint(-20, 20) + huge_wave_move, y, self.head_group))
elif name == c.BUCKETHEAD_DUCKY_TUBE_ZOMBIE: case c.BUCKETHEAD_DUCKY_TUBE_ZOMBIE:
self.zombie_groups[map_y].add(zombie.BucketHeadDuckyTubeZombie(c.ZOMBIE_START_X + random.randint(-20, 20) + huge_wave_move, y, self.head_group)) self.zombie_groups[map_y].add(zombie.BucketHeadDuckyTubeZombie(c.ZOMBIE_START_X + random.randint(-20, 20) + huge_wave_move, y, self.head_group))
elif name == c.SCREEN_DOOR_ZOMBIE: case c.SCREEN_DOOR_ZOMBIE:
self.zombie_groups[map_y].add(zombie.ScreenDoorZombie(c.ZOMBIE_START_X + random.randint(-20, 20) + huge_wave_move, y, self.head_group)) self.zombie_groups[map_y].add(zombie.ScreenDoorZombie(c.ZOMBIE_START_X + random.randint(-20, 20) + huge_wave_move, y, self.head_group))
elif name == c.POLE_VAULTING_ZOMBIE: case c.POLE_VAULTING_ZOMBIE:
# 本来撑杆跳生成位置不同对齐左端可认为修正了一部分看作移动了70只需要相对修改即可 # 本来撑杆跳生成位置不同对齐左端可认为修正了一部分看作移动了70只需要相对修改即可
self.zombie_groups[map_y].add(zombie.PoleVaultingZombie(c.ZOMBIE_START_X + random.randint(0, 10) + huge_wave_move, y, self.head_group)) self.zombie_groups[map_y].add(zombie.PoleVaultingZombie(c.ZOMBIE_START_X + random.randint(0, 10) + huge_wave_move, y, self.head_group))
elif name == c.ZOMBONI: case c.ZOMBONI:
# 冰车僵尸生成位置不同 # 冰车僵尸生成位置不同
self.zombie_groups[map_y].add(zombie.Zomboni(c.ZOMBIE_START_X + random.randint(0, 10) + huge_wave_move, 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) + huge_wave_move, y, self.plant_groups[map_y], self.map, plant.IceFrozenPlot))
elif name == c.SNORKELZOMBIE: case c.SNORKELZOMBIE:
# 潜水僵尸生成位置不同 # 潜水僵尸生成位置不同
self.zombie_groups[map_y].add(zombie.SnorkelZombie(c.ZOMBIE_START_X + random.randint(0, 10) + huge_wave_move, y, self.head_group)) self.zombie_groups[map_y].add(zombie.SnorkelZombie(c.ZOMBIE_START_X + random.randint(0, 10) + huge_wave_move, y, self.head_group))
@ -858,72 +859,73 @@ class Level(tool.State):
map_x, map_y = self.map.getMapIndex(x, y) map_x, map_y = self.map.getMapIndex(x, y)
# 新植物也需要在这里声明 # 新植物也需要在这里声明
if self.plant_name == c.SUNFLOWER: match self.plant_name:
case c.SUNFLOWER:
new_plant = plant.SunFlower(x, y, self.sun_group) new_plant = plant.SunFlower(x, y, self.sun_group)
elif self.plant_name == c.PEASHOOTER: case c.PEASHOOTER:
new_plant = plant.PeaShooter(x, y, self.bullet_groups[map_y]) new_plant = plant.PeaShooter(x, y, self.bullet_groups[map_y])
elif self.plant_name == c.SNOWPEASHOOTER: case c.SNOWPEASHOOTER:
new_plant = plant.SnowPeaShooter(x, y, self.bullet_groups[map_y]) new_plant = plant.SnowPeaShooter(x, y, self.bullet_groups[map_y])
elif self.plant_name == c.WALLNUT: case c.WALLNUT:
new_plant = plant.WallNut(x, y) new_plant = plant.WallNut(x, y)
elif self.plant_name == c.CHERRYBOMB: case c.CHERRYBOMB:
new_plant = plant.CherryBomb(x, y) new_plant = plant.CherryBomb(x, y)
elif self.plant_name == c.THREEPEASHOOTER: case c.THREEPEASHOOTER:
new_plant = plant.ThreePeaShooter(x, y, self.bullet_groups, map_y, self.map.background_type) new_plant = plant.ThreePeaShooter(x, y, self.bullet_groups, map_y, self.map.background_type)
elif self.plant_name == c.REPEATERPEA: case c.REPEATERPEA:
new_plant = plant.RepeaterPea(x, y, self.bullet_groups[map_y]) new_plant = plant.RepeaterPea(x, y, self.bullet_groups[map_y])
elif self.plant_name == c.CHOMPER: case c.CHOMPER:
new_plant = plant.Chomper(x, y) new_plant = plant.Chomper(x, y)
elif self.plant_name == c.PUFFSHROOM: case c.PUFFSHROOM:
new_plant = plant.PuffShroom(x, y, self.bullet_groups[map_y]) new_plant = plant.PuffShroom(x, y, self.bullet_groups[map_y])
elif self.plant_name == c.POTATOMINE: case c.POTATOMINE:
new_plant = plant.PotatoMine(x, y) new_plant = plant.PotatoMine(x, y)
elif self.plant_name == c.SQUASH: case c.SQUASH:
new_plant = plant.Squash(x, y, self.map.map[map_y][map_x][c.MAP_PLANT]) new_plant = plant.Squash(x, y, self.map.map[map_y][map_x][c.MAP_PLANT])
elif self.plant_name == c.SPIKEWEED: case c.SPIKEWEED:
new_plant = plant.Spikeweed(x, y) new_plant = plant.Spikeweed(x, y)
elif self.plant_name == c.JALAPENO: case c.JALAPENO:
new_plant = plant.Jalapeno(x, y) new_plant = plant.Jalapeno(x, y)
elif self.plant_name == c.SCAREDYSHROOM: case c.SCAREDYSHROOM:
new_plant = plant.ScaredyShroom(x, y, self.bullet_groups[map_y]) new_plant = plant.ScaredyShroom(x, y, self.bullet_groups[map_y])
elif self.plant_name == c.SUNSHROOM: case c.SUNSHROOM:
new_plant = plant.SunShroom(x, y, self.sun_group) new_plant = plant.SunShroom(x, y, self.sun_group)
elif self.plant_name == c.ICESHROOM: case c.ICESHROOM:
new_plant = plant.IceShroom(x, y) new_plant = plant.IceShroom(x, y)
elif self.plant_name == c.HYPNOSHROOM: case c.HYPNOSHROOM:
new_plant = plant.HypnoShroom(x, y) new_plant = plant.HypnoShroom(x, y)
elif self.plant_name == c.WALLNUTBOWLING: case c.WALLNUTBOWLING:
new_plant = plant.WallNutBowling(x, y, map_y, self) new_plant = plant.WallNutBowling(x, y, map_y, self)
elif self.plant_name == c.REDWALLNUTBOWLING: case c.REDWALLNUTBOWLING:
new_plant = plant.RedWallNutBowling(x, y) new_plant = plant.RedWallNutBowling(x, y)
elif self.plant_name == c.LILYPAD: case c.LILYPAD:
new_plant = plant.LilyPad(x, y) new_plant = plant.LilyPad(x, y)
elif self.plant_name == c.TORCHWOOD: case c.TORCHWOOD:
new_plant = plant.TorchWood(x, y, self.bullet_groups[map_y]) new_plant = plant.TorchWood(x, y, self.bullet_groups[map_y])
elif self.plant_name == c.STARFRUIT: case c.STARFRUIT:
new_plant = plant.StarFruit(x, y, self.bullet_groups[map_y], self) new_plant = plant.StarFruit(x, y, self.bullet_groups[map_y], self)
elif self.plant_name == c.COFFEEBEAN: case c.COFFEEBEAN:
new_plant = plant.CoffeeBean(x, y, self.plant_groups[map_y], self.map.map[map_y][map_x], self.map, map_x) new_plant = plant.CoffeeBean(x, y, self.plant_groups[map_y], self.map.map[map_y][map_x], self.map, map_x)
elif self.plant_name == c.SEASHROOM: case c.SEASHROOM:
new_plant = plant.SeaShroom(x, y, self.bullet_groups[map_y]) new_plant = plant.SeaShroom(x, y, self.bullet_groups[map_y])
elif self.plant_name == c.TALLNUT: case c.TALLNUT:
new_plant = plant.TallNut(x, y) new_plant = plant.TallNut(x, y)
elif self.plant_name == c.TANGLEKLEP: case c.TANGLEKLEP:
new_plant = plant.TangleKlep(x, y) new_plant = plant.TangleKlep(x, y)
elif self.plant_name == c.DOOMSHROOM: case c.DOOMSHROOM:
if self.map.grid_height_size == c.GRID_Y_SIZE: if self.map.grid_height_size == c.GRID_Y_SIZE:
new_plant = plant.DoomShroom(x, y, self.map.map[map_y][map_x][c.MAP_PLANT], explode_y_range=2) new_plant = plant.DoomShroom(x, y, self.map.map[map_y][map_x][c.MAP_PLANT], explode_y_range=2)
else: else:
new_plant = plant.DoomShroom(x, y, self.map.map[map_y][map_x][c.MAP_PLANT], explode_y_range=3) new_plant = plant.DoomShroom(x, y, self.map.map[map_y][map_x][c.MAP_PLANT], explode_y_range=3)
elif self.plant_name == c.GRAVEBUSTER: case c.GRAVEBUSTER:
new_plant = plant.GraveBuster(x, y, self.plant_groups[map_y], self.map, map_x) new_plant = plant.GraveBuster(x, y, self.plant_groups[map_y], self.map, map_x)
elif self.plant_name == c.FUMESHROOM: case c.FUMESHROOM:
new_plant = plant.FumeShroom(x, y, self.bullet_groups[map_y], self.zombie_groups[map_y]) new_plant = plant.FumeShroom(x, y, self.bullet_groups[map_y], self.zombie_groups[map_y])
elif self.plant_name == c.GARLIC: case c.GARLIC:
new_plant = plant.Garlic(x, y) new_plant = plant.Garlic(x, y)
elif self.plant_name == c.PUMPKINHEAD: case c.PUMPKINHEAD:
new_plant = plant.PumpkinHead(x, y) new_plant = plant.PumpkinHead(x, y)
elif self.plant_name == c.GIANTWALLNUT: case c.GIANTWALLNUT:
new_plant = plant.GiantWallNut(x, y) new_plant = plant.GiantWallNut(x, y)