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


C# Network.OrderManager类代码示例

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


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

示例1: GameTimerLogic

		public GameTimerLogic(Widget widget, OrderManager orderManager, World world)
		{
			var timer = widget.GetOrNull<LabelWidget>("GAME_TIMER");
			if (timer != null)
				timer.GetText = () => WidgetUtils.FormatTime(world.WorldTick);

			var status = widget.GetOrNull<LabelWidget>("GAME_TIMER_STATUS");
			if (status != null)
			{
				var startTick = Ui.LastTickTime;
				// Blink the status line
				status.IsVisible = () => (world.Paused || world.Timestep != Game.Timestep)
					&& (Ui.LastTickTime - startTick) / 1000 % 2 == 0;

				status.GetText = () =>
				{
					if (world.Paused || world.Timestep == 0)
						return "Paused";

					if (world.Timestep == 1)
						return "Max Speed";

					return "{0:F1}x Speed".F(Game.Timestep * 1f / world.Timestep);
				};
			}
		}
开发者ID:Berzeger,项目名称:OpenRA,代码行数:26,代码来源:GameTimerLogic.cs

示例2: ConnectionStateChanged

		// Listen for connection failures
		void ConnectionStateChanged(OrderManager om)
		{
			if (om.Connection.ConnectionState == ConnectionState.NotConnected)
			{
				// Show connection failed dialog
				CloseWindow();

				Action onConnect = () =>
				{
					Game.OpenWindow("SERVER_LOBBY", new WidgetArgs()
					{
						{ "onExit", onExit },
						{ "onStart", onStart },
						{ "skirmishMode", false }
					});
				};

				Action<string> onRetry = password => ConnectionLogic.Connect(om.Host, om.Port, password, onConnect, onExit);

				Ui.OpenWindow("CONNECTIONFAILED_PANEL", new WidgetArgs()
				{
					{ "orderManager", om },
					{ "onAbort", onExit },
					{ "onRetry", onRetry }
				});
			}
		}
开发者ID:Roger-luo,项目名称:OpenRA,代码行数:28,代码来源:LobbyLogic.cs

示例3: 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

示例4: ShowColorDropDown

        public static void ShowColorDropDown(DropDownButtonWidget color, Session.Client client,
			OrderManager orderManager, ColorPickerPaletteModifier preview)
        {
            Action<ColorRamp> onSelect = c =>
            {
                if (client.Bot == null)
                {
                    Game.Settings.Player.ColorRamp = c;
                    Game.Settings.Save();
                }

                color.RemovePanel();
                orderManager.IssueOrder(Order.Command("color {0} {1}".F(client.Index, c)));
            };

            Action<ColorRamp> onChange = c => preview.Ramp = c;

            var colorChooser = Game.LoadWidget(orderManager.world, "COLOR_CHOOSER", null, new WidgetArgs()
            {
                { "onSelect", onSelect },
                { "onChange", onChange },
                { "initialRamp", client.ColorRamp }
            });

            color.AttachPanel(colorChooser);
        }
开发者ID:sonygod,项目名称:OpenRA-Dedicated-20120504,代码行数:26,代码来源:LobbyUtils.cs

示例5: 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.GetWidget<LabelWidget>("LABEL").GetText = () => o.Title;
                return item;
            };

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

示例6: ConnectionFailedLogic

        public ConnectionFailedLogic(Widget widget, OrderManager orderManager, Action onAbort, Action<string> onRetry)
        {
            var panel = widget;
            var abortButton = panel.Get<ButtonWidget>("ABORT_BUTTON");
            var retryButton = panel.Get<ButtonWidget>("RETRY_BUTTON");

            abortButton.Visible = onAbort != null;
            abortButton.OnClick = () => { Ui.CloseWindow(); onAbort(); };

            retryButton.Visible = onRetry != null;
            retryButton.OnClick = () =>
            {
                var password = passwordField != null && passwordField.IsVisible() ? passwordField.Text : orderManager.Password;

                Ui.CloseWindow();
                onRetry(password);
            };

            widget.Get<LabelWidget>("CONNECTING_DESC").GetText = () =>
                "Could not connect to {0}:{1}".F(orderManager.Host, orderManager.Port);

            var connectionError = widget.Get<LabelWidget>("CONNECTION_ERROR");
            connectionError.GetText = () => orderManager.ServerError;

            passwordField = panel.GetOrNull<PasswordFieldWidget>("PASSWORD");
            if (passwordField != null)
            {
                passwordField.Text = orderManager.Password;
                passwordField.IsVisible = () => orderManager.AuthenticationFailed;
                var passwordLabel = widget.Get<LabelWidget>("PASSWORD_LABEL");
                passwordLabel.IsVisible = passwordField.IsVisible;
                passwordField.OnEnterKey = () => { retryButton.OnClick(); return true; };
                passwordField.OnEscKey = () => { abortButton.OnClick(); return true; };
            }

            passwordOffsetAdjusted = false;
            var connectionFailedTicker = panel.GetOrNull<LogicTickerWidget>("CONNECTION_FAILED_TICKER");
            if (connectionFailedTicker != null)
            {
                connectionFailedTicker.OnTick = () =>
                {
                    // Adjust the dialog once the AuthenticationError is parsed.
                    if (passwordField.IsVisible() && !passwordOffsetAdjusted)
                    {
                        var offset = passwordField.Bounds.Y - connectionError.Bounds.Y;
                        abortButton.Bounds.Y += offset;
                        retryButton.Bounds.Y += offset;
                        panel.Bounds.Height += offset;
                        panel.Bounds.Y -= offset / 2;

                        var background = panel.GetOrNull("CONNECTION_BACKGROUND");
                        if (background != null)
                            background.Bounds.Height += offset;

                        passwordOffsetAdjusted = true;
                    }
                };
            }
        }
