Exemple #1
0
        public LoaderBaseManager()
        {
            Loaders = new LoaderBase[3][];
            for (var i = 0; i < 3; i++)
                Loaders[i] = new LoaderBase[3];

            for (var i = 0; i < 3; i = i + 1)
            {
                for (var j = 0; j < 3; j = j + 1)
                {
                    var lb = new LoaderBase();
                    Loaders[i][j] = lb;
                    Loaders[i][j].LoadSector(PlayScreen.SpawnX + (i - 1), PlayScreen.SpawnY + (j - 1));

                }
            }

            //CreateWorldTerrain.UpdateSpace();
        }
Exemple #2
0
        internal void LoadData(ref LoaderBase[][] cl)
        {
            _tileLoaders = cl;
            _terrainTileCollectionWidth = Convert.ToInt16(ScreenBuffer/64);
            _terrainTileCollectionHeight = _terrainTileCollectionWidth;
            _tileColls = new TileCollection[_terrainTileCollectionWidth,_terrainTileCollectionHeight];
            _terrainTextureOne = new RenderTarget2D(MainGame.GraphicD, ScreenBuffer, ScreenBuffer);
            _terrainTextureTwo = new RenderTarget2D(MainGame.GraphicD, ScreenBuffer, ScreenBuffer);

            _terrainPosition = Vector2.Zero;

            _graphicsDevice = MainGame.GraphicD;

            for (var i = 0; i < _terrainTileCollectionWidth; i ++)
            {
                for (var j = 0; j < _terrainTileCollectionHeight; j ++)
                {
                    var tc = new TileCollection(_tileRegions, i, j, _terrainTileCollectionWidth,
                                                _terrainTileCollectionHeight);
                    _tileColls[i, j] = tc;

                    if (i == 0 && j == 0)
                        _mostLeftUpSprite = tc;
                    else if (_terrainTileCollectionWidth - 1 == i && _terrainTileCollectionHeight - 1 == j)
                        _mostRightDownSprite = tc;

                    tc.SectorX = PlayScreen.SpawnX;
                    tc.SectorY = PlayScreen.SpawnY;
                    tc.MySectorSpotX = i;
                    tc.MySectorSpotY = j;
                    tc.SetPosition(i*Sprite2XWidth, j*Sprite2XWidth);
                    var ar = GetSurroundings(ref tc.MyLoaderBase, tc.SectorX, tc.SectorY, tc.MySectorSpotX,
                                             tc.MySectorSpotY);
                    tc.SetSurroundings(FindSurroundings(ar));
                }
            }
            InitialDraw();
            TileColls = _tileColls;
            _terrainLoaded = true;
        }
Exemple #3
0
        private int[] GetSurroundings(ref LoaderBase myLoaderBase, int sectX, int sectY, int sectSpotX, int sectSpotY)
        {
            myLoaderBase = GetSpriteTile(sectX, sectY);

            var holder = 0;
            const byte tileLength = PlayScreen.SectorTileSize;
            for (var i = -1; i < 2; i = i + 1)
            {
                for (var j = -1; j < 2; j = j + 1)
                {
                    var spotX = sectSpotX + j;
                    var spotY = sectSpotY + i;
                    int val;
                    if (spotY >= 0 && spotX >= 0 && spotY < tileLength && spotX < tileLength)
                        val = myLoaderBase.SectorData.TileData[spotX, spotY];
                    else
                    {
                        var offsetX = 0;
                        offsetX = spotX < 0 ? -1 : offsetX;
                        offsetX = spotX >= tileLength ? 1 : offsetX;
                        //
                        var offsetY = 0;
                        offsetY = spotY < 0 ? -1 : offsetY;
                        offsetY = spotY >= tileLength ? 1 : offsetY;
                        //
                        var tl2 = GetSpriteTile(sectX + offsetX, sectY + offsetY);
                        //
                        var currSpotX = spotX;
                        currSpotX = offsetX == -1 ? tileLength - 1 : currSpotX;
                        currSpotX = offsetX == 1 ? 0 : currSpotX;
                        //
                        var currSpotY = spotY;
                        currSpotY = offsetY == -1 ? tileLength - 1 : currSpotY;
                        currSpotY = offsetY == 1 ? 0 : currSpotY;
                        //
                        val = tl2.SectorData.TileData[currSpotX, currSpotY];
                    }
                    // System.out.println("val:" + val);
                    _currentSurroundings[holder++] = val;
                }
            }

            return _currentSurroundings;
        }
Exemple #4
0
 private void CreateLightForTile(Decoration s, LoaderBase ld)
 {
     if (!s.SetInfo(this, ld.SectorData.DecorData[s.MySectorSpotX, s.MySectorSpotY])) return;
     //_tileColls[s.MyVectorSpotX, s.MyVectorSpotY].StarterLight(ref _tileColls, _tileCollWidth, _tileCollHeight);
 }