Exemple #1
0
 //Internal & accessory methods
 static List <Vector3> InternalPathOptimization(List <Vector3> path, int level)
 {
     if (OnLineOfSight(SpaceGraph.GetCellIndexFromCoordOnLevel(path[0], level), SpaceGraph.GetCellIndexFromCoordOnLevel(path[path.Count - 1], level), level))
     {
         return new List <Vector3> {
                    path[0], path[path.Count - 1]
         }
     }
     ;
     for (int j = 2; j <= path.Count - 3; j++)
     {
         for (int i = 2; i < path.Count; i += 2)
         {
             if (i >= path.Count)
             {
                 return(path);
             }
             if (OnLineOfSight(SpaceGraph.GetCellIndexFromCoordOnLevel(path[i - 2], level), SpaceGraph.GetCellIndexFromCoordOnLevel(path[i], level), level))
             {
                 path.RemoveAt(i - 1);
                 return(InternalPathOptimization(path, level));
             }
         }
     }
     return(path);
 }
Exemple #2
0
 public WaveTrace(SpaceConstraints spaceConstraintsInp, object cTInstance, Vector3 start, Vector3 goal)
 {
     this.cTInstance      = (CancellationToken)cTInstance;
     spaceConstarintsInst = spaceConstraintsInp;
     this.start           = SpaceGraph.GetCellIndexFromCoordOnLevel(start, 0);
     this.goal            = SpaceGraph.GetCellIndexFromCoordOnLevel(goal, 0);
     waves = new List <HashSet <Vector3> >();
 }
Exemple #3
0
    static List <Vector3> ChooseFreeAdjacents(List <Vector3> path, int level)
    {
        List <Vector3> newPath = new List <Vector3>();

        newPath.Add(path[0]);
        for (int i = 1; i < path.Count - 1; i++)
        {
            newPath.Add(GetFreeAdjacentCellCoord(SpaceGraph.GetCellIndexFromCoordOnLevel(path[i], level), level));
        }
        newPath.Distinct();
        newPath.Add(path[path.Count - 1]);
        return(newPath);
    }
Exemple #4
0
 public Graph(SpaceManager spaceManagerInstance, object cTInstance, Vector3 start, Vector3 goal, int pathfindingLevel, SpaceConstraints constraints, double omega, bool diags = false)
 {
     if (!constraints.Check(start) || !constraints.Check(goal))
     {
         throw new ArgumentOutOfRangeException();
     }
     this.goal                 = new Cube(SpaceGraph.GetCellIndexFromCoordOnLevel(goal, pathfindingLevel));
     this.start                = new Cube(SpaceGraph.GetCellIndexFromCoordOnLevel(start, pathfindingLevel), this.goal);
     this.constraints          = constraints;
     this.omega                = omega;
     this.diags                = diags;
     this.cTInstance           = cTInstance;
     this.spaceManagerInstance = spaceManagerInstance;
     this.pathfindingLevel     = pathfindingLevel;
 }