本文整理匯總了C#中TEditXNA.Terraria.World.ResetTime方法的典型用法代碼示例。如果您正苦於以下問題:C# World.ResetTime方法的具體用法?C# World.ResetTime怎麽用?C# World.ResetTime使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類TEditXNA.Terraria.World
的用法示例。
在下文中一共展示了World.ResetTime方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: Save
public static void Save(World world, string filename, bool resetTime = false)
{
try
{
OnProgressChanged(world, new ProgressChangedEventArgs(0, "Validating World..."));
world.Validate();
}
catch (ArgumentOutOfRangeException err)
{
string msg = string.Format("There is a problem in your world.\r\n" +
"{0}\r\nThis world will not open in Terraria\r\n" +
"Would you like to save anyways??\r\n"
, err.ParamName);
if (MessageBox.Show(msg, "World Error", MessageBoxButton.YesNo, MessageBoxImage.Error) !=
MessageBoxResult.Yes)
return;
}
lock (_fileLock)
{
if (resetTime)
{
OnProgressChanged(world, new ProgressChangedEventArgs(0, "Resetting Time..."));
world.ResetTime();
}
if (filename == null)
return;
string temp = filename + ".tmp";
using (var fs = new FileStream(temp, FileMode.Create))
{
using (var bw = new BinaryWriter(fs))
{
if (world.Version > 87)
SaveV2(world, bw);
else
SaveV1(world, bw);
bw.Close();
fs.Close();
// make a backup of current file if it exists
if (File.Exists(filename))
{
string backup = filename + ".TEdit";
File.Copy(filename, backup, true);
}
// replace actual file with temp save file
File.Copy(temp, filename, true);
// delete temp save file
File.Delete(temp);
OnProgressChanged(null, new ProgressChangedEventArgs(0, "World Save Complete."));
}
}
world._lastSave = File.GetLastWriteTimeUtc(filename);
}
}
示例2: NewWorldView
public NewWorldView()
{
InitializeComponent();
_newWorld = new World(1200, 4300, "TEdit World");
_newWorld.Version = World.CompatibleVersion;
_newWorld.GroundLevel = 350;
_newWorld.RockLevel = 480;
_newWorld.ResetTime();
AddCharNames();
this.DataContext = NewWorld;
}
示例3: Save
public static void Save(World world, string filename, bool resetTime = false)
{
lock (_fileLock)
{
OnProgressChanged(world, new ProgressChangedEventArgs(0, "Validating World..."));
world.Validate();
if (resetTime)
{
OnProgressChanged(world, new ProgressChangedEventArgs(0, "Resetting Time..."));
world.ResetTime();
}
if (filename == null)
return;
string temp = filename + ".tmp";
using (var fs = new FileStream(temp, FileMode.Create))
{
using (var bw = new BinaryWriter(fs))
{
if (CompatibleVersion > 87)
SaveV2(world, bw);
else
SaveV1(world, bw);
bw.Close();
fs.Close();
// make a backup of current file if it exists
if (File.Exists(filename))
{
string backup = filename + ".TEdit";
File.Copy(filename, backup, true);
}
// replace actual file with temp save file
File.Copy(temp, filename, true);
// delete temp save file
File.Delete(temp);
OnProgressChanged(null, new ProgressChangedEventArgs(0, "World Save Complete."));
}
}
world._lastSave = File.GetLastWriteTimeUtc(filename);
}
}