PC XNA ゲームを xbox に移植しようとしており、ハイスコア用の既存の PC ファイル管理と一緒に xna easystorage を実装しようとしました。基本的にhttp://xnaessentials.com/tutorials/highscores.aspx/tutorials/highscores.aspxとhttp://easystorage.codeplex.com/を組み合わせようとしています
「return (data);」のエラーとして LoadHighScores() に関する 1 つの特定のエラーが発生しています。- 割り当てられていないローカル変数 'data' の使用。
これは、easystorage/xbox の非同期設計によるものだと思います!? 解決方法がわからない - 以下はコードサンプルです。
元の PC コード: (PC 上で動作)
public static HighScoreData LoadHighScores(string filename) { HighScoreData データ; // セーブゲームのパスを取得
string fullpath = "Content/highscores.lst";
// Open the file
FileStream stream = File.Open(fullpath, FileMode.Open,FileAccess.Read);
try
{ // Read the data from the file
XmlSerializer serializer = new XmlSerializer(typeof(HighScoreData));
data = (HighScoreData)serializer.Deserialize(stream);
}
finally
{ // Close the file
stream.Close();
}
return (data);
}
XBOX PORT: (エラーあり)
public static HighScoreData LoadHighScores(文字列コンテナー、文字列ファイル名) { HighScoreData データ;
if (Global.SaveDevice.FileExists(container, filename))
{
Global.SaveDevice.Load(container, filename, stream =>
{
File.Open(Global.fileName_options, FileMode.Open,//FileMode.OpenOrCreate,
FileAccess.Read);
try
{
// Read the data from the file
XmlSerializer serializer = new XmlSerializer(typeof(HighScoreData));
data = (HighScoreData)serializer.Deserialize(stream);
}
finally
{
// Close the file
stream.Close();
}
});
}
return (data);
}
何か案は?