Hi,
I have a little problem.
I have made a 'game editor' in wich i can make maps for my 'game'. I can save the maps in my 'game editor' so I can load them in my 'game' (other project file).
My Classes look like this:
Now the problem is, that my 'game' will not read the maps from the 'game editor'. but the 'game editor' can load saved maps what I made earlier with it.
This means its possible to Save & Load maps in my 'game editor', but i can't load the maps in my 'game'. Can someone help me so I can use my maps that I make in my''game editor' are also useable in my 'game'?
thanks
I have a little problem.
I have made a 'game editor' in wich i can make maps for my 'game'. I can save the maps in my 'game editor' so I can load them in my 'game' (other project file).
My Classes look like this:
Code:
Imports System.IO
Imports System.Xml.Serialization
Public Class MapSaver
Public Shared Sub SaveMap(ByVal Map As Map, ByVal fileName As String)
Dim ser As New XmlSerializer(GetType(Map))
Dim fs As New FileStream(fileName, FileMode.Create)
ser.Serialize(fs, Map)
fs.Close()
fs.Dispose()
End Sub
End Class
Public Class Map
Public Tile(MAX_X * MAX_Y) As TileRec
Public MAX_X As Integer
Public MAX_Y As Integer
Public Npc(50) As MapNpcRec
Public Item(50) As MapItemRec
Public Name As String
Public Moral As Integer
Public SwitchOver(3) As Integer
Public Structure MapItemRec
Public X As Integer
Public Y As Integer
Public ItemID As Integer
Public ItemAmmount As Integer
End Structure
Public Structure MapNpcRec
Public SpawnX As Integer
Public SpawnY As Integer
Public X As Integer
Public Y As Integer
Public NpcID As Integer
Public ItemAmmount As Integer
End Structure
Public Structure LayerRec
Public Ground As TileDataRec
Public Mask As TileDataRec
Public Mask2 As TileDataRec
Public Fringe As TileDataRec
Public Fringe2 As TileDataRec
End Structure
Public Structure TileRec
Public Layer As LayerRec
Public Attribute As AttributeRec
End Structure
Public Structure TileDataRec
Public imgX As Integer
Public imgY As Integer
Public Tileset As Integer
Public Draw As Boolean
End Structure
Public Structure AttributeRec
Public Attribute As Integer
Public Value As Integer
Public Value2 As Integer
End Structure
End Class
Public Class MapLoader
Public Shared Function LoadMap(ByVal fileName As String) As Map
Dim ser As New XmlSerializer(GetType(Map))
Dim fs As New FileStream(fileName, FileMode.Open)
Dim ret As Map
ret = DirectCast(ser.Deserialize(fs), Map)
fs.Close()
fs.Dispose()
Return ret
End Function
End Class
This means its possible to Save & Load maps in my 'game editor', but i can't load the maps in my 'game'. Can someone help me so I can use my maps that I make in my''game editor' are also useable in my 'game'?
thanks