开发者ID:RobotCaleb,项目名称:OpenRA,代码行数:59,代码来源:ConnectionLogic.cs

示例7: RemoveHandlers

 public void RemoveHandlers(OrderManager orderManager)
 {
     if (!orderManager.GameStarted)
     {
         Game.ConnectionStateChanged -= RemoveHandlers;
         objectives.OnObjectivesUpdated -= UpdateObjectives;
     }
 }
开发者ID:nevelis,项目名称:OpenRA,代码行数:8,代码来源:MissionObjectivesLogic.cs

示例8: GameTimerLogic

        public GameTimerLogic(Widget widget, OrderManager orderManager, World world)
        {
            var timer = widget.GetOrNull<LabelWidget>("GAME_TIMER");
            var status = widget.GetOrNull<LabelWidget>("GAME_TIMER_STATUS");
            var startTick = Ui.LastTickTime;

            Func<bool> shouldShowStatus = () => (world.Paused || world.Timestep != world.LobbyInfo.GlobalSettings.Timestep)
                && (Ui.LastTickTime - startTick) / 1000 % 2 == 0;

            Func<string> statusText = () =>
            {
                if (world.Paused || world.Timestep == 0)
                    return "Paused";

                if (world.Timestep == 1)
                    return "Max Speed";

                return "{0}% Speed".F(world.LobbyInfo.GlobalSettings.Timestep * 100 / world.Timestep);
            };

            if (timer != null)
            {
                // Timers in replays should be synced to the effective game time, not the playback time.
                var timestep = world.Timestep;
                if (world.IsReplay)
                {
                    GameSpeed speed;
                    var gameSpeeds = Game.ModData.Manifest.Get<GameSpeeds>();
                    if (gameSpeeds.Speeds.TryGetValue(world.LobbyInfo.GlobalSettings.GameSpeedType, out speed))
                        timestep = speed.Timestep;
                }

                timer.GetText = () =>
                {
                    if (status == null && shouldShowStatus())
                        return statusText();

                    return WidgetUtils.FormatTime(world.WorldTick, timestep);
                };
            }

            if (status != null)
            {
                // Blink the status line
                status.IsVisible = shouldShowStatus;
                status.GetText = statusText;
            }

            var percentage = widget.GetOrNull<LabelWidget>("GAME_TIMER_PERCENTAGE");
            if (percentage != null)
            {
                var connection = orderManager.Connection as ReplayConnection;
                if (connection != null && connection.TickCount != 0)
                    percentage.GetText = () => "({0}%)".F(orderManager.NetFrameNumber * 100 / connection.TickCount);
                else if (timer != null)
                    timer.Bounds.Width += percentage.Bounds.Width;
            }
        }
开发者ID:CH4Code,项目名称:OpenRA,代码行数:58,代码来源:GameTimerLogic.cs

示例9: ConnectionFailedLogic

        public ConnectionFailedLogic(Widget widget, OrderManager orderManager, Action onRetry, Action onAbort)
        {
            var panel = widget;
            panel.Get<ButtonWidget>("ABORT_BUTTON").OnClick = () => { Ui.CloseWindow(); onAbort(); };
            panel.Get<ButtonWidget>("RETRY_BUTTON").OnClick = () => { Ui.CloseWindow(); onRetry(); };

            widget.Get<LabelWidget>("CONNECTING_DESC").GetText = () =>
                "Could not connect to {0}:{1}\n{2}".F(orderManager.Host, orderManager.Port, orderManager.ServerError);
        }
