微调攻击范围
This commit is contained in:
parent
0a5ce37a73
commit
dfcbff5228
@ -290,7 +290,7 @@ class Plant(pg.sprite.Sprite):
|
|||||||
|
|
||||||
def canAttack(self, zombie):
|
def canAttack(self, zombie):
|
||||||
if (self.state != c.SLEEP and zombie.state != c.DIE and (not zombie.lostHead) and
|
if (self.state != c.SLEEP and zombie.state != c.DIE and (not zombie.lostHead) and
|
||||||
self.rect.x <= zombie.rect.right and zombie.rect.left <= 800):
|
self.rect.x <= zombie.rect.right and zombie.rect.left <= c.SCREEN_WIDTH + 3):
|
||||||
return True
|
return True
|
||||||
return False
|
return False
|
||||||
|
|
||||||
@ -596,7 +596,7 @@ class PuffShroom(Plant):
|
|||||||
|
|
||||||
def canAttack(self, zombie):
|
def canAttack(self, zombie):
|
||||||
if (self.rect.x <= zombie.rect.right and
|
if (self.rect.x <= zombie.rect.right and
|
||||||
(self.rect.x + c.GRID_X_SIZE * 3.5 >= zombie.rect.x)):
|
(self.rect.x + c.GRID_X_SIZE * 3.5 >= zombie.rect.x) and (zombie.rect.left <= c.SCREEN_WIDTH + 3)):
|
||||||
return True
|
return True
|
||||||
return False
|
return False
|
||||||
|
|
||||||
@ -1149,10 +1149,10 @@ class StarFruit(Plant):
|
|||||||
if (self.rect.x >= zombie.rect.x) and (self.map_y == zombieMapY): # 对于同行且在杨桃后的僵尸
|
if (self.rect.x >= zombie.rect.x) and (self.map_y == zombieMapY): # 对于同行且在杨桃后的僵尸
|
||||||
return True
|
return True
|
||||||
# 斜向上,理想直线方程为:f(zombie.rect.x) = -0.75*(zombie.rect.x - (self.rect.right - 5)) + self.rect.y - 10
|
# 斜向上,理想直线方程为:f(zombie.rect.x) = -0.75*(zombie.rect.x - (self.rect.right - 5)) + self.rect.y - 10
|
||||||
elif -100 <= (zombie.rect.y - (-0.75*(zombie.rect.x - (self.rect.right - 5)) + self.rect.y - 10)) <= 70:
|
elif -100 <= (zombie.rect.y - (-0.75*(zombie.rect.x - (self.rect.right - 5)) + self.rect.y - 10)) <= 70 and (zombie.rect.left <= c.SCREEN_WIDTH + 3):
|
||||||
return True
|
return True
|
||||||
# 斜向下,理想直线方程为:f(zombie.rect.x) = zombie.rect.x + self.rect.y - self.rect.right - 15
|
# 斜向下,理想直线方程为:f(zombie.rect.x) = zombie.rect.x + self.rect.y - self.rect.right - 15
|
||||||
elif abs(zombie.rect.y - (zombie.rect.x + self.rect.y - self.rect.right - 15)) <= 70:
|
elif abs(zombie.rect.y - (zombie.rect.x + self.rect.y - self.rect.right - 15)) <= 70 and (zombie.rect.left <= c.SCREEN_WIDTH + 3):
|
||||||
return True
|
return True
|
||||||
elif zombie.rect.left <= self.rect.x <= zombie.rect.right:
|
elif zombie.rect.left <= self.rect.x <= zombie.rect.right:
|
||||||
return True
|
return True
|
||||||
|
|||||||
@ -1180,6 +1180,6 @@ class Level(tool.State):
|
|||||||
surface.blit(self.mainMenu_button, self.mainMenu_button_rect)
|
surface.blit(self.mainMenu_button, self.mainMenu_button_rect)
|
||||||
|
|
||||||
if not ((c.ZOMBIE_LIST in self.map_data.keys()) and self.map_data[c.SPAWN_ZOMBIES] == c.SPAWN_ZOMBIES_LIST):
|
if not ((c.ZOMBIE_LIST in self.map_data.keys()) and self.map_data[c.SPAWN_ZOMBIES] == c.SPAWN_ZOMBIES_LIST):
|
||||||
|
self.showLevelProgress(surface)
|
||||||
if self.current_time - self.showHugeWaveApprochingTime <= 2000:
|
if self.current_time - self.showHugeWaveApprochingTime <= 2000:
|
||||||
surface.blit(self.huge_wave_approching_image, self.huge_wave_approching_image_rect)
|
surface.blit(self.huge_wave_approching_image, self.huge_wave_approching_image_rect)
|
||||||
self.showLevelProgress(surface)
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user