当前位置: 首页>>代码示例>>C#>>正文


C# Server.ChooseFreePlayerIndex方法代码示例

本文整理汇总了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;
                    }
开发者ID:CH4Code,项目名称:OpenRA,代码行数:67,代码来源:LobbyCommands.cs

示例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)
开发者ID:romainhk,项目名称:OpenRA,代码行数:67,代码来源:LobbyCommands.cs

示例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 =>
                    {
开发者ID:TiriliPiitPiit,项目名称:OpenRA,代码行数:67,代码来源:LobbyCommands.cs

示例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]]);
开发者ID:Roger-luo,项目名称:OpenRA,代码行数:67,代码来源:LobbyCommands.cs


注:本文中的OpenRA.Server.Server.ChooseFreePlayerIndex方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。