Exemple #1
0
        // #############################################################################################
        /// Function:<summary>
        ///             Reset the map
        ///          </summary>
        ///
        /// In:		<param name="_width"></param>
        ///			<param name="_height"></param>
        ///			<param name="_depth"></param>
        ///
        // #############################################################################################
        public void Reset(int _width, int _height, int _depth, int _groundlevel)
        {
            Width       = _width;
            Height      = _height;
            Depth       = _depth;
            GroundLevel = _groundlevel;

            BlockCRCLookup = new Dictionary <uint, int>();
            BlockInfo      = new List <block_info>();
            FreeList       = new Stack <int>();
            map            = new MapColumn[_width * _height];



            BlockInfo.Add(new block_info());            // block "0" is empty
            BlockInfo[0].Ref = 1;
            BlockInfo[0].UpdateCRC();
            BlockCRCLookup.Add(BlockInfo[0].CRC, 0);


            BlockInfo.Add(new block_info());            // block "1" is "almost" empty
            BlockInfo[1].Ref     = (_width * _height * GroundLevel) + 1;;
            BlockInfo[1].Flags1 |= 0x80000000;          // always set this - it's cleared on save
            BlockInfo[1].UpdateCRC();
            BlockCRCLookup.Add(BlockInfo[1].CRC, 1);

            block_info b = new block_info();            // block "2" is pavement;

            b.Lid = Pavement;
            b.Ref = (_width * _height) + 1;
            BlockInfo.Add(b);
            CheckDuplicate(2);



            for (int y = 0; y < _height; y++)
            {
                int index = y * Width;
                for (int x = 0; x < _width; x++)
                {
                    map[x + index] = new MapColumn();
                    for (int g = 0; g < GroundLevel; g++)
                    {
                        map[x + index].Add(1);              // Water level has nothing by default
                    }
                    map[x + index].Add(2);                  // Build pavement at ground level (one block up)
                }
            }
        }
Exemple #2
0
        // #############################################################################################
        /// Function:<summary>
        ///          	Reset the map
        ///          </summary>
        ///
        /// In:		<param name="_width"></param>
        ///			<param name="_height"></param>
        ///			<param name="_depth"></param>
        ///
        // #############################################################################################
        public void Reset(int _width, int _height, int _depth, int _groundlevel)
        {
            Width = _width;
            Height = _height;
            Depth = _depth;
            GroundLevel = _groundlevel;

            BlockCRCLookup = new Dictionary<uint, int>();
            BlockInfo = new List<block_info>();
            FreeList = new Stack<int>();
            map = new MapColumn[_width * _height];

            BlockInfo.Add(new block_info());            // block "0" is empty
            BlockInfo[0].Ref = 1;
            BlockInfo[0].UpdateCRC();
            BlockCRCLookup.Add(BlockInfo[0].CRC,0);

            BlockInfo.Add(new block_info());            // block "1" is "almost" empty
            BlockInfo[1].Ref = (_width * _height * GroundLevel) + 1; ;
            BlockInfo[1].Flags1|=0x80000000;            // always set this - it's cleared on save
            BlockInfo[1].UpdateCRC();
            BlockCRCLookup.Add(BlockInfo[1].CRC,1);

            block_info b = new block_info();            // block "2" is pavement;
            b.Lid = Pavement;
            b.Ref = (_width * _height)+1;
            BlockInfo.Add(b);
            CheckDuplicate(2);

            for (int y = 0; y < _height; y++)
            {
                int index = y*Width;
                for (int x = 0; x < _width; x++)
                {
                    map[x + index] = new MapColumn();
                    for(int g=0;g<GroundLevel;g++){
                        map[x + index].Add(1);              // Water level has nothing by default
                    }
                    map[x + index].Add(2);                  // Build pavement at ground level (one block up)
                }
            }
        }