/// <summary> /// 向所有的客户端发送命令 /// </summary> /// <param name="order">命令</param> public void TellClients(POrder order) { foreach (PClientCommander commander in CommanderList) { commander.Send(order); } if (CommanderList.Count > 0) { PThread.Delay(Config.SendDelay); } }
/// <summary> /// 向客户端发送命令 /// </summary> /// <param name="IPAddress">目标客户端的IP地址</param> /// <param name="order">命令</param> public void TellClient(string IPAddress, POrder order) { foreach (PClientCommander commander in CommanderList) { if (commander.RemoteIPAddress.Equals(IPAddress)) { commander.Send(order); break; } } PThread.Delay(Config.SendDelay); }
void Update() { lock (ActionWaitingList) { Queue <NamedAction> TempQueue = new Queue <NamedAction>(); while (ActionWaitingList.Count > 0) { NamedAction CurrentAction = ActionWaitingList.Dequeue(); try { if (CurrentAction != null) { if (CurrentAction.AnimationID > 0) { if (CurrentAnimationID > 0 && CurrentAnimationID != CurrentAction.AnimationID) { TempQueue.Enqueue(CurrentAction); continue; } //} else { // if (CurrentAnimationID == 0) { // WaitingAnimation.Remove(CurrentAction.AnimationID); // } // CurrentAnimationID = CurrentAction.AnimationID; //} } if (!CurrentAction.Name.Equals(string.Empty)) { // PLogger.Log("执行操作 " + CurrentAction.ToString()); } bool ActionCompleted = false; PThread.Async(() => { PThread.Delay(0.5f); if (!ActionCompleted) { PLogger.Log("操作异常:" + CurrentAction.ToString()); throw new TimeoutException("UI操作超时"); } }); CurrentAction.Action(); ActionCompleted = true; } } catch (Exception e) { PLogger.Log("操作 " + CurrentAction.ToString() + " 发生错误"); PLogger.Log(e.ToString()); } } while (TempQueue.Count > 0) { ActionWaitingList.Enqueue(TempQueue.Dequeue()); } } }
public void Open() { CameraThread = new Thread(() => { while (true) { if (IsTracking && !IsChangingPerspective) { PUIManager.AddNewUIAction(string.Empty, () => { Track(); }); } PThread.Delay(Config.CameraInterval); } }) { IsBackground = true }; CameraThread.Start(); }
public PBlock AskToChooseBlock(PPlayer Player, string Title, Predicate <PBlock> Condition = null) { PGame Game = PNetworkManager.NetworkServer.Game; PBlock Answer = null; Game.TagManager.CreateTag(new PChooseBlockTag(Player, null)); PNetworkManager.NetworkServer.TellClient(Player, new PShowInformationOrder(Title)); while (Answer == null) { PThread.WaitUntil(() => Game.TagManager.FindPeekTag <PChooseBlockTag>(PChooseBlockTag.TagName).Block != null); Answer = Game.TagManager.FindPeekTag <PChooseBlockTag>(PChooseBlockTag.TagName).Block; if (Condition != null && !Condition(Answer)) { Answer = null; PThread.Delay(0.2f); } } return(Game.TagManager.PopTag <PChooseBlockTag>(PChooseBlockTag.TagName).Block); }