开发者ID:TiriliPiitPiit,项目名称:OpenRA,代码行数:9,代码来源:ConnectionLogic.cs

示例10: GetSpawnClients

 public static Dictionary<int2, Session.Client> GetSpawnClients(OrderManager orderManager, Map map)
 {
     var spawns = map.GetSpawnPoints();
     return orderManager.LobbyInfo.Clients
         .Where(c => c.SpawnPoint != 0)
             .ToDictionary(
                 c => spawns[c.SpawnPoint - 1],
                 c => c);
 }
开发者ID:Tsher,项目名称:OpenRA,代码行数:9,代码来源:LobbyUtils.cs

示例11: GetSpawnColors

 public static Dictionary<int2, Color> GetSpawnColors(OrderManager orderManager, Map map)
 {
     var spawns = map.GetSpawnPoints();
     return orderManager.LobbyInfo.Clients
         .Where( c => c.SpawnPoint != 0 )
         .ToDictionary(
             c => spawns[c.SpawnPoint - 1],
             c => c.ColorRamp.GetColor(0));
 }
开发者ID:sonygod,项目名称:OpenRA-Dedicated-20120504,代码行数:9,代码来源:LobbyUtils.cs

示例12: 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

示例13: BuildPaletteWidget

        public BuildPaletteWidget(OrderManager orderManager, World world, WorldRenderer worldRenderer)
        {
            this.orderManager = orderManager;
            this.world = world;
            this.worldRenderer = worldRenderer;

            cantBuild = new Animation(world, "clock");
            cantBuild.PlayFetchIndex("idle", () => 0);
            clock = new Animation(world, "clock");
            VisibleQueues = new List<ProductionQueue>();
            CurrentQueue = null;
        }
开发者ID:RunCraze,项目名称:OpenRA,代码行数:12,代码来源:BuildPaletteWidget.cs

示例14: GetExternalIP

        public static string GetExternalIP(int clientIndex, OrderManager orderManager)
        {
            var address = orderManager.LobbyInfo.ClientWithIndex(clientIndex).IpAddress;
            if (clientIndex == orderManager.LocalClient.Index && address == IPAddress.Loopback.ToString())
            {
                var externalIP = UPnP.GetExternalIP();
                if (externalIP != null)
                    address = externalIP.ToString();
            }

            return address;
        }
开发者ID:CH4Code,项目名称:OpenRA,代码行数:12,代码来源:LobbyUtils.cs

示例15: GameTimerLogic

        public GameTimerLogic(Widget widget, OrderManager orderManager, World world)
        {
            var timer = widget.GetOrNull<LabelWidget>("GAME_TIMER");
            var status = widget.GetOrNull<LabelWidget>("GAME_TIMER_STATUS");
            var startTick = Ui.LastTickTime;

            Func<bool> shouldShowStatus = () => (world.Paused || world.Timestep != world.LobbyInfo.GlobalSettings.Timestep)
                && (Ui.LastTickTime - startTick) / 1000 % 2 == 0;

            Func<string> statusText = () =>
            {
                if (world.Paused || world.Timestep == 0)
                    return "Paused";

                if (world.Timestep == 1)
                    return "Max Speed";

                return "{0}% Speed".F(world.LobbyInfo.GlobalSettings.Timestep * 100 / world.Timestep);
            };

            if (timer != null)
            {
                // Timers in replays should be synced to the effective game time, not the playback time.
                var timestep = world.Timestep;
                if (world.IsReplay)
                    timestep = world.WorldActor.Trait<MapOptions>().GameSpeed.Timestep;

                timer.GetText = () =>
                {
                    if (status == null && shouldShowStatus())
                        return statusText();

                    return WidgetUtils.FormatTime(world.WorldTick, timestep);
                };
            }

            if (status != null)
            {
                // Blink the status line
                status.IsVisible = shouldShowStatus;
                status.GetText = statusText;
            }

            var timerTooltip = timer as LabelWithTooltipWidget;
            if (timerTooltip != null)
            {
                var connection = orderManager.Connection as ReplayConnection;
                if (connection != null && connection.TickCount != 0)
                    timerTooltip.GetTooltipText = () => "{0}% complete".F(orderManager.NetFrameNumber * 100 / connection.TickCount);
                else
                    timerTooltip.GetTooltipText = null;
            }
        }
开发者ID:pchote,项目名称:OpenRA,代码行数:53,代码来源:GameTimerLogic.cs


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