本文整理汇总了C#中Configuration.GetList方法的典型用法代码示例。如果您正苦于以下问题:C# Configuration.GetList方法的具体用法?C# Configuration.GetList怎么用?C# Configuration.GetList使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Configuration
的用法示例。
在下文中一共展示了Configuration.GetList方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CMatchInfo
/// <summary>
/// Initializes the underlying <see cref="MatchInfo"/> with values provided by a <see cref="Configuration"/>
/// and associates the <see cref="MatchInfo"/> with the given <see cref="ControllerInformation"/>.
/// </summary>
/// <param name="config">The <see cref="Configuration"/> to load settings from.</param>
/// <param name="controllerInfos">A variable number of <see cref="ControllerInformation"/>
/// to associate with.</param>
/// <exception cref="ControllerIncompatibleException">A controller is not designed for the
/// configured <see cref="GameMode"/>.</exception>
public CMatchInfo(Configuration config, params ControllerInformation[] controllerInfos)
{
//Get the game mode from the Configuration.
DetermineGameMode(config);
//Make sure all of the controllers are compatible with the given game mode.
foreach (var controllerInfo in controllerInfos)
{
if (!controllerInfo.Capabilities.CompatibleWith(gameMode))
{
throw new ControllerIncompatibleException(controllerInfo, gameMode);
}
}
this.controllerNames = new List<string>();
foreach (var controllerInfo in controllerInfos)
{
this.controllerNames.Add(controllerInfo.ToString());
}
//Configuration setting for a list of ships that the controllers start with.
initShips = new ShipList(config.GetList<int>("mbc_ship_sizes").ToArray());
//Configuration setting for the size of the field.
fieldSize = new Coordinates(
config.GetValue<int>("mbc_field_width"),
config.GetValue<int>("mbc_field_height"));
//Configuration setting for the amount of time a controller is allowed per method invoke.
methodTimeLimit = config.GetValue<int>("mbc_timeout");
}
示例2: DetermineGameMode
private void DetermineGameMode(Configuration config)
{
gameMode = 0;
foreach (var gmStr in config.GetList<GameMode>("mbc_game_mode"))
{
gameMode |= gmStr;
if (gmStr == GameMode.Salvo || gmStr == GameMode.Powered || gmStr == GameMode.Teams)
{
throw new NotImplementedException("The " + gmStr.ToString() + " game mode is not supported.");
}
}
}
示例3: CMatchInfo
/// <summary>
/// Initializes the underlying <see cref="MatchInfo"/> with values provided by a <see cref="Configuration"/>
/// and associates the <see cref="MatchInfo"/> with the given <see cref="ControllerInformation"/>.
/// </summary>
/// <param name="config">The <see cref="Configuration"/> to load settings from.</param>
/// <param name="controllerNames">A variable number of <see cref="ControllerInformation"/>
/// to associate with.</param>
/// <exception cref="ControllerIncompatibleException">A controller is not designed for the
/// configured <see cref="GameMode"/>.</exception>
public CMatchInfo(Configuration config)
{
//Get the game mode from the Configuration.
DetermineGameMode(config);
this.controllerNames = new List<string>();
//Configuration setting for a list of ships that the controllers start with.
initShips = new ShipList(config.GetList<int>("mbc_ship_sizes").ToArray());
//Configuration setting for the size of the field.
fieldSize = new Coordinates(
config.GetValue<int>("mbc_field_width"),
config.GetValue<int>("mbc_field_height"));
//Configuration setting for the amount of time a controller is allowed per method invoke.
methodTimeLimit = config.GetValue<int>("mbc_timeout");
}
示例4: SetConfiguration
public void SetConfiguration(Configuration config)
{
Config = config;
var newConfig = new MatchConfig();
newConfig.FieldSize = new Coordinates(Config.GetValue<int>("mbc_field_width"), Config.GetValue<int>("mbc_field_height"));
newConfig.NumberOfRounds = Config.GetValue<int>("mbc_match_rounds");
var initShips = new ShipList();
foreach (var length in Config.GetList<int>("mbc_ship_sizes"))
{
initShips.Add(new Ship(length));
}
newConfig.StartingShips = initShips;
newConfig.TimeLimit = Config.GetValue<int>("mbc_player_timeout");
newConfig.GameMode = 0;
foreach (var mode in Config.GetList<GameMode>("mbc_game_mode"))
{
newConfig.GameMode |= mode;
}
if (!newConfig.GameMode.HasFlag(GameMode.Classic))
{
throw new NotImplementedException("The " + newConfig.GameMode.ToString() + " game mode is not supported.");
}
newConfig.Random = new Random();
ApplyEvent(new MatchConfigChangedEvent(newConfig));
}
示例5: ApplyParameters
/// <summary>
/// Applies a configuration to the match.
/// </summary>
/// <param name="conf"></param>
private void ApplyParameters(Configuration conf)
{
fieldSize = new Coordinates(conf.GetValue<int>("mbc_field_width"), conf.GetValue<int>("mbc_field_height"));
numberOfRounds = conf.GetValue<int>("mbc_match_rounds");
startingShips = ShipList.ShipsFromLengths(conf.GetList<int>("mbc_ship_sizes"));
timeLimit = conf.GetValue<int>("mbc_player_timeout");
gameModes = conf.GetList<GameMode>("mbc_game_mode");
}