Exemplo n.º 1
0
        public VergeTileGround(VergeTileData data, Rectangle screenViewRect, Rectanglef mapSize)
        {
            gridWidthSum  = data.gridWidth;
            gridHeightSum = data.gridHeight;

            this.screenViewRect = screenViewRect;
            this.mapSize        = mapSize;

            float gridScaleInWidth  = mapSize.Width / (float)gridWidthSum;
            float gridScaleInHeight = mapSize.Height / (float)gridHeightSum;

            gridScale = Math.Max(gridScaleInWidth, gridScaleInHeight);

            vertexTexIndexs = new int[data.vertexTexIndexs.Length];
            data.vertexTexIndexs.CopyTo(vertexTexIndexs, 0);

            gridTexIndexs = new int[data.gridTexIndexs.Length];
            data.gridTexIndexs.CopyTo(gridTexIndexs, 0);

            InitialTexList(data);

            InitialGridTexData();

            CreateSpriteBatches();

            sourceWidth = gridTexData[0][0].sourceRect.Width;

            BaseGame.Device.DeviceReset += new EventHandler(Device_DeviceReset);
        }
Exemplo n.º 2
0
        public VergeTileGround ( VergeTileData data, Rectangle screenViewRect, Rectanglef mapSize )
        {
            gridWidthSum = data.gridWidth;
            gridHeightSum = data.gridHeight;

            this.screenViewRect = screenViewRect;
            this.mapSize = mapSize;

            float gridScaleInWidth = mapSize.Width / (float)gridWidthSum;
            float gridScaleInHeight = mapSize.Height / (float)gridHeightSum;

            gridScale = Math.Max( gridScaleInWidth, gridScaleInHeight );

            vertexTexIndexs = new int[data.vertexTexIndexs.Length];
            data.vertexTexIndexs.CopyTo( vertexTexIndexs, 0 );

            gridTexIndexs = new int[data.gridTexIndexs.Length];
            data.gridTexIndexs.CopyTo( gridTexIndexs, 0 );

            InitialTexList( data );

            InitialGridTexData();

            CreateSpriteBatches();

            sourceWidth = gridTexData[0][0].sourceRect.Width;

            BaseGame.Device.DeviceReset += new EventHandler( Device_DeviceReset );
        }
Exemplo n.º 3
0
 private void InitialTexList(VergeTileData data)
 {
     TexList = new Texture2D[data.texPaths.Length];
     for (int i = 0; i < data.texPaths.Length; i++)
     {
         TexList[i] = Texture2D.FromFile(BaseGame.Device, data.texPaths[i]);
     }
 }
Exemplo n.º 4
0
        public static void Save ( Stream stream, VergeTileData data )
        {
            if (serializer == null)
                serializer = new XmlSerializer( typeof( VergeTileData ) );

            try
            {
                serializer.Serialize( stream, data );
            }
            catch (Exception)
            {
                Log.Write( "Save VergeTileData error!" );
            }
            finally
            {
                stream.Close();
            }
        }
Exemplo n.º 5
0
        public static void Save(Stream stream, VergeTileData data)
        {
            if (serializer == null)
            {
                serializer = new XmlSerializer(typeof(VergeTileData));
            }

            try
            {
                serializer.Serialize(stream, data);
            }
            catch (Exception)
            {
                Log.Write("Save VergeTileData error!");
            }
            finally
            {
                stream.Close();
            }
        }
Exemplo n.º 6
0
        public static VergeTileData Load(Stream stream)
        {
            if (serializer == null)
            {
                serializer = new XmlSerializer(typeof(VergeTileData));
            }

            VergeTileData result = null;

            try
            {
                result = (VergeTileData)serializer.Deserialize(stream);
            }
            catch (Exception)
            {
                Log.Write("Load VergeTileData error!");
            }
            finally
            {
                stream.Close();
            }
            return(result);
        }
Exemplo n.º 7
0
 private void InitialBackGround()
 {
     VergeTileData data = new VergeTileData();
     data.gridWidth = 50;
     data.gridHeight = 50;
     data.SetRondomVertexIndex( 50, 50, 4 );
     data.SetRondomGridIndex( 50, 50 );
     data.texPaths = new string[]
     {
         Path.Combine(Directories.ContentDirectory,"BackGround\\Lords_Dirt.tga"),
         Path.Combine(Directories.ContentDirectory,"BackGround\\Lords_DirtRough.tga"),
         Path.Combine(Directories.ContentDirectory,"BackGround\\Lords_DirtGrass.tga"),
         Path.Combine(Directories.ContentDirectory,"BackGround\\Lords_GrassDark.tga"),
     };
     backGround = new VergeTileGround( data, scrnRect, mapSize );
 }
Exemplo n.º 8
0
        private void InintialBackGround()
        {
            VergeTileData data2 = new VergeTileData();
            data2.gridWidth = 20;
            data2.gridHeight = 15;
            //data2.vertexTexIndexs = new int[]
            //{
            //    0,0,0,1,1,1,1,2,2,2,3,
            //    0,0,1,2,1,1,1,2,2,3,3,
            //    0,1,3,3,3,3,1,2,2,3,3,
            //    0,1,3,3,3,1,2,2,3,3,3,
            //    0,1,1,2,3,1,2,2,3,3,3,
            //    1,1,1,2,2,2,2,2,2,3,2,
            //    1,1,1,1,2,2,2,3,3,2,2,
            //    1,1,2,2,2,1,2,2,3,3,2,
            //    1,1,1,2,2,2,2,3,3,2,2,
            //    1,1,2,1,2,3,2,3,3,2,2,
            //    1,1,2,2,2,2,2,3,2,2,2,

            //};
            data2.SetRondomVertexIndex( 20, 15, 4 );
            data2.SetRondomGridIndex( 20, 15 );
            data2.texPaths = new string[]
            {
                Path.Combine(Directories.ContentDirectory,"BackGround\\Lords_Dirt.tga"),
                Path.Combine(Directories.ContentDirectory,"BackGround\\Lords_DirtRough.tga"),
                Path.Combine(Directories.ContentDirectory,"BackGround\\Lords_DirtGrass.tga"),
                Path.Combine(Directories.ContentDirectory,"BackGround\\Lords_GrassDark.tga"),

                //"Cave_Dirt.tga",
                //"Cave_LavaCracks.tga",
                //"Cave_Brick.tga",
                //"Cave_RedStones.tga",
                //"Cave_SquareTiles.tga",
                //"Cave_Lava.tga",
                //"Cave_GreyStones.tga",

                //"Lordw_Dirt.tga",
                //"Lordw_DirtRough.tga",
                //"Lordw_Grass.tga",
                //"Lordw_SnowGrass.tga",
                //"Lordw_Rock.tga",
                //"Lordw_Snow.tga",
                
                //"North_dirt.tga",
                //"North_dirtdark.tga",
                //"North_Grass.tga",
                //"North_ice.tga",
                //"North_rock.tga",
                //"North_Snow.tga",
                //"North_SnowRock.tga",

                //"Village_Dirt.tga",
                //"Village_DirtRough.tga",
                //"Village_GrassShort.tga",
                //"Village_Crops.tga",

            };

            vergeGround = new VergeTileGround( data2, scrnViewRect, mapSize );
        }
Exemplo n.º 9
0
 private void InitialTexList ( VergeTileData data )
 {
     TexList = new Texture2D[data.texPaths.Length];
     for (int i = 0; i < data.texPaths.Length; i++)
     {
         TexList[i] = Texture2D.FromFile( BaseGame.Device, data.texPaths[i] );
     }
 }