Exemple #1
0
    /// <summary>
    /// Uses pathfinding to generate a path between the 2 given points in game-space.
    /// </summary>
    private void CalcPath(Point3 playerPos, Point3 monsterPos)
    {
        // path find around the monster, find path to player
        print("playerPos: " + playerPos);
        print("monsterPos: " + monsterPos);
        Pathfinding pathfinding = mazeStruct.Pathfind(monsterPos);

        path = pathfinding.PathToPoint(playerPos);

        // fill in positions
        distance = 0;
        //Debug.Log("path: "+path);
        //Debug.Log("path length: "+path.Length);
        positions = new Vector3[path.Length];
        for (int i = 0; i < positions.Length; ++i)
        {
            Point3  p = path[i];
            Vector3 v = mazeStruct.FromGameToCube(p);
            positions[i] = mazeStruct.Vector3FromCubeToSphere(v);
            //print(path[i]+" -> "+v+" -> "+v+" -> "+positions[i]);
        }
    }
 public void Init(MazeStructure mazeStruct, MazeCell[,,] cells, AudioSource lightOff)
 {
     this.cells = cells;
     this.path  = mazeStruct.Pathfind(mazeStruct.FindKey()[0]);
     this.sound = lightOff;
 }