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


C# OrderManager.IssueOrder方法代码示例

本文整理汇总了C#中OpenRA.Network.OrderManager.IssueOrder方法的典型用法代码示例。如果您正苦于以下问题:C# OrderManager.IssueOrder方法的具体用法?C# OrderManager.IssueOrder怎么用?C# OrderManager.IssueOrder使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在OpenRA.Network.OrderManager的用法示例。


在下文中一共展示了OrderManager.IssueOrder方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ShowSlotDropDown

		public static void ShowSlotDropDown(Ruleset rules, DropDownButtonWidget dropdown, Session.Slot slot,
			Session.Client client, OrderManager orderManager)
		{
			var options = new Dictionary<string, IEnumerable<SlotDropDownOption>>() {{"Slot", new List<SlotDropDownOption>()
			{
				new SlotDropDownOption("Open", "slot_open "+slot.PlayerReference, () => (!slot.Closed && client == null)),
				new SlotDropDownOption("Closed", "slot_close "+slot.PlayerReference, () => slot.Closed)
			}}};

			var bots = new List<SlotDropDownOption>();
			if (slot.AllowBots)
			{
				foreach (var b in rules.Actors["player"].Traits.WithInterface<IBotInfo>().Select(t => t.Name))
				{
					var bot = b;
					var botController = orderManager.LobbyInfo.Clients.FirstOrDefault(c => c.IsAdmin);
					bots.Add(new SlotDropDownOption(bot,
						"slot_bot {0} {1} {2}".F(slot.PlayerReference, botController.Index, bot),
						() => client != null && client.Bot == bot));
				}
			}
			options.Add(bots.Any() ? "Bots" : "Bots Disabled", bots);

			Func<SlotDropDownOption, ScrollItemWidget, ScrollItemWidget> setupItem = (o, itemTemplate) =>
			{
				var item = ScrollItemWidget.Setup(itemTemplate,
					o.Selected,
					() => orderManager.IssueOrder(Order.Command(o.Order)));
				item.Get<LabelWidget>("LABEL").GetText = () => o.Title;
				return item;
			};

			dropdown.ShowDropDown<SlotDropDownOption>("LABEL_DROPDOWN_TEMPLATE", 167, options, setupItem);
		}
开发者ID:JackKucan,项目名称:OpenRA,代码行数:34,代码来源:LobbyUtils.cs

示例2: IngameChatLogic

        public IngameChatLogic(Widget widget, OrderManager orderManager, World world)
        {
            World = world;
            var chatPanel = (ContainerWidget) widget;

            ChatOverlay = chatPanel.Get<ContainerWidget>("CHAT_OVERLAY");
            ChatOverlayDisplay = ChatOverlay.Get<ChatDisplayWidget>("CHAT_DISPLAY");
            ChatOverlay.Visible = false;

            ChatChrome = chatPanel.Get<ContainerWidget>("CHAT_CHROME");
            ChatChrome.Visible = true;

            var chatMode = ChatChrome.Get<ButtonWidget>("CHAT_MODE");
            chatMode.GetText = () => TeamChat ? "Team" : "All";
            chatMode.OnClick = () => TeamChat = !TeamChat;

            ChatText = ChatChrome.Get<TextFieldWidget>("CHAT_TEXTFIELD");
            ChatText.OnTabKey = () => { TeamChat = !TeamChat; return true; };
            ChatText.OnEnterKey = () =>
            {
                ChatText.Text = ChatText.Text.Trim();
                if (ChatText.Text != "")
                    orderManager.IssueOrder(Order.Chat(TeamChat, ChatText.Text));
                CloseChat();
                return true;
            };
            ChatText.OnEscKey = () => {CloseChat(); return true; };

            var chatClose = ChatChrome.Get<ButtonWidget>("CHAT_CLOSE");
            chatClose.OnClick += () => CloseChat();

            chatPanel.OnKeyPress = (e) =>
            {
                if (e.Event == KeyInputEvent.Up) return false;
                if (!IsOpen && (e.KeyName == "enter" || e.KeyName == "return") )
                {

                    var shift = e.Modifiers.HasModifier(Modifiers.Shift);
                    var toggle = Game.Settings.Game.TeamChatToggle ;
                    TeamChat = (!toggle && shift) || ( toggle &&  (TeamChat ^ shift) );
                    OpenChat();
                    return true;
                }

                return false;
            };

            ChatScrollPanel = ChatChrome.Get<ScrollPanelWidget>("CHAT_SCROLLPANEL");
            ChatTemplate = ChatScrollPanel.Get<ContainerWidget>("CHAT_TEMPLATE");

            Game.AddChatLine += AddChatLine;
            Game.BeforeGameStart += UnregisterEvents;

            CloseChat();
            ChatOverlayDisplay.AddLine(Color.White, null, "Use RETURN key to open chat window...");
        }
