Eager loading strategy loads not only visible tiles but also ones that are likely to be visible. It's based on LazyLoadingStrategy, and loads additional tiles according to users' actions.
Inheritance: ITileLoadingStrategy
Exemplo n.º 1
0
Arquivo: App.cs Projeto: hnjm/tilemap
    public void Initialize(AppConfig config)
    {
        if (map != null)
        {
            map.Dispose();
        }

        fileName      = config.MapFileName;
        userDragSpeed = config.UserDragSpeed;

        server = new TileServer(config.MapSize.x, config.MapSize.y, prefab.GetPrefabCount(), config.RefreshIntervalSeconds, networkLatency);

        ITileFactory factory;

        if (config.RefreshTiles)
        {
            factory = new TimedProxyTileFactory(server, config.RefreshIntervalSeconds);
        }
        else
        {
            factory = new ProxyTileFactory(server);
        }

        ITileLoadingStrategy tileLoadingStrategy;

        if (config.LoadPotentialTiles)
        {
            tileLoadingStrategy = new EagerLoadingStrategy();
        }
        else
        {
            tileLoadingStrategy = new LazyLoadingStrategy();
        }

        storage = new TileStorage(factory);

        Map simpleMap = new Map(storage.Load(fileName), factory, tileLoadingStrategy, prefab, config.MapSize.x, config.MapSize.y);

        if (config.LimitTilesCount)
        {
            map = new LimitedMap(simpleMap, config.MaxTilesCount);
        }
        else
        {
            map = simpleMap;
        }

        area = new VisibleArea(map);

        initialized = true;
    }
Exemplo n.º 2
0
    public void Initialize(AppConfig config)
    {
        if (map != null) {
            map.Dispose ();
        }

        fileName = config.MapFileName;
        userDragSpeed = config.UserDragSpeed;

        server = new TileServer (config.MapSize.x, config.MapSize.y, prefab.GetPrefabCount (), config.RefreshIntervalSeconds, networkLatency);

        ITileFactory factory;
        if (config.RefreshTiles) {
            factory = new TimedProxyTileFactory (server, config.RefreshIntervalSeconds);
        } else {
            factory = new ProxyTileFactory (server);
        }

        ITileLoadingStrategy tileLoadingStrategy;
        if (config.LoadPotentialTiles) {
            tileLoadingStrategy = new EagerLoadingStrategy ();
        } else {
            tileLoadingStrategy = new LazyLoadingStrategy ();
        }

        storage = new TileStorage (factory);

        Map simpleMap = new Map (storage.Load (fileName), factory, tileLoadingStrategy, prefab, config.MapSize.x, config.MapSize.y);

        if (config.LimitTilesCount) {
            map = new LimitedMap (simpleMap, config.MaxTilesCount);
        } else {
            map = simpleMap;
        }

        area = new VisibleArea (map);

        initialized = true;
    }