Ejemplo n.º 1
0
        private StaticTileBrush(LibraryX.StaticTileBrushX proxy, TilePoolManager manager)
            : base(proxy.Uid, proxy.Name, proxy.TileWidth, proxy.TileHeight)
        {
            _tiles = new Dictionary<TileCoord, TileStack>();

            if (proxy.Tiles != null) {
                foreach (var stack in proxy.Tiles) {
                    string[] coord = stack.At.Split(',');
                    string[] tileIds = stack.Items.Split(',');

                    int x = (coord.Length > 0) ? Convert.ToInt32(coord[0].Trim()) : 0;
                    int y = (coord.Length > 1) ? Convert.ToInt32(coord[1].Trim()) : 0;

                    foreach (string tileId in tileIds) {
                        Guid id = new Guid(tileId.Trim());

                        TilePool pool = manager.PoolFromItemKey(id);
                        if (pool == null)
                            continue;

                        AddTile(new TileCoord(x, y), pool.GetTile(id));
                    }
                }
            }

            Normalize();
        }
Ejemplo n.º 2
0
        public ImportTilePool()
        {
            InitializeComponent();

            _localTexturePool = new TexturePool();
            _localManager     = new TilePoolManager(_localTexturePool);

            _buttonOK.Enabled = false;

            _layerControl                         = new LayerGraphicsControl();
            _layerControl.Dock                    = DockStyle.Fill;
            _layerControl.WidthSynced             = true;
            _layerControl.CanvasAlignment         = CanvasAlignment.UpperLeft;
            _layerControl.TextureCache.SourcePool = _localManager.TexturePool;

            _rootLayer = new GroupLayerPresenter();
            _layerControl.RootLayer = new GroupLayer(_rootLayer);

            _previewPanel.Controls.Add(_layerControl);

            _message.Text = "";

            _buttonTransColor.Click   += ButtonTransColorClickHandler;
            _checkboxTransColor.Click += CheckboxTransColorClickHandler;
            _layerControl.MouseDown   += PreviewControlClickHandler;
        }
Ejemplo n.º 3
0
        public ImportTilePool(Project project)
        {
            InitializeComponent();

            _project = project;

            _localTexturePool = new TexturePool();
            _localManager = new TilePoolManager(_localTexturePool);

            _buttonOK.Enabled = false;

            _layerControl = new LayerGraphicsControl();
            _layerControl.Dock = DockStyle.Fill;
            _layerControl.WidthSynced = true;
            _layerControl.CanvasAlignment = CanvasAlignment.UpperLeft;
            _layerControl.TextureCache.SourcePool = _localManager.TexturePool;

            _rootLayer = new GroupLayerPresenter();
            _layerControl.RootLayer = new GroupLayer(_rootLayer);

            _previewPanel.Controls.Add(_layerControl);

            _message.Text = "";

            _buttonTransColor.Click += ButtonTransColorClickHandler;
            _checkboxTransColor.Click += CheckboxTransColorClickHandler;
            _layerControl.MouseDown += PreviewControlClickHandler;
        }
Ejemplo n.º 4
0
        public static DynamicTileBrush FromXProxy(LibraryX.DynamicTileBrushX proxy, TilePoolManager manager, DynamicTileBrushClassRegistry registry)
        {
            if (proxy == null)
                return null;

            DynamicTileBrush brush = new DynamicTileBrush(proxy, manager, registry);
            if (brush._brushClass == null)
                return null;

            return brush;
        }
Ejemplo n.º 5
0
    /// <summary>
    /// Prints the initial rows out
    /// </summary>
    void Start()
    {
        deadRows = 0;
        gameObject.AddComponent <Pingable>().OnPing(this);
        screwSpawner = gameObject.AddComponent <RandPositionSpawner>();

        poolManager = GetComponent <TilePoolManager>();
        Vector3 bottomLeft = GetCameraBottomLeft();

        nextBottomLeft = bottomLeft;

        for (int i = 0; i < startingRows; i++)
        {
            PrintNext();
        }
    }
Ejemplo n.º 6
0
        private DynamicTileBrush(LibraryX.DynamicTileBrushX proxy, TilePoolManager manager, DynamicTileBrushClassRegistry registry)
            : base(proxy.Uid, proxy.Name, proxy.TileWidth, proxy.TileHeight)
        {
            _brushClass = registry.Lookup(proxy.Type);
            if (_brushClass == null)
                return;

            _tiles = _brushClass.CreateTileProxyList();

            foreach (var entry in proxy.Entries) {
                TilePool pool = manager.PoolFromItemKey(entry.TileId);
                if (pool == null)
                    continue;

                SetTile(entry.Slot, pool.GetTile(entry.TileId));
            }
        }
Ejemplo n.º 7
0
        public static StaticTileBrush FromXProxy(LibraryX.StaticTileBrushX proxy, TilePoolManager manager)
        {
            if (proxy == null)
                return null;

            return new StaticTileBrush(proxy, manager);
        }
Ejemplo n.º 8
0
        public void Dispose()
        {
            if (_poolTextureMap != null) {
                foreach (Texture2D tex in _poolTextureMap.Values)
                    tex.Dispose();
            }

            if (_manager != null) {
                _manager.Pools.ResourceAdded -= TilePoolAdded;
                _manager.Pools.ResourceModified -= TilePoolModified;
                _manager.Pools.ResourceRemapped -= TilePoolRemapped;
                _manager.Pools.ResourceRemoved -= TilePoolRemoved;
            }

            _poolTextureMap = null;
            _manager = null;
        }
Ejemplo n.º 9
0
        public TilePoolTextureService(TilePoolManager manager, IGraphicsDeviceService deviceService)
        {
            _manager = manager;
            _deviceService = deviceService;

            _manager.Pools.ResourceAdded += TilePoolAdded;
            _manager.Pools.ResourceModified += TilePoolModified;
            _manager.Pools.ResourceRemapped += TilePoolRemapped;
            _manager.Pools.ResourceRemoved += TilePoolRemoved;

            Initialize();
        }