本文整理汇总了C#中MCForge.Level.Dispose方法的典型用法代码示例。如果您正苦于以下问题:C# Level.Dispose方法的具体用法?C# Level.Dispose怎么用?C# Level.Dispose使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MCForge.Level
的用法示例。
在下文中一共展示了Level.Dispose方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Use
public override void Use(Player p, string message)
{
if (message == "") { Help(p); return; }
string[] parameters = message.Split(' '); // Grab the parameters from the player's message
if (parameters.Length >= 5 && parameters.Length <= 6) // make sure there are 5 or 6 params
{
switch (parameters[4])
{
case "flat":
case "pixel":
case "island":
case "mountains":
case "ocean":
case "forest":
case "desert":
case "space":
case "rainbow":
case "hell":
case "nether":
break;
default:
Player.SendMessage(p, "Valid types: island, mountains, forest, ocean, flat, pixel, desert, space, rainbow, and hell/nether"); return;
}
string name = parameters[0].ToLower();
ushort x = 1, y = 1, z = 1;
int seed = 0;
bool useSeed = false;
try
{
x = Convert.ToUInt16(parameters[1]);
y = Convert.ToUInt16(parameters[2]);
z = Convert.ToUInt16(parameters[3]);
}
catch { Player.SendMessage(p, "Invalid dimensions."); return; }
if (parameters.Length == 6)
{
try { seed = Convert.ToInt32(parameters[5]); }
catch { seed = parameters[5].GetHashCode(); }
useSeed = true;
}
if (!isGood(x)) { Player.SendMessage(p, x + " is not a good dimension! Use a power of 2 next time."); }
if (!isGood(y)) { Player.SendMessage(p, y + " is not a good dimension! Use a power of 2 next time."); }
if (!isGood(z)) { Player.SendMessage(p, z + " is not a good dimension! Use a power of 2 next time."); }
if (!Player.ValidName(name)) { Player.SendMessage(p, "Invalid name!"); return; }
if (System.IO.File.Exists("levels/" + name + ".lvl")) { Player.SendMessage(p, "Level \"" + name + "\" already exists!"); return; }
/*try
{
if (p != null)
if (p.group.Permission < LevelPermission.Admin)
{
if (x * y * z > 30000000) { Player.SendMessage(p, "Cannot create a map with over 30million blocks"); return; }
}
else
{
if (x * y * z > 225000000) { Player.SendMessage(p, "You cannot make a map with over 225million blocks"); return; }
}
}
catch
{
Player.SendMessage(p, "An error occured");
}*/
// create a new level...
try
{
using (Level lvl = new Level(name, x, y, z, parameters[4], seed, useSeed))
{
lvl.Save(true); //... and save it.
lvl.Dispose(); // Then take out the garbage.
}
}
finally
{
GC.Collect();
GC.WaitForPendingFinalizers();
}
Player.GlobalMessage("Level \"" + name + "\" created" + (useSeed ? " with seed \"" + parameters[5] + "\"" : "")); // The player needs some form of confirmation.
}
else
Help(p);
}
示例2: Use
//.........这里部分代码省略.........
{
x = Convert.ToUInt16(parameters[1]);
y = Convert.ToUInt16(parameters[2]);
z = Convert.ToUInt16(parameters[3]);
}
catch { Player.SendMessage(p, "Invalid dimensions."); return; }
if (parameters.Length == 6)
{
try { seed = Convert.ToInt32(parameters[5]); }
catch { seed = parameters[5].GetHashCode(); }
useSeed = true;
}
if (!isGood(x)) { Player.SendMessage(p, x + " is not a good dimension! Use a power of 2 next time."); }
if (!isGood(y)) { Player.SendMessage(p, y + " is not a good dimension! Use a power of 2 next time."); }
if (!isGood(z)) { Player.SendMessage(p, z + " is not a good dimension! Use a power of 2 next time."); }
if (!Player.ValidName(name)) { Player.SendMessage(p, "Invalid name!"); return; }
//if (System.IO.File.Exists("levels/" + name + ".lvl")) { Player.SendMessage(p, "Level \"" + name + "\" already exists!"); return; }
StringBuilder dir = new StringBuilder("levels/" + name);
dir.Append(mapnumber != 0 ? "." + mapnumber.ToString() : "");
dir.Append(".lvl");
while (System.IO.File.Exists(dir.ToString()))
{
if (p != null)
{
if (mapnumber < p.GetMaxMaps())
{
Server.s.Log(mapnumber.ToString());
Server.s.Log(dir.ToString());
Server.s.Log(p.GetMaxMaps().ToString());
mapnumber++;
dir = null;
dir = new StringBuilder("levels/" + name);
dir.Append(mapnumber != 0 ? "." + mapnumber.ToString() : "");
dir.Append(".lvl");
}
else { Player.SendMessage(p, "You have used up your maps!"); return; }
}
else { Player.SendMessage(p, "Level \"" + name + "\" already exists!"); return; }
}
name = name + "." + mapnumber.ToString();
/*retry:
StringBuilder dir = new StringBuilder("levels/" + name);
dir.Append(mapnumber != 0 ? "." + mapnumber.ToString() : "");
dir.Append(".lvl");
if (System.IO.File.Exists(dir.ToString()))
{
if (p != null)
{
if (mapnumber <= p.GetMaxMaps())
{
mapnumber++;
goto retry;
}
else { Player.SendMessage(p, "You have used up your maps!"); return; }
}
else { Player.SendMessage(p, "Level \"" + name + "\" already exists!"); return; }
}*/
/*try
{
if (p != null)
if (p.group.Permission < LevelPermission.Admin)
{
if (x * y * z > 30000000) { Player.SendMessage(p, "Cannot create a map with over 30million blocks"); return; }
}
else
{
if (x * y * z > 225000000) { Player.SendMessage(p, "You cannot make a map with over 225million blocks"); return; }
}
}
catch
{
Player.SendMessage(p, "An error occured");
}*/
// create a new level...
try
{
using (Level lvl = new Level(name, x, y, z, parameters[4], seed, useSeed))
{
lvl.Save(true); //... and save it.
lvl.Dispose(); // Then take out the garbage.
}
}
finally
{
GC.Collect();
GC.WaitForPendingFinalizers();
}
Player.GlobalMessage("Level \"" + name + "\" created" + (useSeed ? " with seed \"" + parameters[5] + "\"" : "")); // The player needs some form of confirmation.
}
else
Help(p);
}