Beispiel #1
0
 private void routePlayerToTurret(TeamInformation ti, Turret turret)
 {
     ti.playerObjective = turret;
     List<GridObjectInterface> neighbouringObjects = this.spatialGrid.checkNeighbouringBlocks(turret);
     Node closeWaypointToTurret = null;
     foreach (GridObjectInterface obj in neighbouringObjects)
         if (obj is Node && (obj.Position - ti.playerObjective.Position).Length() <= GridDataCollection.MAX_CAPTURE_DISTANCE)
         {
             closeWaypointToTurret = obj as Node;
             break;
         }
     neighbouringObjects = this.spatialGrid.checkNeighbouringBlocks(ti.teamPlayer);
     Node closeWaypointToPlayer = null;
     float minDist = 0;
     foreach (GridObjectInterface obj in neighbouringObjects)
         if (obj is Node)
         {
             float dist = (obj.Position - ti.teamPlayer.Position).Length();
             if (closeWaypointToPlayer == null || minDist > dist)
             {
                 closeWaypointToPlayer = obj as Node;
                 minDist = dist;
             }
         }
     if (!(closeWaypointToTurret == null || closeWaypointToPlayer == null))
         navComputer.setNewPathForRegisteredObject(ti.teamPlayer, closeWaypointToPlayer, closeWaypointToTurret);
     else
     {
         List<Node> path = new List<Node>();
         path.Add(new Node(ti.playerObjective.Position + Vector3.Normalize(Matrix.CreateFromQuaternion(ti.playerObjective.rotation).Forward) *
             (ti.playerObjective.getGreatestLength + ti.teamPlayer.getGreatestLength) * LINE_OF_SIGHT_CLOSE_DIST_MULTIPLYER, -1));
         navComputer.objectPaths[ti.teamPlayer].remainingPath = path;
     }
 }
Beispiel #2
0
 public void registerTurretOnTeam(Turret turret, Team team)
 {
     if (team == Team.neutral)
         return;
     foreach (TeamInformation ti in infoOnTeams)
         if (ti.teamId == team)
         {
             ti.ownedTurrets.Add(turret);
             return;
         }
 }