示例#1
0
    //private SortedSet<int> _mapsInTheWorld;

    private WorldMap(IWorldMapProvider mapDataManager)
    {
        if (mapDataManager == null)
            throw new ArgumentNullException("mapDataManager", "You need to provide the instance of an object to retrieve map data");
        IWorldMapProvider _mapDataManager = mapDataManager;
        WorldMapConnectionsStored = GetWorldMapConnections(_mapDataManager, true);
        WorldMapConnectionsComputed = GetWorldMapConnections(_mapDataManager, false);
    }
示例#2
0
        //private SortedSet<int> _mapsInTheWorld;

        private WorldMap(IWorldMapProvider mapDataManager)
        {
            if (mapDataManager == null)
            {
                throw new ArgumentNullException("mapDataManager", "You need to provide the instance of an object to retrieve map data");
            }
            IWorldMapProvider _mapDataManager = mapDataManager;

            WorldMapConnectionsStored   = GetWorldMapConnections(_mapDataManager, true);
            WorldMapConnectionsComputed = GetWorldMapConnections(_mapDataManager, false);
        }
示例#3
0
        private Dictionary <int, List <int> > GetWorldMapConnections(IWorldMapProvider mapDataManager, bool StoredInMap)
        {
            _mapDataManager = mapDataManager;
            Stopwatch st = new Stopwatch();

            st.Start();
            //MapDataManager mapDataManager = new MapDataManager(pathToMapsData, StoredInMap); // Gets only Headers, except if checking cell content is needed
            Dictionary <int, List <int> > dico = new Dictionary <int, List <int> >(mapDataManager.KnownMapIds.Count);

            foreach (int mapId in mapDataManager.KnownMapIds)
            {
                IMap mapData = mapDataManager.LoadMap(mapId);
                dico.Add(mapData.Id, GetConnectedMaps(mapData, StoredInMap));
            }
            st.Stop();
            ProcessAllMapsTimer = st.Elapsed;

            // To do : detect submaps
            // To do : find connections between submaps

            // Convert into 0 based internal index (todo : split sub maps)
            MapIdToInternal = new Dictionary <int, int>();
            int        i = 0;
            List <int> tmpInternaltoMapId = new List <int>();

            foreach (int mapId in dico.Keys) //
            {
                MapIdToInternal[mapId] = i++;
                tmpInternaltoMapId.Add(mapId);
            }
            InternalToMapId = tmpInternaltoMapId.ToArray();
            // Fill converted int[][] to feed the PathFinder
            List <int[]> mainList = new List <int[]>();
            List <int>   connectionList;
            List <int>   ConvertedConnectionList;
            Dictionary <int, List <int> > newDico = new Dictionary <int, List <int> >(dico.Count);

            foreach (var map in dico)
            {
                int mapID = map.Key;
                connectionList          = map.Value;
                ConvertedConnectionList = new List <int>();
                foreach (int mapId in connectionList)
                {
                    ConvertedConnectionList.Add(MapIdToInternal[mapId]);
                }
                newDico[mapID] = ConvertedConnectionList;
            }
            return(newDico);
        }
示例#4
0
 public Emulation(IWorldMapProvider mapProvider,
                  IWorldMapFiller mapFiller,
                  IGenerationBuilder generationBuilder,
                  EmulationConfig config)
 {
     StatusMonitor                     = new StatusMonitor();
     state                             = new EmulationState();
     state.Changed                    += state => StateChanged?.Invoke(state);
     this.mapProvider                  = mapProvider;
     this.mapFiller                    = mapFiller;
     this.generationBuilder            = generationBuilder;
     Config                            = config;
     iterationsCountSinceLastItemSpawn = new Dictionary <WorldObjectType, int>
     {
         { WorldObjectType.Food, 0 },
         { WorldObjectType.Poison, 0 },
     };
 }
示例#5
0
    private Dictionary<int, List<int>> GetWorldMapConnections(IWorldMapProvider mapDataManager, bool StoredInMap)
    {
      _mapDataManager = mapDataManager;
      Stopwatch st = new Stopwatch();
      st.Start();
      //MapDataManager mapDataManager = new MapDataManager(pathToMapsData, StoredInMap); // Gets only Headers, except if checking cell content is needed
      Dictionary<int, List<int>> dico = new Dictionary<int, List<int>>(mapDataManager.KnownMapIds.Count);
      foreach (int mapId in mapDataManager.KnownMapIds)
      {
        IMap mapData = mapDataManager.LoadMap(mapId);
        dico.Add(mapData.Id, GetConnectedMaps(mapData, StoredInMap));
      }
      st.Stop();
      ProcessAllMapsTimer = st.Elapsed;

      // To do : detect submaps
      // To do : find connections between submaps 

      // Convert into 0 based internal index (todo : split sub maps)
      MapIdToInternal = new Dictionary<int, int>();
      int i=0;
      List<int> tmpInternaltoMapId = new List<int>();
      foreach (int mapId in dico.Keys) // 
      {
          MapIdToInternal[mapId] = i++;
          tmpInternaltoMapId.Add(mapId);
      }
      InternalToMapId = tmpInternaltoMapId.ToArray();
      // Fill converted int[][] to feed the PathFinder
      List<int[]> mainList = new List<int[]>();
      List<int> connectionList; 
      List<int> ConvertedConnectionList;
      Dictionary<int, List<int>> newDico = new Dictionary<int, List<int>>(dico.Count);
      foreach (var map in dico)
      {
          int mapID = map.Key;
          connectionList = map.Value;
          ConvertedConnectionList = new List<int>();
          foreach (int mapId in connectionList)
              ConvertedConnectionList.Add(MapIdToInternal[mapId]);
          newDico[mapID] = ConvertedConnectionList;
      }
      return newDico;
    }