本文整理汇总了C#中OpenRA.Server.Server.ChooseFreePlayerIndex方法的典型用法代码示例。如果您正苦于以下问题:C# Server.ChooseFreePlayerIndex方法的具体用法?C# Server.ChooseFreePlayerIndex怎么用?C# Server.ChooseFreePlayerIndex使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类OpenRA.Server.Server
的用法示例。
在下文中一共展示了Server.ChooseFreePlayerIndex方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: InterpretCommand
//.........这里部分代码省略.........
if (parts.Length < 3)
{
server.SendOrderTo(conn, "Message", "Malformed slot_bot command");
return true;
}
if (!ValidateSlotCommand(server, conn, client, parts[0], true))
return false;
var slot = server.LobbyInfo.Slots[parts[0]];
var bot = server.LobbyInfo.ClientInSlot(parts[0]);
int controllerClientIndex;
if (!Exts.TryParseIntegerInvariant(parts[1], out controllerClientIndex))
{
Log.Write("server", "Invalid bot controller client index: {0}", parts[1]);
return false;
}
var botType = parts.Skip(2).JoinWith(" ");
// Invalid slot
if (bot != null && bot.Bot == null)
{
server.SendOrderTo(conn, "Message", "Can't add bots to a slot with another client.");
return true;
}
slot.Closed = false;
if (bot == null)
{
// Create a new bot
bot = new Session.Client()
{
Index = server.ChooseFreePlayerIndex(),
Name = botType,
Bot = botType,
Slot = parts[0],
Faction = "Random",
SpawnPoint = 0,
Team = 0,
State = Session.ClientState.NotReady,
BotControllerClientIndex = controllerClientIndex
};
// Pick a random color for the bot
var validator = server.ModData.Manifest.Get<ColorValidator>();
var tileset = server.Map.Rules.TileSet;
var terrainColors = tileset.TerrainInfo.Where(ti => ti.RestrictPlayerColor).Select(ti => ti.Color);
var playerColors = server.LobbyInfo.Clients.Select(c => c.Color.RGB)
.Concat(server.Map.Players.Players.Values.Select(p => p.Color.RGB));
bot.Color = bot.PreferredColor = validator.RandomValidColor(server.Random, terrainColors, playerColors);
server.LobbyInfo.Clients.Add(bot);
}
else
{
// Change the type of the existing bot
bot.Name = botType;
bot.Bot = botType;
}
S.SyncClientToPlayerReference(bot, server.Map.Players.Players[parts[0]]);
server.SyncLobbyClients();
server.SyncLobbySlots();
return true;
}
示例2: InterpretCommand
//.........这里部分代码省略.........
return true;
}},
{ "slot_bot",
s =>
{
var parts = s.Split(' ');
if (parts.Length < 2)
{
server.SendChatTo( conn, "Malformed slot_bot command" );
return true;
}
if (!ValidateSlotCommand( server, conn, client, parts[0], true ))
return false;
var slot = server.lobbyInfo.Slots[parts[0]];
var bot = server.lobbyInfo.ClientInSlot(parts[0]);
var botType = parts.Skip(1).JoinWith(" ");
// Invalid slot
if (bot != null && bot.Bot == null)
{
server.SendChatTo( conn, "Can't add bots to a slot with another client" );
return true;
}
slot.Closed = false;
if (bot == null)
{
// Create a new bot
bot = new Session.Client()
{
Index = server.ChooseFreePlayerIndex(),
Name = botType,
Bot = botType,
Slot = parts[0],
Country = "random",
SpawnPoint = 0,
Team = 0,
State = Session.ClientState.NotReady
};
// pick a random color for the bot
var hue = (byte)server.Random.Next(255);
var sat = (byte)server.Random.Next(255);
var lum = (byte)server.Random.Next(51,255);
bot.ColorRamp = new ColorRamp(hue, sat, lum, 10);
server.lobbyInfo.Clients.Add(bot);
}
else
{
// Change the type of the existing bot
bot.Name = botType;
bot.Bot = botType;
}
S.SyncClientToPlayerReference(bot, server.Map.Players[parts[0]]);
server.SyncLobbyInfo();
return true;
}},
{ "map",
s =>
{
if (!client.IsAdmin)
示例3: InterpretCommand
//.........这里部分代码省略.........
if (parts.Length < 3)
{
server.SendOrderTo(conn, "Message", "Malformed slot_bot command");
return true;
}
if (!ValidateSlotCommand(server, conn, client, parts[0], true))
return false;
var slot = server.lobbyInfo.Slots[parts[0]];
var bot = server.lobbyInfo.ClientInSlot(parts[0]);
int controllerClientIndex;
if (!int.TryParse(parts[1], out controllerClientIndex))
{
Log.Write("server", "Invalid bot controller client index: {0}", parts[1]);
return false;
}
var botType = parts.Skip(2).JoinWith(" ");
// Invalid slot
if (bot != null && bot.Bot == null)
{
server.SendOrderTo(conn, "Message", "Can't add bots to a slot with another client");
return true;
}
slot.Closed = false;
if (bot == null)
{
// Create a new bot
bot = new Session.Client()
{
Index = server.ChooseFreePlayerIndex(),
Name = botType,
Bot = botType,
Slot = parts[0],
Country = "random",
SpawnPoint = 0,
Team = 0,
State = Session.ClientState.NotReady,
BotControllerClientIndex = controllerClientIndex
};
// pick a random color for the bot
var hue = (byte)server.Random.Next(255);
var sat = (byte)server.Random.Next(255);
var lum = (byte)server.Random.Next(51,255);
bot.Color = bot.PreferredColor = new HSLColor(hue, sat, lum);
server.lobbyInfo.Clients.Add(bot);
}
else
{
// Change the type of the existing bot
bot.Name = botType;
bot.Bot = botType;
}
S.SyncClientToPlayerReference(bot, server.Map.Players[parts[0]]);
server.SyncLobbyInfo();
return true;
}},
{ "map",
s =>
{
示例4: InterpretCommand
//.........这里部分代码省略.........
if (parts.Length < 3)
{
server.SendOrderTo(conn, "Message", "Malformed slot_bot command");
return true;
}
if (!ValidateSlotCommand(server, conn, client, parts[0], true))
return false;
var slot = server.LobbyInfo.Slots[parts[0]];
var bot = server.LobbyInfo.ClientInSlot(parts[0]);
int controllerClientIndex;
if (!Exts.TryParseIntegerInvariant(parts[1], out controllerClientIndex))
{
Log.Write("server", "Invalid bot controller client index: {0}", parts[1]);
return false;
}
var botType = parts.Skip(2).JoinWith(" ");
// Invalid slot
if (bot != null && bot.Bot == null)
{
server.SendOrderTo(conn, "Message", "Can't add bots to a slot with another client.");
return true;
}
slot.Closed = false;
if (bot == null)
{
// Create a new bot
bot = new Session.Client()
{
Index = server.ChooseFreePlayerIndex(),
Name = botType,
Bot = botType,
Slot = parts[0],
Faction = "Random",
SpawnPoint = 0,
Team = 0,
State = Session.ClientState.NotReady,
BotControllerClientIndex = controllerClientIndex
};
// Pick a random color for the bot
HSLColor botColor;
do
{
var hue = (byte)server.Random.Next(255);
var sat = (byte)server.Random.Next(255);
var lum = (byte)server.Random.Next(51, 255);
botColor = new HSLColor(hue, sat, lum);
} while (!ColorValidator.ValidatePlayerNewColor(server, botColor.RGB, bot.Index));
bot.Color = bot.PreferredColor = botColor;
server.LobbyInfo.Clients.Add(bot);
}
else
{
// Change the type of the existing bot
bot.Name = botType;
bot.Bot = botType;
}
S.SyncClientToPlayerReference(bot, server.MapPlayers.Players[parts[0]]);