Merge branch 'master' of github.com:wszqkzqk/pypvz
This commit is contained in:
commit
533820deda
@ -1606,9 +1606,9 @@ class DoomShroom(Plant):
|
|||||||
|
|
||||||
# 用于描述毁灭菇的坑
|
# 用于描述毁灭菇的坑
|
||||||
class Hole(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)
|
Plant.__init__(self, x, y, c.HOLE, c.INF, None)
|
||||||
self.timer = 0
|
self.timer = 0
|
||||||
self.shallow = False
|
self.shallow = False
|
||||||
@ -1638,9 +1638,9 @@ class Hole(Plant):
|
|||||||
for i, name in enumerate(name_list):
|
for i, name in enumerate(name_list):
|
||||||
self.loadFrames(frame_list[i], name)
|
self.loadFrames(frame_list[i], name)
|
||||||
|
|
||||||
if self.plotType == c.MAP_TILE:
|
if self.plot_type == c.MAP_TILE:
|
||||||
self.frames = self.roof_frames
|
self.frames = self.roof_frames
|
||||||
elif self.plotType == c.MAP_WATER:
|
elif self.plot_type == c.MAP_WATER:
|
||||||
self.frames = self.water_frames
|
self.frames = self.water_frames
|
||||||
else:
|
else:
|
||||||
self.frames = self.idle_frames
|
self.frames = self.idle_frames
|
||||||
@ -1649,9 +1649,9 @@ class Hole(Plant):
|
|||||||
if self.timer == 0:
|
if self.timer == 0:
|
||||||
self.timer = self.current_time
|
self.timer = self.current_time
|
||||||
elif (not self.shallow) and (self.current_time - self.timer >= 90000):
|
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
|
self.frames = self.roof2_frames
|
||||||
elif self.plotType == c.MAP_WATER:
|
elif self.plot_type == c.MAP_WATER:
|
||||||
self.frames = self.water2_frames
|
self.frames = self.water2_frames
|
||||||
else:
|
else:
|
||||||
self.frames = self.idle2_frames
|
self.frames = self.idle2_frames
|
||||||
|
|||||||
@ -180,7 +180,7 @@ SURVIVAL_ROUNDS = "survival_rounds"
|
|||||||
# 地图单元格属性
|
# 地图单元格属性
|
||||||
MAP_PLANT = "plantnames"
|
MAP_PLANT = "plantnames"
|
||||||
MAP_SLEEP = "sleep" # 有没有休眠的蘑菇,作是否能种植咖啡豆的判断
|
MAP_SLEEP = "sleep" # 有没有休眠的蘑菇,作是否能种植咖啡豆的判断
|
||||||
MAP_PLOT_TYPE = "plotType"
|
MAP_PLOT_TYPE = "plot_type"
|
||||||
# 地图单元格区域类型
|
# 地图单元格区域类型
|
||||||
MAP_GRASS = "grass"
|
MAP_GRASS = "grass"
|
||||||
MAP_WATER = "water"
|
MAP_WATER = "water"
|
||||||
|
|||||||
@ -333,8 +333,8 @@ class Level(tool.State):
|
|||||||
return self.before_pause_time
|
return self.before_pause_time
|
||||||
|
|
||||||
def initBowlingMap(self):
|
def initBowlingMap(self):
|
||||||
for x in range(3, self.map.width):
|
for x in range(3, self.map_x_len):
|
||||||
for y in range(self.map.height):
|
for y in range(self.map_y_len):
|
||||||
self.map.setMapGridType(x, y, c.MAP_UNAVAILABLE) # 将坚果保龄球红线右侧设置为不可种植任何植物
|
self.map.setMapGridType(x, y, c.MAP_UNAVAILABLE) # 将坚果保龄球红线右侧设置为不可种植任何植物
|
||||||
|
|
||||||
def initState(self):
|
def initState(self):
|
||||||
@ -632,6 +632,8 @@ class Level(tool.State):
|
|||||||
def shovelRemovePlant(self, mouse_pos):
|
def shovelRemovePlant(self, mouse_pos):
|
||||||
x, y = mouse_pos
|
x, y = mouse_pos
|
||||||
map_x, map_y = self.map.getMapIndex(x, y)
|
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]:
|
for i in self.plant_groups[map_y]:
|
||||||
if (x >= i.rect.x and x <= i.rect.right and
|
if (x >= i.rect.x and x <= i.rect.right and
|
||||||
y >= i.rect.y and y <= i.rect.bottom):
|
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)
|
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)
|
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]:
|
if c.PUMPKINHEAD in self.map.map[map_y][map_x][c.MAP_PLANT]:
|
||||||
for actual_target_plant in self.plant_groups[i]:
|
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)
|
map_x, map_y = self.map.getMapIndex(x, y)
|
||||||
surface.blit(self.shovel, self.shovel_rect)
|
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]:
|
for i in self.plant_groups[map_y]:
|
||||||
if (x >= i.rect.x and x <= i.rect.right and
|
if (x >= i.rect.x and x <= i.rect.right and
|
||||||
y >= i.rect.y and y <= i.rect.bottom):
|
y >= i.rect.y and y <= i.rect.bottom):
|
||||||
|
|||||||
@ -1,5 +1,6 @@
|
|||||||
import os
|
import os
|
||||||
import pygame as pg
|
import pygame as pg
|
||||||
|
from abc import abstractmethod
|
||||||
from .. import tool
|
from .. import tool
|
||||||
from .. import constants as c
|
from .. import constants as c
|
||||||
|
|
||||||
@ -7,6 +8,7 @@ class Screen(tool.State):
|
|||||||
def __init__(self):
|
def __init__(self):
|
||||||
tool.State.__init__(self)
|
tool.State.__init__(self)
|
||||||
|
|
||||||
|
@abstractmethod
|
||||||
def startup(self, current_time, persist):
|
def startup(self, current_time, persist):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user