开发者ID:TiriliPiitPiit,项目名称:OpenRA,代码行数:56,代码来源:IngameChatLogic.cs

示例3: ShowTeamDropDown

		public static void ShowTeamDropDown(DropDownButtonWidget dropdown, Session.Client client,
			OrderManager orderManager, int teamCount)
		{
			Func<int, ScrollItemWidget, ScrollItemWidget> setupItem = (ii, itemTemplate) =>
			{
				var item = ScrollItemWidget.Setup(itemTemplate,
					() => client.Team == ii,
					() => orderManager.IssueOrder(Order.Command("team {0} {1}".F(client.Index, ii))));
				item.Get<LabelWidget>("LABEL").GetText = () => ii == 0 ? "-" : ii.ToString();
				return item;
			};

			var options = Exts.MakeArray(teamCount + 1, i => i).ToList();
			dropdown.ShowDropDown("TEAM_DROPDOWN_TEMPLATE", 150, options, setupItem);
		}
开发者ID:JackKucan,项目名称:OpenRA,代码行数:15,代码来源:LobbyUtils.cs

示例4: ShowRaceDropDown

        public static void ShowRaceDropDown(DropDownButtonWidget dropdown, Session.Client client,
			OrderManager orderManager, Dictionary<string, string> countryNames)
        {
            Func<string, ScrollItemWidget, ScrollItemWidget> setupItem = (race, itemTemplate) =>
            {
                var item = ScrollItemWidget.Setup(itemTemplate,
                    () => client.Country == race,
                    () => orderManager.IssueOrder(Order.Command("race {0} {1}".F(client.Index, race))));
                item.GetWidget<LabelWidget>("LABEL").GetText = () => countryNames[race];
                var flag = item.GetWidget<ImageWidget>("FLAG");
                flag.GetImageCollection = () => "flags";
                flag.GetImageName = () => race;
                return item;
            };

            dropdown.ShowDropDown("RACE_DROPDOWN_TEMPLATE", 150, countryNames.Keys.ToList(), setupItem);
        }
开发者ID:hoxworth,项目名称:OpenRA,代码行数:17,代码来源:LobbyUtils.cs

示例5: SelectSpawnPoint

        public static void SelectSpawnPoint(OrderManager orderManager, MapPreviewWidget mapPreview, Map map, MouseInput mi)
        {
            if (map == null || mi.Button != MouseButton.Left
                || orderManager.LocalClient.State == Session.ClientState.Ready)
                return;

            var selectedSpawn = map.GetSpawnPoints()
                .Select((sp, i) => Pair.New(mapPreview.ConvertToPreview(sp), i))
                .Where(a => (a.First - mi.Location).LengthSquared < 64)
                .Select(a => a.Second + 1)
                .FirstOrDefault();

            var owned = orderManager.LobbyInfo.Clients.Any(c => c.SpawnPoint == selectedSpawn);
            if (selectedSpawn == 0 || !owned)
            {
                var locals = orderManager.LobbyInfo.Clients.Where(c => c.Index == orderManager.LocalClient.Index || (Game.IsHost && c.Bot != null));
                var playerToMove = locals.Where(c => (selectedSpawn == 0) ^ (c.SpawnPoint == 0)).FirstOrDefault();
                orderManager.IssueOrder(Order.Command("spawn {0} {1}".F((playerToMove ?? orderManager.LocalClient).Index, selectedSpawn)));
            }
        }
开发者ID:sonygod,项目名称:OpenRA-Dedicated-20120504,代码行数:20,代码来源:LobbyUtils.cs

