Exemplo n.º 1
0
        public TileMap(List <Layer> layers, List <BGOVERLAY_DEF> overlayList, List <BGANIM_DEF> animList, uint factor)
        {
            Int32 minX, minY, maxX, maxY;

            TileMap.GetBounds(overlayList, 0, out minX, out minY, out maxX, out maxY);
            this.SizeX   = (maxX - minX) / 16;
            this.SizeY   = (maxY - minY) / 16;
            _cameraIndex = overlayList[0].camNdx;
            _overlays    = new Dictionary <int, Overlay>();
            _animList    = animList;

            bool[] animationArray = new bool[overlayList.Count];
            for (var m = 0; m < animList.Count; m++)
            {
                BGANIM_DEF animation = animList[m];
                for (var n = 0; n < animation.frameList.Count; n++)
                {
                    int index = animation.frameList[n].target;
                    animationArray[index] = true;
                }
            }
            for (int i = 0; i < overlayList.Count; i++)
            {
                BGOVERLAY_DEF info          = overlayList[i];
                Layer         layer         = layers[i];
                bool          animationFlag = animationArray[i];
                Overlay       overlay       = new Overlay(CopyBytesHelper.GetImageData(layer, info, factor), info, i, this.SizeX, this.SizeY, minX, minY, maxX, maxY, animationFlag);
                _overlays[i] = overlay;
            }

            TDMap = new TileDepthMap(_overlays, this.SizeX, this.SizeY);
        }
Exemplo n.º 2
0
        public void FillBackgroundOverlays(TileMap tilemap)
        {
            TileDepthMap tileDepthMap = tilemap.TDMap;

            for (var i = 0; i < tilemap.SizeY; i++)
            {
                for (var j = 0; j < tilemap.SizeX; j++)
                {
                    List <TileDepthInfo> lst = tileDepthMap.TileMap[j, i];
                    if (lst == null || lst.Count < 2)
                    {
                        continue;
                    }
                    int     overlayNum    = lst[0].orderNumber;
                    Overlay targetOverlay = tilemap.GetOverlay(overlayNum);
                    Tile    targetTile    = targetOverlay.GetTile(j, i);
                    for (var k = 1; k < lst.Count; k++)
                    {
                        var     toX           = (int)(targetTile.info.offX * _factor);
                        var     toY           = (int)(targetOverlay.info.h * this._factor - (targetTile.info.offY * this._factor + this._tileHeight));
                        Overlay sourceOverlay = tilemap.GetOverlay(lst[k].orderNumber);
                        Tile    sourceTile    = sourceOverlay.GetTile(j, i);
                        this.CopyTile(targetOverlay.imageData, targetOverlay.info.w * (int)_factor, toX, toY, sourceTile, sourceOverlay, true);
                    }
                }
            }
        }
Exemplo n.º 3
0
        public TileMap(int fieldMapNumber, List <Layer> layers, List <BGOVERLAY_DEF> overlayList, List <BGANIM_DEF> animList, List <BGLIGHT_DEF> lightList, int cameraIndex, uint factor)
        {
            Int32 minX, minY, maxX, maxY;

            TileMap.GetBounds(overlayList, cameraIndex, out minX, out minY, out maxX, out maxY);
            this.MinX       = minX;
            this.MinY       = minY;
            this.SizeX      = (maxX - minX) / 16 + 1;
            this.SizeY      = (maxY - minY) / 16 + 1;
            _fieldMapNumber = fieldMapNumber;
            _cameraIndex    = cameraIndex;
            _overlays       = new Dictionary <int, Overlay>();
            _animList       = animList;
            _lightList      = lightList;

            bool[] animationArray = new bool[overlayList.Count];
            for (var m = 0; m < animList.Count; m++)
            {
                BGANIM_DEF animation = animList[m];
                for (var n = 0; n < animation.frameList.Count; n++)
                {
                    int index = animation.frameList[n].target;
                    animationArray[index] = true;
                }
            }
            for (var m = 0; m < lightList.Count; m++)
            {
                BGLIGHT_DEF lightDef = lightList[m];
            }
            for (int i = 0; i < overlayList.Count; i++)
            {
                BGOVERLAY_DEF info = overlayList[i];
                if (info.camNdx != _cameraIndex)
                {
                    continue;
                }
                Layer   layer         = layers[i];
                bool    animationFlag = animationArray[i];
                bool    isLight       = false;
                Overlay overlay       = new Overlay(CopyBytesHelper.GetImageData(layer, info, factor), info, i, this.SizeX, this.SizeY, minX, minY, maxX, maxY, animationFlag);
                _overlays[i] = overlay;
            }

            TDMap = new TileDepthMap(_overlays, this.SizeX, this.SizeY);
        }