Пример #1
0
            public readonly List <Tile>[][][] Tiles; // Elevation,Y,X,SubLayers

            public Block(Blockset parent, int id, EndianBinaryReader r)
            {
                Behavior = r.ReadEnum <BlocksetBlockBehavior>();
                Tiles    = new List <Tile> [Overworld.NumElevations][][];
                for (byte e = 0; e < Overworld.NumElevations; e++)
                {
                    var arrE = new List <Tile> [Overworld.Block_NumTilesY][];
                    for (int y = 0; y < Overworld.Block_NumTilesY; y++)
                    {
                        var arrY = new List <Tile> [Overworld.Block_NumTilesX];
                        for (int x = 0; x < Overworld.Block_NumTilesX; x++)
                        {
                            byte count     = r.ReadByte();
                            var  subLayers = new List <Tile>(count);
                            for (int i = 0; i < count; i++)
                            {
                                subLayers.Add(new Tile(r));
                            }
                            arrY[x] = subLayers;
                        }
                        arrE[y] = arrY;
                    }
                    Tiles[e] = arrE;
                }
                Parent = parent;
                Id     = id;
            }
Пример #2
0
            public Block(Blockset parent, int id)
            {
                Parent = parent;
                Id     = id;
                List <Tile>[] Create()
                {
                    var d = new List <Tile> [Overworld.NumElevations];

                    for (byte e = 0; e < Overworld.NumElevations; e++)
                    {
                        d[e] = new List <Tile>();
                    }
                    return(d);
                }

                Tiles = new List <Tile> [Overworld.Block_NumTilesY][][];
                for (int y = 0; y < Overworld.Block_NumTilesY; y++)
                {
                    var arrY = new List <Tile> [Overworld.Block_NumTilesX][];
                    for (int x = 0; x < Overworld.Block_NumTilesX; x++)
                    {
                        arrY[x] = Create();
                    }
                    Tiles[y] = arrY;
                }
            }
Пример #3
0
 public Block(int x, int y, EndianBinaryReader r)
 {
     X             = x;
     Y             = y;
     Elevations    = r.ReadByte();
     Passage       = r.ReadEnum <LayoutBlockPassage>();
     BlocksetBlock = Blockset.LoadOrGet(r.ReadInt32()).Blocks[r.ReadInt32()];
 }
Пример #4
0
        internal static void Clear(Block block)
        {
            for (int y = 0; y < Overworld.Block_NumTilesY; y++)
            {
                List <Block.Tile>[][] arrY = block.Tiles[y];
                for (int x = 0; x < Overworld.Block_NumTilesX; x++)
                {
                    List <Block.Tile>[] arrX = arrY[x];
                    for (byte e = 0; e < Overworld.NumElevations; e++)
                    {
                        arrX[e].Clear();
                    }
                }
            }
            Blockset blockset = block.Parent;

            blockset.OnChanged?.Invoke(blockset, block);
            blockset.DrawOne(block);
        }
Пример #5
0
 public Block(Blockset parent, int id)
 {
     Parent = parent;
     Id     = id;
     Tiles  = new List <Tile> [Overworld.NumElevations][][];
     for (byte e = 0; e < Overworld.NumElevations; e++)
     {
         var arrE = new List <Tile> [Overworld.Block_NumTilesY][];
         for (int y = 0; y < Overworld.Block_NumTilesY; y++)
         {
             var arrY = new List <Tile> [Overworld.Block_NumTilesX];
             for (int x = 0; x < Overworld.Block_NumTilesX; x++)
             {
                 arrY[x] = new List <Tile>();
             }
             arrE[y] = arrY;
         }
         Tiles[e] = arrE;
     }
 }
Пример #6
0
        internal static void Remove(Block block)
        {
            Blockset blockset = block.Parent;

            blockset.Blocks.Remove(block);
            block.Parent = null;
            for (int i = block.Id; i < blockset.Blocks.Count; i++)
            {
                blockset.Blocks[i].Id--;
            }
            blockset.OnRemoved?.Invoke(blockset, block);
            if (blockset.UpdateBitmapSize())
            {
                blockset.DrawAll();
            }
            else
            {
                blockset.DrawFrom(block.Id);
            }
        }
Пример #7
0
        private static Blockset LoadOrGet(string name, int id)
        {
            Blockset b;

            if (!_loadedBlocksets.ContainsKey(id))
            {
                b = new Blockset(name, id);
                _loadedBlocksets.Add(id, new WeakReference <Blockset>(b));
                return(b);
            }
            WeakReference <Blockset> w = _loadedBlocksets[id];

            if (w.TryGetTarget(out b))
            {
                return(b);
            }
            b = new Blockset(name, id);
            w.SetTarget(b);
            return(b);
        }