Beispiel #1
0
        static public void Initialize(Texture2D tileTexture)
        {
            tileSheet = tileTexture;

            for (int x = 0; x < MapWidth; x++)
            {
                for (int y = 0; y < MapHeight; y++)
                {
                    for (int z = 0; z < MapLayers; z++)
                    {
                        mapCells[x, y] = new MapSquare(skyTile, 0, 0, "", true);
                    }
                }
            }
        }
Beispiel #2
0
 public static void ClearMap()
 {
     for (int x = 0; x < MapWidth; x++)
         for (int y = 0; y < MapHeight; y++)
             for (int z = 0; z < MapLayers; z++)
             {
                 mapCells[x, y] = new MapSquare(2, 0, 0, "", true);
             }
 }
Beispiel #3
0
 static public void SetMapSquareAtCell(
     int tileX,
     int tileY,
     MapSquare tile)
 {
     if ((tileX >= 0) && (tileX < MapWidth) &&
         (tileY >= 0) && (tileY < MapHeight))
     {
         mapCells[tileX, tileY] = tile;
     }
 }
Beispiel #4
0
 /*Initialisering*/
 public static void Initialize(Texture2D tileTexture)
 {
     tileSheet = tileTexture;
     //Sett alle lagene i hver "celle" standardbildet (skyTile).
     for (int x = 0; x < MapWidth; x++)
     {
         for (int y = 0; y < MapHeight; y++)
         {
             for (int z = 0; z < MapLayers; z++)
             {
                 mapCells[x, y] = new MapSquare(skyTile, 0, 0, "", true);
             }
         }
     }
 }
Beispiel #5
0
 public static void ClearMap()
 {
     mapCells = new MapSquare[MapWidth,MapHeight];
     for(int x = 0; x < MapWidth; x++)
     {
         for(int y = 0; y < MapHeight; y++)
         {
             for(int z = 0; z < MapLayers; z++)
             {
                 mapCells[x,y] = new MapSquare(floorTile, emptyTile, emptyTile, "");
             }
         }
     }
     Camera.WorldRectangle = new Rectangle(0, 0, TileMap.TileWidth * TileMap.MapWidth, TileMap.TileHeight * TileMap.MapHeight);
 }
        public void SaveMap(FileStream fileStream)
        {
            //#if WINDOWS
            //BinaryFormatter formatter = new BinaryFormatter();
            //formatter.Serialize(fileStream, mapCells);
            //fileStream.Close();
            //#endif
            int k = 0;
            MapSquare[] lala = new MapSquare[MapWidth * MapHeight];
            for (int i = 0; i < MapWidth; i++)
            {
                for (int j = 0; j < MapHeight; j++)
                {// Grab each value one at a time, and place it inside the SD array
                    lala[k] = mapCells[i, j];
                    k++;
                }
            }

            XmlSerializer serializer = new XmlSerializer(typeof(MapSquare[]));
            serializer.Serialize(fileStream, lala);
            fileStream.Close();
        }
        public static void LoadMap(FileStream fileStream)
        {
            try
            {
            //#if WINDOWS
            //                BinaryFormatter formatter = new BinaryFormatter();
            //                mapCells = (MapSquare[,])formatter.Deserialize(fileStream);
            //                fileStream.Close();
            //#elif XBOX

                XmlSerializer serializer = new XmlSerializer(typeof(MapSquare[]));
                MapSquare[] lala = new MapSquare[MapWidth * MapHeight];
                lala = (MapSquare[])serializer.Deserialize(fileStream);
                int k = 0;
                for (int i = 0; i < MapWidth; i++)
                {
                    for (int j = 0; j < MapHeight; j++)
                    {// Going backwards now
                        mapCells[i, j] = lala[k];
                        if (k % 20 == 0)
                            mapCells[i, j].ToggleRotating();
                        k++;
                    }
                }
                fileStream.Close();

            //#endif
            }
            catch
            {
                ClearMap();
            }
        }