Merge branch 'master' of github.com:wszqkzqk/pypvz

This commit is contained in:
wszqkzqk 2022-08-30 18:57:43 +08:00
commit 533820deda
4 changed files with 16 additions and 10 deletions

View File

@ -1606,9 +1606,9 @@ class DoomShroom(Plant):
# 用于描述毁灭菇的坑
class Hole(Plant):
def __init__(self, x, y, plotType):
def __init__(self, x, y, plot_type):
# 指定区域类型这一句必须放在前面,否则加载图片判断将会失败
self.plotType = plotType
self.plot_type = plot_type
Plant.__init__(self, x, y, c.HOLE, c.INF, None)
self.timer = 0
self.shallow = False
@ -1638,9 +1638,9 @@ class Hole(Plant):
for i, name in enumerate(name_list):
self.loadFrames(frame_list[i], name)
if self.plotType == c.MAP_TILE:
if self.plot_type == c.MAP_TILE:
self.frames = self.roof_frames
elif self.plotType == c.MAP_WATER:
elif self.plot_type == c.MAP_WATER:
self.frames = self.water_frames
else:
self.frames = self.idle_frames
@ -1649,9 +1649,9 @@ class Hole(Plant):
if self.timer == 0:
self.timer = self.current_time
elif (not self.shallow) and (self.current_time - self.timer >= 90000):
if self.plotType == c.MAP_TILE:
if self.plot_type == c.MAP_TILE:
self.frames = self.roof2_frames
elif self.plotType == c.MAP_WATER:
elif self.plot_type == c.MAP_WATER:
self.frames = self.water2_frames
else:
self.frames = self.idle2_frames

View File

@ -180,7 +180,7 @@ SURVIVAL_ROUNDS = "survival_rounds"
# 地图单元格属性
MAP_PLANT = "plantnames"
MAP_SLEEP = "sleep" # 有没有休眠的蘑菇,作是否能种植咖啡豆的判断
MAP_PLOT_TYPE = "plotType"
MAP_PLOT_TYPE = "plot_type"
# 地图单元格区域类型
MAP_GRASS = "grass"
MAP_WATER = "water"

View File

@ -333,8 +333,8 @@ class Level(tool.State):
return self.before_pause_time
def initBowlingMap(self):
for x in range(3, self.map.width):
for y in range(self.map.height):
for x in range(3, self.map_x_len):
for y in range(self.map_y_len):
self.map.setMapGridType(x, y, c.MAP_UNAVAILABLE) # 将坚果保龄球红线右侧设置为不可种植任何植物
def initState(self):
@ -632,6 +632,8 @@ class Level(tool.State):
def shovelRemovePlant(self, mouse_pos):
x, y = mouse_pos
map_x, map_y = self.map.getMapIndex(x, y)
if not self.map.isValid(map_x, map_y):
return
for i in self.plant_groups[map_y]:
if (x >= i.rect.x and x <= i.rect.right and
y >= i.rect.y and y <= i.rect.bottom):
@ -1082,7 +1084,7 @@ class Level(tool.State):
# 默认为最右侧的一个植物
target_plant = max(attackable_common_plants, key=lambda i: i.rect.x)
map_x, map_y = self.map.getMapIndex(target_plant.rect.centerx, target_plant.rect.centery)
if not (map_x >= self.map.width or map_y >= self.map.height):
if self.map.isValid(map_x, map_y):
if c.PUMPKINHEAD in self.map.map[map_y][map_x][c.MAP_PLANT]:
for actual_target_plant in self.plant_groups[i]:
# 检测同一格的其他植物
@ -1469,6 +1471,8 @@ class Level(tool.State):
# 铲子接近植物时会高亮提示
map_x, map_y = self.map.getMapIndex(x, y)
surface.blit(self.shovel, self.shovel_rect)
if not self.map.isValid(map_x, map_y):
return
for i in self.plant_groups[map_y]:
if (x >= i.rect.x and x <= i.rect.right and
y >= i.rect.y and y <= i.rect.bottom):

View File

@ -1,5 +1,6 @@
import os
import pygame as pg
from abc import abstractmethod
from .. import tool
from .. import constants as c
@ -7,6 +8,7 @@ class Screen(tool.State):
def __init__(self):
tool.State.__init__(self)
@abstractmethod
def startup(self, current_time, persist):
pass