本文整理汇总了C#中MiNET.Worlds.Level.Initialize方法的典型用法代码示例。如果您正苦于以下问题:C# Level.Initialize方法的具体用法?C# Level.Initialize怎么用?C# Level.Initialize使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MiNET.Worlds.Level
的用法示例。
在下文中一共展示了Level.Initialize方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetLevel
public virtual Level GetLevel(Player player, string name)
{
Level level = Levels.FirstOrDefault(l => l.LevelId.Equals(name, StringComparison.InvariantCultureIgnoreCase));
if (level == null)
{
level = new Level(name);
level.Initialize();
Levels.Add(level);
}
return level;
}
示例2: GetLevel
public virtual Level GetLevel(Player player, string name)
{
Level level = Levels.FirstOrDefault(l => l.LevelId.Equals(name, StringComparison.InvariantCultureIgnoreCase));
if (level == null)
{
GameMode gameMode = Config.GetProperty("GameMode", GameMode.Survival);
Difficulty difficulty = Config.GetProperty("Difficulty", Difficulty.Peaceful);
int viewDistance = Config.GetProperty("ViewDistance", 11);
IWorldProvider worldProvider = null;
switch (Config.GetProperty("WorldProvider", "flat").ToLower().Trim())
{
case "flat":
case "flatland":
worldProvider = new FlatlandWorldProvider();
break;
case "cool":
worldProvider = new CoolWorldProvider();
break;
case "experimental":
worldProvider = new ExperimentalWorldProvider();
break;
case "anvil":
worldProvider = new AnvilWorldProvider();
break;
default:
worldProvider = new FlatlandWorldProvider();
break;
}
level = new Level(name, worldProvider, gameMode, difficulty, viewDistance);
level.Initialize();
Levels.Add(level);
OnLevelCreated(new LevelEventArgs(null, level));
}
return level;
}
示例3: CreateLevel
public virtual Level CreateLevel(string name)
{
var level = new Level(name);
level.Initialize();
return level;
}
示例4: Join
public Game Join(Player player, string world)
{
if (!Games.ContainsKey(player.Level.LevelId))
{
Games.Add(player.Level.LevelId, new Game(this)
{
Name = player.Level.LevelId,
Level = player.Level,
State = GameState.Undefined
});
}
if (!Games.ContainsKey(world))
{
if (!GameTemplates.ContainsKey(world)) return null;
GameSettings settings = GameTemplates[world];
Level gameLevel = new Level(settings.Name, new AnvilWorldProvider(settings.ArenaWorldPath));
gameLevel.Initialize();
var spawn = gameLevel.SpawnPoint;
if (!world.Equals("Default"))
{
gameLevel.SpawnPoint = new BlockCoordinates
{
X = spawn.X,
Y = spawn.Y + 20,
Z = spawn.Z,
};
}
Games.Add(world, new Game(this) {Name = world, Level = gameLevel, State = GameState.WaitingToStart});
}
Game currentGame = Games[player.Level.LevelId];
Game game = Games[world];
if (game.State == GameState.Started || game.State == GameState.Finshed)
{
return currentGame;
}
currentGame.RemovePlayer(player);
game.AddPlayer(player);
player.SpawnLevel(game.Level);
game.Level.BroadcastTextMessage(string.Format("{0} joined game <{1}>.", player.Username, game.Name));
return game;
}
示例5: Teleport
public void Teleport(Player player, string world)
{
if (player.Level.LevelId.Equals(world)) return;
if (!Context.LevelManager.Levels.Contains(player.Level))
{
Context.LevelManager.Levels.Add(player.Level);
}
ThreadPool.QueueUserWorkItem(delegate(object state)
{
Level[] levels = state as Level[];
if (levels != null)
{
Level nextLevel = levels.FirstOrDefault(l => l.LevelId != null && l.LevelId.Equals(world));
if (nextLevel == null)
{
nextLevel = new Level(world, new FlatlandWorldProvider());
nextLevel.Initialize();
Context.LevelManager.Levels.Add(nextLevel);
}
player.Level.BroadcastMessage(string.Format("{0} teleported to world {1}.", player.Username, nextLevel.LevelId), type: MessageType.Raw);
player.SpawnLevel(nextLevel);
}
}, Context.LevelManager.Levels.ToArray());
}
示例6: Teleport
public void Teleport(Player player, string world)
{
Level oldLevel = player.Level;
if (player.Level.LevelId.Equals(world))
{
Teleport(player, (int) player.SpawnPosition.X, (int) player.SpawnPosition.Y, (int) player.SpawnPosition.Z);
return;
}
if (!Context.LevelManager.Levels.Contains(player.Level))
{
Context.LevelManager.Levels.Add(player.Level);
}
ThreadPool.QueueUserWorkItem(delegate(object state)
{
Level[] levels = state as Level[];
if (levels != null)
{
player.SpawnLevel(null, null, true, delegate
{
Level nextLevel = levels.FirstOrDefault(l => l.LevelId != null && l.LevelId.Equals(world));
if (nextLevel == null)
{
nextLevel = new Level(world, new FlatlandWorldProvider(), player.GameMode, Difficulty.Normal);
nextLevel.Initialize();
Context.LevelManager.Levels.Add(nextLevel);
}
return nextLevel;
});
oldLevel.BroadcastMessage(string.Format("{0} teleported to world {1}.", player.Username, player.Level.LevelId), type: MessageType.Raw);
}
}, Context.LevelManager.Levels.ToArray());
}