示例6: SetupNameWidget

        public static void SetupNameWidget(OrderManager orderManager, Session.Client c, TextFieldWidget name)
        {
            name.Text = c.Name;
            name.OnEnterKey = () =>
            {
                name.Text = name.Text.Trim();
                if (name.Text.Length == 0)
                    name.Text = c.Name;

                name.LoseFocus();
                if (name.Text == c.Name)
                    return true;

                orderManager.IssueOrder(Order.Command("name " + name.Text));
                Game.Settings.Player.Name = name.Text;
                Game.Settings.Save();
                return true;
            };
            name.OnLoseFocus = () => name.OnEnterKey();
        }
开发者ID:sonygod,项目名称:OpenRA-Dedicated-20120504,代码行数:20,代码来源:LobbyUtils.cs

示例7: ShowSlotDropDown

        public static void ShowSlotDropDown(DropDownButtonWidget dropdown, Session.Slot slot,
			Session.Client client, OrderManager orderManager)
        {
            var options = new List<SlotDropDownOption>()
            {
                new SlotDropDownOption("Open", "slot_open "+slot.PlayerReference, () => (!slot.Closed && client == null)),
                new SlotDropDownOption("Closed", "slot_close "+slot.PlayerReference, () => slot.Closed)
            };

            if (slot.AllowBots)
                foreach (var b in Rules.Info["player"].Traits.WithInterface<IBotInfo>().Select(t => t.Name))
                {
                    var bot = b;
                    options.Add(new SlotDropDownOption("Bot: {0}".F(bot),
                        "slot_bot {0} {1}".F(slot.PlayerReference, bot),
                        () => client != null && client.Bot == bot));
                }

            Func<SlotDropDownOption, ScrollItemWidget, ScrollItemWidget> setupItem = (o, itemTemplate) =>
            {
                var item = ScrollItemWidget.Setup(itemTemplate,
                    o.Selected,
                    () => orderManager.IssueOrder(Order.Command(o.Order)));
                item.Get<LabelWidget>("LABEL").GetText = () => o.Title;
                return item;
            };

            dropdown.ShowDropDown("LABEL_DROPDOWN_TEMPLATE", 150, options, setupItem);
        }
开发者ID:sonygod,项目名称:OpenRA-Dedicated-20120504,代码行数:29,代码来源:LobbyUtils.cs

示例8: IngameChatLogic

        public IngameChatLogic(Widget widget, OrderManager orderManager, World world, Ruleset modRules)
        {
            this.modRules = modRules;

            chatTraits = world.WorldActor.TraitsImplementing<INotifyChat>().ToList();

            var players = world.Players.Where(p => p != world.LocalPlayer && !p.NonCombatant && !p.IsBot);
            var disableTeamChat = world.LocalPlayer == null || world.LobbyInfo.IsSinglePlayer || !players.Any(p => p.IsAlliedWith(world.LocalPlayer));
            teamChat = !disableTeamChat;

            var chatPanel = (ContainerWidget)widget;
            chatOverlay = chatPanel.Get<ContainerWidget>("CHAT_OVERLAY");
            chatOverlayDisplay = chatOverlay.Get<ChatDisplayWidget>("CHAT_DISPLAY");
            chatOverlay.Visible = false;

            chatChrome = chatPanel.Get<ContainerWidget>("CHAT_CHROME");
            chatChrome.Visible = true;

            var chatMode = chatChrome.Get<ButtonWidget>("CHAT_MODE");
            chatMode.GetText = () => teamChat ? "Team" : "All";
            chatMode.OnClick = () => teamChat ^= true;
            chatMode.IsDisabled = () => disableTeamChat;

            chatText = chatChrome.Get<TextFieldWidget>("CHAT_TEXTFIELD");
            chatText.OnTabKey = () =>
            {
                if (!disableTeamChat)
                    teamChat ^= true;
                return true;
            };
            chatText.OnEnterKey = () =>
            {
                var team = teamChat && !disableTeamChat;
                if (chatText.Text != "")
                    orderManager.IssueOrder(Order.Chat(team, chatText.Text.Trim()));

                CloseChat();
                return true;
            };

            chatText.OnEscKey = () => { CloseChat(); return true; };

            var chatClose = chatChrome.Get<ButtonWidget>("CHAT_CLOSE");
            chatClose.OnClick += () => CloseChat();

            chatPanel.OnKeyPress = (e) =>
            {
                if (e.Event == KeyInputEvent.Up)
                    return false;

                if (!chatChrome.IsVisible() && (e.Key == Keycode.RETURN || e.Key == Keycode.KP_ENTER))
                {
                    OpenChat();
                    return true;
                }

                return false;
            };

            chatScrollPanel = chatChrome.Get<ScrollPanelWidget>("CHAT_SCROLLPANEL");
            chatTemplate = chatScrollPanel.Get<ContainerWidget>("CHAT_TEMPLATE");
            chatScrollPanel.RemoveChildren();

            Game.AddChatLine += AddChatLine;
            Game.BeforeGameStart += UnregisterEvents;

            CloseChat();
        }
