/// <summary> Sets up the Observer to watch the given grid. </summary>
        public void Initialize(WorldGrid worldGrid, Camera itemToTrack)
        {
            _itemToTrack = itemToTrack;

            _worldGrid                 = worldGrid;
            _theGridSlice              = new WorldGridSlice <ViewGridItemData>(_worldGrid, VisibleWidth, VisibleHeight);
            _theGridSlice.DataChanged += HandleChanged;
            _theGridSlice.Initialize(new GridCoordinate(Vector2.zero));
        }
Ejemplo n.º 2
0
        public void Start()
        {
            WorldGrid = new WorldGrid();

            _slice              = new WorldGridSlice <UnityWorldData>(WorldGrid, 20, 20);
            _slice.DataChanged += HandleDataChanged;

            _slice.Initialize(new GridCoordinate(Player.transform.position));
        }
        public VisibleTileGridDrawer(GraphicsDevice device,
                                     ResourceLoader resources,
                                     WorldGrid world,
                                     Camera2D camera2D)
        {
            _tileTextures = resources.MapEnumToResources <TileType, Texture2D>("images/tiles.");

            _worldView = new WorldGridSlice <int>(world,
                                                  device.Viewport.Width / Constants.PixelSize + 2,
                                                  device.Viewport.Height / Constants.PixelSize + 2);
            _worldView.Initialize(new GridCoordinate(0, 0));
            _camera = camera2D;

            _renderer = new TextureRenderer(_camera, new SpriteBatch(device))
            {
                Offset = new Vector2(0.5f, 0.5f) * Constants.PixelSize
            };
        }