游戏可以运行
This commit is contained in:
@@ -39,16 +39,19 @@ class Tower:
|
||||
continue
|
||||
d = distance(self.x, self.y, e.x, e.y)
|
||||
if d <= self.range:
|
||||
progress = e.waypoint_index + (1 - distance(e.x, e.y, *self._wp(e.waypoint_index)) / 100)
|
||||
wp_idx = min(e.waypoint_index, len(e.waypoints) - 1)
|
||||
progress = e.waypoint_index + (1 - distance(e.x, e.y, *e.waypoints[wp_idx]) / 100)
|
||||
if progress > best_progress:
|
||||
best_progress = progress
|
||||
best = e
|
||||
self.target = best
|
||||
|
||||
def _wp(self, idx):
|
||||
if self.target and idx < len(self.target.waypoints):
|
||||
return self.target.waypoints[idx]
|
||||
if self.target:
|
||||
return self.target.waypoints[-1]
|
||||
from game.config import PATH_WAYPOINTS
|
||||
if idx < len(PATH_WAYPOINTS):
|
||||
return PATH_WAYPOINTS[idx]
|
||||
return PATH_WAYPOINTS[-1]
|
||||
|
||||
def update(self, dt, enemies, projectiles):
|
||||
|
||||
Reference in New Issue
Block a user