Unable to find assembly 'BlockableLevelEditor, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'.
Which comes up when it runs this line with a file matching the fileName:
SaveGameData data = (SaveGameData)formatter.Deserialize(stream);
Now at the moment I start the program off by loading the gameplayscreen with a level no. and I load the data from the saved file before the Load Content occurs otherwise I will get an error, at the moment I've had to link to the LoadLevel() method before it starts to load all the other game content:
/// <summary>
/// Constructor.
/// </summary>
public GameplayScreen(int levelNo)
{
TransitionOnTime = TimeSpan.FromSeconds(1.5);
TransitionOffTime = TimeSpan.FromSeconds(0.5);
blockableGame = new BlockableGame();
gameLevel = new Level();
currentLevelNo = levelNo;
stateobj = (Object)"GetDevice for Player One";
StorageDevice.BeginShowSelector(PlayerIndex.One, this.GetDevice, stateobj);
result = StorageDevice.BeginShowSelector(
PlayerIndex.One, null, null);
StorageDevice device = StorageDevice.EndShowSelector(result);
if (device != null && device.IsConnected)
{
LoadLevel(device, currentLevelNo);
}
HandleGame();
}
/// <summary>
/// Load graphics content for the game.
/// </summary>
public override void LoadContent()
{
if (content == null)
content = new ContentManager(ScreenManager.Game.Services, "Content");
gameFont = content.Load<SpriteFont>("gamefont");
gameLevel.LoadContent(content);
// A real game would probably have more content than this sample, so
// it would take longer to load. We simulate that by delaying for a
// while, giving you a chance to admire the beautiful loading screen.
Thread.Sleep(1000);
// once the load has finished, we use ResetElapsedTime to tell the game's
// timing mechanism that we have just finished a very long frame, and that
// it should not try to catch up.
ScreenManager.Game.ResetElapsedTime();
}
void GetDevice(IAsyncResult result)
{
device = StorageDevice.EndShowSelector(result);
}
public void LoadLevel(StorageDevice device, int levelNo)
{
string fileName;
fileName = string.Format("level{0}.sav", levelNo);
// Open a storage container.
IAsyncResult result =
device.BeginOpenContainer("BlockableFiles", null, null);
// Wait for the WaitHandle to become signaled.
result.AsyncWaitHandle.WaitOne();
StorageContainer container = device.EndOpenContainer(result);
// Close the wait handle.
result.AsyncWaitHandle.Close();
// Check to see whether the save exists.
if (!container.FileExists(fileName))
{
// If not, dispose of the container and return.
container.Dispose();
return;
}
// Open the file.
Stream stream = container.OpenFile(fileName, FileMode.Open);
// Read the data from the file.
BinaryFormatter formatter = new BinaryFormatter();
SaveGameData data = (SaveGameData)formatter.Deserialize(stream);
// Close the file.
stream.Close();
// Dispose the container.
container.Dispose();
for (int i = 0; i < gameLevel.DataHeight; i++)
{
for (int j = 0; j < gameLevel.DataWidth; j++)
{
gameLevel.Grid[i, j] = new Tile(data.gameGrid[i, j], i, j);
}
}
}
This post has been edited by ShadowsEdge19: 28 March 2011 - 06:37 AM

New Topic/Question
Reply


MultiQuote





|