Example #1
0
        public PathFinderTask(int playerIndex, long unitId, long targetId, MapRoot map, int mapSize, VoxelData controlledData, Coordinate coordinate, VoxelAbilities ablilities, Coordinate[] waypoints, PathMatrixPool[] pools, Action <long, Coordinate[]> callback, Action <long> terminateCallback)
        {
            m_waypoints         = waypoints;
            m_callback          = callback;
            m_terminateCallback = terminateCallback;

            m_playerIndex = playerIndex;
            m_unitId      = unitId;
            m_targetId    = targetId;

            Map                         = map;
            MapSize                     = mapSize;
            m_controlledData            = new VoxelData(controlledData);
            m_controlledData.Unit.State = VoxelDataState.Idle;
            m_coordinate                = coordinate;
            m_abilities                 = new VoxelAbilities(ablilities);

            m_matrixPool = pools[m_controlledData.Weight - ablilities.MinWeight];
            m_hopsMatrix = m_matrixPool.Acquire();
            m_hopsMatrix[m_coordinate.Row, m_coordinate.Col] = 0;

            ClosestToGoal = m_coordinate;
            m_dataQueue   = new Queue <Data>();
            m_dataQueue.Enqueue(new Data(m_coordinate, 0));
        }
Example #2
0
 public PathFinder2(MapRoot map)
 {
     m_idToActiveTask = new Dictionary <long, PathFinderTask>();
     m_rand           = new System.Random(Guid.NewGuid().GetHashCode());
     m_matrixPools    = new PathMatrixPool[3];
     for (int i = 0; i < m_matrixPools.Length; ++i)
     {
         m_matrixPools[i] = new PathMatrixPool(100, map.GetMapSizeWith(GameConstants.MinVoxelActorWeight + i));
     }
 }