开发者ID:RunCraze,项目名称:OpenRA,代码行数:68,代码来源:IngameChatLogic.cs

示例9: SetupEditableNameWidget

        public static void SetupEditableNameWidget(Widget parent, Session.Slot s, Session.Client c, OrderManager orderManager)
        {
            var name = parent.Get<TextFieldWidget>("NAME");
            name.IsVisible = () => true;
            name.IsDisabled = () => orderManager.LocalClient.IsReady;

            name.Text = c.Name;
            name.OnEnterKey = () =>
            {
                name.Text = name.Text.Trim();
                if (name.Text.Length == 0)
                    name.Text = c.Name;

                name.LoseFocus();
                if (name.Text == c.Name)
                    return true;

                orderManager.IssueOrder(Order.Command("name " + name.Text));
                Game.Settings.Player.Name = name.Text;
                Game.Settings.Save();
                return true;
            };

            name.OnLoseFocus = () => name.OnEnterKey();
        }
开发者ID:Tsher,项目名称:OpenRA,代码行数:25,代码来源:LobbyUtils.cs

示例10: SetupKickSpectatorsWidget

        public static void SetupKickSpectatorsWidget(Widget parent, OrderManager orderManager, Widget lobby, Action before, Action after, bool skirmishMode)
        {
            var checkBox = parent.Get<CheckboxWidget>("TOGGLE_SPECTATORS");
            checkBox.IsChecked = () => orderManager.LobbyInfo.GlobalSettings.AllowSpectators;
            checkBox.IsVisible = () => orderManager.LocalClient.IsAdmin && !skirmishMode;
            checkBox.IsDisabled = () => false;

            Action okPressed = () =>
            {
                orderManager.IssueOrder(Order.Command("allow_spectators {0}".F(!orderManager.LobbyInfo.GlobalSettings.AllowSpectators)));
                orderManager.IssueOrders(
                    orderManager.LobbyInfo.Clients.Where(
                        c => c.IsObserver && !c.IsAdmin).Select(
                            client => Order.Command("kick {0} {1}".F(client.Index, client.Name))).ToArray());

                after();
            };

            checkBox.OnClick = () =>
            {
                before();

                var spectatorCount = orderManager.LobbyInfo.Clients.Count(c => c.IsObserver);
                if (spectatorCount > 0)
                {
                    Game.LoadWidget(null, "KICK_SPECTATORS_DIALOG", lobby.Get("TOP_PANELS_ROOT"), new WidgetArgs
                    {
                        { "clientCount", "{0}".F(spectatorCount) },
                        { "okPressed", okPressed },
                        { "cancelPressed", after }
                    });
                }
                else
                {
                    orderManager.IssueOrder(Order.Command("allow_spectators {0}".F(!orderManager.LobbyInfo.GlobalSettings.AllowSpectators)));
                    after();
                }
            };
        }
开发者ID:CH4Code,项目名称:OpenRA,代码行数:39,代码来源:LobbyUtils.cs

示例11: SetupEditableNameWidget

        public static void SetupEditableNameWidget(Widget parent, Session.Slot s, Session.Client c, OrderManager orderManager)
        {
            var name = parent.Get<TextFieldWidget>("NAME");
            name.IsVisible = () => true;
            name.IsDisabled = () => orderManager.LocalClient.IsReady;

            name.Text = c.Name;
            var escPressed = false;
            name.OnLoseFocus = () =>
            {
                if (escPressed)
                {
                    escPressed = false;
                    return;
                }

                name.Text = name.Text.Trim();
                if (name.Text.Length == 0)
                    name.Text = c.Name;
                else if (name.Text != c.Name)
                {
                    name.Text = Settings.SanitizedPlayerName(name.Text);
                    orderManager.IssueOrder(Order.Command("name " + name.Text));
                    Game.Settings.Player.Name = name.Text;
                    Game.Settings.Save();
                }
            };

            name.OnEnterKey = () => { name.YieldKeyboardFocus(); return true; };
            name.OnEscKey = () =>
            {
                name.Text = c.Name;
                escPressed = true;
                name.YieldKeyboardFocus();
                return true;
            };
        }
