Beispiel #1
0
 public XmlWrite()
 {
     // initialise levelFolder
     StaticVariables.execFolder = AppDomain.CurrentDomain.BaseDirectory;
     StaticVariables.levelFolder = StaticVariables.execFolder;
     // create world
     this.w = new World(10, 10);
     // fill world
     this.w.FillWorld(TERRAIN.grass_normal, new Size(10, 10));
     // initialize player
     this.w.InitPlayer(new PointF(5, 5));
     this.p = w.getPlayer();
     LevelWriter.saveWorld(this.w, this.file);
     beforelist = new TerrainTile[w.getTerrain().Count];
     before = new Entity[w.getEntities().Count];
     // save beforlist
     w.getTerrain().CopyTo(beforelist);
     w.getEntities().CopyTo(before);
     world = new World(10, 10);
     world.loadLevel(this.file);
     afterlist = new TerrainTile[world.getTerrain().Count];
     after = new Entity[world.getEntities().Count];
     // save afterlist
     world.getTerrain().CopyTo(afterlist);
     world.getEntities().CopyTo(after);
 }
Beispiel #2
0
        //Stub
        public TerrainTile[] getTilesView()
        {
            if (StaticVariables.viewWidth > width)
                StaticVariables.viewWidth = width;
            if (StaticVariables.viewHeight > height)
                StaticVariables.viewHeight = height;

            TerrainTile[] returnTiles = new TerrainTile[StaticVariables.viewWidth * StaticVariables.viewHeight];
            //Get viewport
            Rectangle view = getView ();

            int index = 0;
            for (int i = view.Left; i < view.Right; i++) {
                for (int j = view.Top; j < view.Bottom; j++) {
                    returnTiles [index++] = terrainTiles[i * height + j];
                }
            }
            return returnTiles;
        }