Esempio n. 1
0
        private void createObsicals(ref SpriteObjects.Obstical[] obsicals, MapSurfacesAsset[] obsicalsSpec)
        {
            obsicals = new SpriteObjects.Obstical[obsicalsSpec.Length];

            for (int i = 0; i < obsicals.Length; i++)
            {
                Vector2 obsticalPos = new Vector2(
                                               Convert.ToInt32(obsicalsSpec[i].Position.X),
                                               Convert.ToInt32(obsicalsSpec[i].Position.Y)
                                           );

                Vector2 obsticalPosScale = new Vector2(
                                            (float)Convert.ToDecimal(obsicalsSpec[i].Scale.X),
                                            (float)Convert.ToDecimal(obsicalsSpec[i].Scale.Y)
                    );

                float rotation = (float)Convert.ToDecimal(obsicalsSpec[i].Rotation);

                obsicals[i] = new SpriteObjects.Obstical(mWorld, obsticalPos, obsticalPosScale, rotation);
            }
        }
        public void save(string filename)
        {
            Map newMap = new Map();

            // create map dimentions
            MapMapDimentions dimentions = new MapMapDimentions();
            dimentions.Height = 1;
            dimentions.Width = 1;
            newMap.MapDimentions = dimentions;

            // create surfaces
            MapSurfaces surfaces = new MapSurfaces();

            // create background
            MapSurfacesBackgoundPicture backgroundPic = new MapSurfacesBackgoundPicture();
            MapSurfacesBackgoundPictureAsset backgroundAsset = new MapSurfacesBackgoundPictureAsset();
            MapSurfacesBackgoundPictureAssetScale backScale = new MapSurfacesBackgoundPictureAssetScale();
            MapSurfacesBackgoundPictureAssetPosition backgroundPos = new MapSurfacesBackgoundPictureAssetPosition();

            backgroundAsset.name = "smudgystars";

            backScale.X = "1";
            backScale.Y = "1";

            backgroundPos.X = "0";
            backgroundPos.Y = "0";

            backgroundPic.Asset = backgroundAsset;
            surfaces.BackgoundPicture = backgroundPic;
            backgroundAsset.Scale = backScale;
            backgroundAsset.Position = backgroundPos;

            // create some walls
            MapSurfacesWall[] walls = new MapSurfacesWall[4];
            createWall(ref walls, 0, "left", editor.leftWallPosition, editor.leftWall);
            createWall(ref walls, 1, "right", editor.rightWallPosition, editor.rightWall);
            createWall(ref walls, 2, "bottom", editor.bottomWallPosition, editor.bottomWall);
            createWall(ref walls, 3, "top", editor.topWallPosition, editor.topWall);

            MapSurfacesAsset[] obsticals = new MapSurfacesAsset[0];

            surfaces.Obsticals = obsticals;

            surfaces.MapWalls = walls;
            newMap.Surfaces = surfaces;

            // create spawns

            MapSpawnPoint spawns = new MapSpawnPoint();
            MapSpawnPointPlayer1 p1Spawn = new MapSpawnPointPlayer1();

            p1Spawn.X = "0";
            p1Spawn.Y = "100";

            spawns.Player1 = p1Spawn;
            newMap.SpawnPoint = spawns;

            XmlSerializer serialiser = new XmlSerializer(typeof(Map));
            serialiser.Serialize(new StreamWriter(filename), newMap);
        }