Example #1
0
 public MazeAStar(VisionMapping vision, Func <Map2d> getMap, Func <bool> canJump, Action reset_state,
                  GetCameFrom get_came_from, Action <Coord, Coord, int> set_came_from,
                  Func <Coord, float> get_f_score, Action <Coord, float> set_f_score,
                  Func <Coord, float> get_g_score, Action <Coord, float> set_g_score)
 {
     SetAstarSourceData(vision, getMap, canJump, reset_state, get_came_from, set_came_from, get_f_score, set_f_score, get_g_score, set_g_score);
 }
Example #2
0
    public Map2dAStar(Func <bool> canJump, MazeLevel maze, VisionMapping vision, Transform transform, GameObject prefab_debug_astar)
    {
        this.maze = maze;
        this.prefab_debug_astar = prefab_debug_astar;
        SetAstarSourceData(vision, () => maze.Map, canJump, ResetCalcSpace,
                           (Coord c, out Coord n) => {
            AStarData a = calcSpace.At(c);
            Coord f     = a.from;                 //e = a._edge;
            n           = f != Coord.NegativeOne ? f : c;
            return(a._edge);
        },
                           (c, f, e) => {
            AStarData a = calcSpace.At(c);
            a._edge     = e; a.from = f;
        },
                           c => calcSpace.At(c).f, (c, f) => { calcSpace.At(c).f = f; },
                           c => calcSpace.At(c).g, (c, f) => { calcSpace.At(c).g = f; });
        ResetCalcSpace(Map.GetSize());
        Vector3 p    = transform.position;
        Coord   here = maze.GetCoord(p);

        Start(here, here);
        if (prefab_debug_astar != null)
        {
            maze.seen.onChange += RefreshVision;
            vision.onChange    += RefreshVision;
        }
    }
Example #3
0
 public void SetAstarSourceData(VisionMapping vision, Func <Map2d> getMap, Func <bool> canJump, Action reset_state,
                                GetCameFrom get_came_from, Action <Coord, Coord, int> set_came_from,
                                Func <Coord, float> get_f_score, Action <Coord, float> set_f_score,
                                Func <Coord, float> get_g_score, Action <Coord, float> set_g_score)
 {
     this.getMap  = getMap;
     this.canJump = canJump;
     this.vision  = vision;
     SetNodeAndEdgeMethods(GetEdges, NextNode, EdgeCost, Dist, reset_state, get_came_from, set_came_from, get_f_score, set_f_score, get_g_score, set_g_score);
 }
Example #4
0
 public void ResetCalc()
 {
     if (vision == null)
     {
         if (maze != null && maze.Map != null)
         {
             vision = new VisionMapping(() => maze.Map.GetSize());
         }
     }
     else
     {
         vision.Reset();
     }
     Blink();
 }
Example #5
0
 public AStarData Reset(Coord c, Map2dAStar a, VisionMapping vm, GameObject prefab_data_vis)
 {
     _f     = _g = _edge = -1; _from = c;
     coord  = c;
     astar  = a;
     visMap = vm;
     if (debugVisibleObject == null && prefab_data_vis != null)
     {
         debugVisibleObject = GameObject.Instantiate(prefab_data_vis);
         RefreshDebug();
     }
     if (debugVisibleObject)
     {
         debugVisibleObject.name = prefab_data_vis.name + " (" + coord + ")";
         if (fromArrow != null)
         {
             RefreshDebugFromArrow();
         }
     }
     return(this);
 }
Example #6
0
 private void Awake()
 {
     _t   = transform;
     seen = new VisionMapping(() => map != null ? map.GetSize() : new Coord(7, 7));
 }
Example #7
0
 public AStarData(Coord c, Map2dAStar a, VisionMapping vm, GameObject prefab_data_vis)
 {
     Reset(c, a, vm, prefab_data_vis);
 }