Permalink
Browse files

Working on saving the map. Before implementing IXmlSerializable

  • Loading branch information...
1 parent ec3249f commit 35cd037ae052dbb727e055db0aa818592e220912 @mkniffen committed Jan 1, 2012
Showing with 38 additions and 6 deletions.
  1. +12 −6 SlashIt/Game.cs
  2. +13 −0 SlashIt/Location.cs
  3. +9 −0 SlashIt/Map.cs
  4. +4 −0 SlashIt/SlashIt.csproj
View
@@ -2,6 +2,8 @@
using System.Collections.Generic;
using System.Linq;
using System.Text;
+using System.Xml.Serialization;
+using System.IO;
namespace SlashIt
{
@@ -28,12 +30,22 @@ public void InitConsole()
character.SetPosition(22, 2); //TODO Const
Map = new Map();
+ Serialize();
this.WriteConsole();
Status.Message = "Height: " + Console.WindowHeight + " Width: " + Console.WindowWidth;
}
+ public void Serialize()
+ {
+
+ XmlSerializer serializer = new XmlSerializer(typeof(Map));
+ TextWriter tw = new StreamWriter(@".\map.ser");
+ serializer.Serialize(tw, this.Map);
+ tw.Close();
+ }
+
//TODO eventually optimize how and when things are drawn. don't necessarily need to redraw all the time.
//TODO maybe have use a second array that tracks what should be drawn on the grid.
@@ -176,10 +188,4 @@ public void DoOpenClose()
}
}
-
- public class Location
- {
- public int Top { get; set; }
- public int Left { get; set; }
- }
}
View
@@ -0,0 +1,13 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+
+namespace SlashIt
+{
+ public class Location
+ {
+ public int Top { get; set; }
+ public int Left { get; set; }
+ }
+}
View
@@ -2,6 +2,8 @@
using System.Collections.Generic;
using System.Linq;
using System.Text;
+using System.Xml.Serialization;
+using System.IO;
namespace SlashIt
{
@@ -41,5 +43,12 @@ public int GetUpperBound(int dimension)
{ 1,1,1,1,1,1,1,1,1,1 },
};
+
+ public static void Load()
+ {
+ throw new NotImplementedException();
+ }
+
+
}
}
View
@@ -45,6 +45,7 @@
<ItemGroup>
<Compile Include="Character.cs" />
<Compile Include="Game.cs" />
+ <Compile Include="Location.cs" />
<Compile Include="Map.cs" />
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
@@ -53,6 +54,9 @@
<ItemGroup>
<Content Include="TODO.txt" />
</ItemGroup>
+ <ItemGroup>
+ <None Include="game.map" />
+ </ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.

0 comments on commit 35cd037

Please sign in to comment.