Пример #1
0
 public void testLoadMap()
 {
     if (System.IO.File.Exists(Application.dataPath + "/Maps/0.bin"))
     {
         TotalMap testmap = BinaryLoad <TotalMap>(Application.dataPath + "/Maps/map_test.bin");
         Debug.Log(testmap.gameMapList.Count);
     }
 }
Пример #2
0
    public void CompeleteTotalMap()
    {
        DirectoryInfo di = new DirectoryInfo(Application.dataPath + "/Maps");

        FileInfo[] fis = di.GetFiles();

        TotalMap totalMap = new TotalMap((fis.Length / 2).ToString(), MapName, gameMaps, MapLength, TotalMapRank);

        BinarySave <TotalMap>(totalMap, Application.dataPath + "/Maps/" + (fis.Length / 2).ToString() + ".bin");
    }
Пример #3
0
        //---------------------------------------//
        //-----         FUNÇÕES             -----//
        //---------------------------------------//

        /// <summary>
        /// Lê o array contido no mapa e ordena as posições dos tiles.
        /// </summary>
        public override void Read()
        {
            IsRead = false;

            TotalMap = Map.GetMap();
            Tiles.Clear();

            //dimensões do array
            int d0 = TotalMap.GetLength(0);
            int d1 = TotalMap.GetLength(1);

            for (int row = 0; row < d0; row++)
            {
                for (int col = 0; col < d1; col++)
                {
                    //O valor da posição no array
                    T index = TotalMap[row, col];

                    //Recebe o Tile da tabela
                    if (Map.Table.ContainsKey(index))
                    {
                        IsoTile tile = new IsoTile(Map.Table[index]);
                        //Atualiza todas as animações do tile
                        //tile.UpdateBounds();
                        //largura e altura para cálculo
                        //Usa as configuraçõs do tamanho do tile pela animação
                        //int w = tile.Animation.Bounds.Width;
                        //int h = tile.Animation.Bounds.Height;

                        //Usa as configurações de tamanho geral
                        int   w  = TileWidth;
                        int   h  = TileHeight;
                        float sx = StartPosition.X;
                        float sy = StartPosition.Y;

                        //O cálculo se dá na animação do topo
                        //antes o valor de row era positivo
                        tile.Actor.Transform.X = ((w / 2) * -row) + ((w / 2) * col) + sx;
                        tile.Actor.Transform.Y = ((h / 2) * col) - ((h / 2) * -row) + sy;

                        Tiles.Add(new Point(row, col), tile);
                    }
                }
            }

            IsRead = true;
        }
        private void ReadFinalMap()
        {
            IsRead = false;
            Tiles.Clear();

            //dimensões do array
            int d0 = TotalMap.GetLength(0);
            int d1 = TotalMap.GetLength(1);

            for (int row = 0; row < d0; row++)
            {
                for (int col = 0; col < d1; col++)
                {
                    //O valor da posição no array
                    T index = TotalMap[row, col];
                    //Recebe o Tile da tabela
                    Dictionary <T, IsoTile> table = point_sector[new Point(row, col)].Table;

                    if (table.ContainsKey(index))
                    {
                        IsoTile tile = new IsoTile(table[index]);

                        //largura e altura para cálculo
                        //int w = tile.Animation.Bounds.Width;
                        //int h = tile.Animation.Bounds.Height;
                        int   w  = TileWidth;
                        int   h  = TileHeight;
                        float sx = StartPosition.X;
                        float sy = StartPosition.Y;

                        //O cálculo se dá na animação do topo
                        //com o valor de row positivo o mapa fica invertido
                        tile.Actor.Transform.X = ((w / 2) * -row) + ((w / 2) * col) + sx;
                        tile.Actor.Transform.Y = ((h / 2) * col) - ((h / 2) * -row) + sy;
                        tile.UpdateBounds();

                        tile.MapPoint = new Point(row, col);

                        Tiles.Add(new Point(row, col), tile);
                    }
                }
            }

            IsRead = true;
        }