开发者ID:CH4Code,项目名称:OpenRA,代码行数:37,代码来源:LobbyUtils.cs

示例12: ProcessOrder

        public static void ProcessOrder(OrderManager orderManager, World world, int clientId, Order order)
        {
            if (world != null)
            {
                if (!world.WorldActor.TraitsImplementing<IValidateOrder>().All(vo =>
                    vo.OrderValidation(orderManager, world, clientId, order)))
                    return;
            }

            switch (order.OrderString)
            {
                case "Chat":
                    {
                        var client = orderManager.LobbyInfo.ClientWithIndex(clientId);
                        if (client != null)
                        {
                            var player = world != null ? world.FindPlayerByClient(client) : null;
                            var suffix = (player != null && player.WinState == WinState.Lost) ? " (Dead)" : "";
                            Game.AddChatLine(client.ColorRamp.GetColor(0), client.Name + suffix, order.TargetString);
                        }
                        else
                            Game.AddChatLine(Color.White, "(player {0})".F(clientId), order.TargetString);
                        break;
                    }
                case "Disconnected": /* reports that the target player disconnected */
                    {
                        var client = orderManager.LobbyInfo.ClientWithIndex(clientId);
                        if (client != null)
                        {
                            client.State = Session.ClientState.Disconnected;
                        }
                        break;
                    }
                case "TeamChat":
                    {
                        var client = orderManager.LobbyInfo.ClientWithIndex(clientId);

                        if (client != null)
                        {
                            if (world == null)
                            {
                                if (client.Team == orderManager.LocalClient.Team)
                                    Game.AddChatLine(client.ColorRamp.GetColor(0), client.Name + " (Team)",
                                                     order.TargetString);
                            }
                            else
                            {
                                var player = world.FindPlayerByClient(client);
                                var display = player != null
                                              &&
                                              (world.LocalPlayer != null &&
                                               player.Stances[world.LocalPlayer] == Stance.Ally
                                               || player.WinState == WinState.Lost);

                                if (display)
                                {
                                    var suffix = (player != null && player.WinState == WinState.Lost)
                                                     ? " (Dead)"
                                                     : " (Team)";
                                    Game.AddChatLine(client.ColorRamp.GetColor(0), client.Name + suffix, order.TargetString);
                                }
                            }
                        }
                        break;
                    }
                case "StartGame":
                    {
                        Game.AddChatLine(Color.White, "Server", "The game has started.");
                        Game.StartGame(orderManager.LobbyInfo.GlobalSettings.Map);
                        break;
                    }

                case "HandshakeRequest":
                {
                    var request = HandshakeRequest.Deserialize(order.TargetString);

                    // Check that the map exists on the client
                    if (!Game.modData.AvailableMaps.ContainsKey(request.Map))
                        throw new InvalidOperationException("Missing map {0}".F(request.Map));

                    var info = new Session.Client()
                    {
                        Name = Game.Settings.Player.Name,
                        ColorRamp = Game.Settings.Player.ColorRamp,
                        Country = "random",
                        SpawnPoint = 0,
                        Team = 0,
                        State = Session.ClientState.NotReady
                    };

                    var localMods = orderManager.LobbyInfo.GlobalSettings.Mods.Select(m => "{0}@{1}".F(m,Mod.AllMods[m].Version)).ToArray();
                    var response = new HandshakeResponse()
                    {
                        Client = info,
                        Mods = localMods,
                        Password = "Foo"
                    };

                    orderManager.IssueOrder(Order.HandshakeResponse(response.Serialize()));
                    break;
//.........这里部分代码省略.........
开发者ID:katzsmile,项目名称:OpenRA,代码行数:101,代码来源:UnitOrders.cs

示例13: ProcessOrder


//.........这里部分代码省略.........
							}

							orderManager.world.Paused = pause;
							orderManager.world.PredictedPaused = pause;
						}
						break;
					}

				case "HandshakeRequest":
					{
						// TODO: Switch to the server's mod if we have it
						// Otherwise send the handshake with our current settings and let the server reject us
						var mod = Game.modData.Manifest.Mod;

						var info = new Session.Client()
						{
							Name = Game.Settings.Player.Name,
							PreferredColor = Game.Settings.Player.Color,
							Color = Game.Settings.Player.Color,
							Country = "random",
							SpawnPoint = 0,
							Team = 0,
							State = Session.ClientState.Invalid
						};

						var response = new HandshakeResponse()
						{
							Client = info,
							Mod = mod.Id,
							Version = mod.Version,
							Password = orderManager.Password
						};

						orderManager.IssueOrder(Order.HandshakeResponse(response.Serialize()));
						break;
					}

				case "ServerError":
					{
						orderManager.ServerError = order.TargetString;
						orderManager.AuthenticationFailed = false;
						break;
					}

				case "AuthenticationError":
					{
						orderManager.ServerError = order.TargetString;
						orderManager.AuthenticationFailed = true;
						break;
					}

				case "SyncInfo":
					{
						orderManager.LobbyInfo = Session.Deserialize(order.TargetString);
						SetOrderLag(orderManager);
						Game.SyncLobbyInfo();
						break;
					}

				case "SyncLobbyClients":
					{
						var clients = new List<Session.Client>();
						var nodes = MiniYaml.FromString(order.TargetString);
						foreach (var node in nodes)
						{
							var strings = node.Key.Split('@');
开发者ID:Berzeger,项目名称:OpenRA,代码行数:67,代码来源:UnitOrders.cs

示例14: LobbyLogic

		internal LobbyLogic(Widget widget, WorldRenderer worldRenderer, OrderManager orderManager,
			Action onExit, Action onStart, bool skirmishMode, Ruleset modRules)
		{
			lobby = widget;
			this.orderManager = orderManager;
			this.onStart = onStart;
			this.onExit = onExit;
			this.skirmishMode = skirmishMode;
			this.modRules = modRules;
			shellmapWorld = worldRenderer.World;

			orderManager.AddChatLine += AddChatLine;
			Game.LobbyInfoChanged += UpdateCurrentMap;
			Game.LobbyInfoChanged += UpdatePlayerList;
			Game.BeforeGameStart += OnGameStart;
			Game.ConnectionStateChanged += ConnectionStateChanged;

			var name = lobby.GetOrNull<LabelWidget>("SERVER_NAME");
			if (name != null)
				name.GetText = () => orderManager.LobbyInfo.GlobalSettings.ServerName;

			Ui.LoadWidget("LOBBY_MAP_PREVIEW", lobby.Get("MAP_PREVIEW_ROOT"), new WidgetArgs
			{
				{ "orderManager", orderManager },
				{ "lobby", this }
			});

			UpdateCurrentMap();

			var playerBin = Ui.LoadWidget("LOBBY_PLAYER_BIN", lobby.Get("TOP_PANELS_ROOT"), new WidgetArgs());
			playerBin.IsVisible = () => panel == PanelType.Players;

			players = playerBin.Get<ScrollPanelWidget>("LOBBY_PLAYERS");
			editablePlayerTemplate = players.Get("TEMPLATE_EDITABLE_PLAYER");
			nonEditablePlayerTemplate = players.Get("TEMPLATE_NONEDITABLE_PLAYER");
			emptySlotTemplate = players.Get("TEMPLATE_EMPTY");
			editableSpectatorTemplate = players.Get("TEMPLATE_EDITABLE_SPECTATOR");
			nonEditableSpectatorTemplate = players.Get("TEMPLATE_NONEDITABLE_SPECTATOR");
			newSpectatorTemplate = players.Get("TEMPLATE_NEW_SPECTATOR");
			colorPreview = lobby.Get<ColorPreviewManagerWidget>("COLOR_MANAGER");
			colorPreview.Color = Game.Settings.Player.Color;

			foreach (var f in modRules.Actors["world"].TraitInfos<FactionInfo>())
				factions.Add(f.InternalName, new LobbyFaction { Selectable = f.Selectable, Name = f.Name, Side = f.Side, Description = f.Description });

			var gameStarting = false;
			Func<bool> configurationDisabled = () => !Game.IsHost || gameStarting ||
				panel == PanelType.Kick || panel == PanelType.ForceStart ||
				orderManager.LocalClient == null || orderManager.LocalClient.IsReady;

			var mapButton = lobby.GetOrNull<ButtonWidget>("CHANGEMAP_BUTTON");
			if (mapButton != null)
			{
				mapButton.IsDisabled = () => gameStarting || panel == PanelType.Kick || panel == PanelType.ForceStart ||
					orderManager.LocalClient == null || orderManager.LocalClient.IsReady;
				mapButton.OnClick = () =>
				{
					var onSelect = new Action<string>(uid =>
					{
						// Don't select the same map again
						if (uid == Map.Uid)
							return;

						orderManager.IssueOrder(Order.Command("map " + uid));
						Game.Settings.Server.Map = uid;
						Game.Settings.Save();
					});

					Ui.OpenWindow("MAPCHOOSER_PANEL", new WidgetArgs()
					{
						{ "initialMap", Map.Uid },
						{ "initialTab", MapClassification.System },
						{ "onExit", DoNothing },
						{ "onSelect", Game.IsHost ? onSelect : null },
						{ "filter", MapVisibility.Lobby },
					});
				};
			}

			var slotsButton = lobby.GetOrNull<DropDownButtonWidget>("SLOTS_DROPDOWNBUTTON");
			if (slotsButton != null)
			{
				slotsButton.IsDisabled = () => configurationDisabled() || panel != PanelType.Players ||
					Map.RuleStatus != MapRuleStatus.Cached || !orderManager.LobbyInfo.Slots.Values.Any(s => s.AllowBots || !s.LockTeam);

				var botNames = modRules.Actors["player"].TraitInfos<IBotInfo>().Select(t => t.Name);
				slotsButton.OnMouseDown = _ =>
				{
					var options = new Dictionary<string, IEnumerable<DropDownOption>>();

					var botController = orderManager.LobbyInfo.Clients.FirstOrDefault(c => c.IsAdmin);
					if (orderManager.LobbyInfo.Slots.Values.Any(s => s.AllowBots))
					{
						var botOptions = new List<DropDownOption>()
						{
							new DropDownOption()
							{
								Title = "Add",
								IsSelected = () => false,
								OnClick = () =>
//.........这里部分代码省略.........
开发者ID:Roger-luo,项目名称:OpenRA,代码行数:101,代码来源:LobbyLogic.cs

示例15: ProcessOrder


//.........这里部分代码省略.........
                            var launchCommand = replay != null ?
                                "Launch.Replay=" + replay.Filename :
                                "Launch.Connect=" + orderManager.Host + ":" + orderManager.Port;

                            Game.ModData.LoadScreen.Display();
                            Game.InitializeMod(request.Mod, new Arguments(launchCommand));

                            break;
                        }

                        Game.Settings.Player.Name = Settings.SanitizedPlayerName(Game.Settings.Player.Name);
                        Game.Settings.Save();

                        // Otherwise send the handshake with our current settings and let the server reject us
                        var info = new Session.Client()
                        {
                            Name = Game.Settings.Player.Name,
                            PreferredColor = Game.Settings.Player.Color,
                            Color = Game.Settings.Player.Color,
                            Faction = "Random",
                            SpawnPoint = 0,
                            Team = 0,
                            State = Session.ClientState.Invalid
                        };

                        var response = new HandshakeResponse()
                        {
                            Client = info,
                            Mod = mod.Id,
                            Version = mod.Metadata.Version,
                            Password = orderManager.Password
                        };

                        orderManager.IssueOrder(Order.HandshakeResponse(response.Serialize()));
                        break;
                    }

                case "ServerError":
                    {
                        orderManager.ServerError = order.TargetString;
                        orderManager.AuthenticationFailed = false;
                        break;
                    }

                case "AuthenticationError":
                    {
                        orderManager.ServerError = order.TargetString;
                        orderManager.AuthenticationFailed = true;
                        break;
                    }

                case "SyncInfo":
                    {
                        orderManager.LobbyInfo = Session.Deserialize(order.TargetString);
                        SetOrderLag(orderManager);
                        Game.SyncLobbyInfo();
                        break;
                    }

                case "SyncLobbyClients":
                    {
                        var clients = new List<Session.Client>();
                        var nodes = MiniYaml.FromString(order.TargetString);
                        foreach (var node in nodes)
                        {
                            var strings = node.Key.Split('@');
开发者ID:OpenRA,项目名称:OpenRA,代码行数:67,代码来源:UnitOrders.cs


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