diff --git a/VPet-Simulator.Core/Display/Main.xaml.cs b/VPet-Simulator.Core/Display/Main.xaml.cs index 46e911a..6ceb8e0 100644 --- a/VPet-Simulator.Core/Display/Main.xaml.cs +++ b/VPet-Simulator.Core/Display/Main.xaml.cs @@ -82,6 +82,9 @@ namespace VPet_Simulator.Core PetGrid2.Visibility = Visibility.Collapsed; Task.Run(() => { + EventTimer.Elapsed += (s, e) => EventTimer_Elapsed(); + MoveTimer.Elapsed += MoveTimer_Elapsed; + SmartMoveTimer.Elapsed += SmartMoveTimer_Elapsed; //while (!ig.IsReady) //{ // Thread.Sleep(100); @@ -111,10 +114,6 @@ namespace VPet_Simulator.Core DisplayNomal(); }); }); - - EventTimer.Elapsed += (s, e) => EventTimer_Elapsed(); - MoveTimer.Elapsed += MoveTimer_Elapsed; - SmartMoveTimer.Elapsed += SmartMoveTimer_Elapsed; } private void Labledisplaytimer_Elapsed(object sender, System.Timers.ElapsedEventArgs e) diff --git a/VPet-Simulator.Core/Display/ToolBar.xaml.cs b/VPet-Simulator.Core/Display/ToolBar.xaml.cs index 2c66419..26d511a 100644 --- a/VPet-Simulator.Core/Display/ToolBar.xaml.cs +++ b/VPet-Simulator.Core/Display/ToolBar.xaml.cs @@ -43,7 +43,7 @@ namespace VPet_Simulator.Core closePanelTimer = new Timer(); closePanelTimer.Elapsed += ClosePanelTimer_Tick; m.TimeUIHandle += M_TimeUIHandle; - LoadWork(); + //LoadWork(); } public void LoadClean() { diff --git a/VPet-Simulator.Windows/MutiPlayer/MPFriends.xaml.cs b/VPet-Simulator.Windows/MutiPlayer/MPFriends.xaml.cs index b3445d8..cdb2a71 100644 --- a/VPet-Simulator.Windows/MutiPlayer/MPFriends.xaml.cs +++ b/VPet-Simulator.Windows/MutiPlayer/MPFriends.xaml.cs @@ -314,13 +314,20 @@ public partial class MPFriends : WindowX /// public void Quit() { - Main.Display(GraphType.Shutdown, AnimatType.Single, () => Dispatcher.Invoke(Close)); - Task.Run(() => + try { - Thread.Sleep(5000); - if (Loaded) - Dispatcher.Invoke(Close); - }); + Main.Display(GraphType.Shutdown, AnimatType.Single, () => Dispatcher.Invoke(Close)); + Task.Run(() => + { + Thread.Sleep(5000); + if (Loaded) + Dispatcher.Invoke(Close); + }); + } + catch + { + Close(); + } } /// @@ -420,16 +427,20 @@ public partial class MPFriends : WindowX msg.Type = MSGType.Chat; msg.SetContent(new Chat() { Content = cont, ChatType = (Chat.Type)talktype, SendName = SteamClient.Name }); msg.To = SteamClient.SteamId; + switch (talktype) { case 0: wmp.SendMessage(friend.Id, msg); + mw.Main.Say("{0} 悄悄地对你说: {1}".Translate(SteamClient.Name, cont)); break; case 1: wmp.SendMessageALL(msg); + mw.Main.Say("{0} 对你说: {1}".Translate(SteamClient.Name, cont)); break; case 2: wmp.SendMessageALL(msg); + mw.Main.Say("{0} 对大家说: {1}".Translate(SteamClient.Name, cont)); break; } }); diff --git a/VPet-Simulator.Windows/MutiPlayer/winMutiPlayer.xaml.cs b/VPet-Simulator.Windows/MutiPlayer/winMutiPlayer.xaml.cs index 61d80ad..3b0688e 100644 --- a/VPet-Simulator.Windows/MutiPlayer/winMutiPlayer.xaml.cs +++ b/VPet-Simulator.Windows/MutiPlayer/winMutiPlayer.xaml.cs @@ -199,14 +199,18 @@ public partial class winMutiPlayer : Window } } } - + GraphInfo lastgraph = new GraphInfo() { Type = GraphType.Common }; private void Main_GraphDisplayHandler(GraphInfo info) { if (info.Type == GraphType.Shutdown || info.Type == GraphType.Common || info.Type == GraphType.Move - || info.Type == GraphType.Raised_Dynamic || info.Type == GraphType.Raised_Static || info.Type == GraphType.Default) + || info.Type == GraphType.Raised_Dynamic || info.Type == GraphType.Raised_Static) { return; } + //如果是同一个动画就不发送 + if (lastgraph.Type == info.Type && lastgraph.Animat == info.Animat && info.Name == lastgraph.Name) + return; + lastgraph = info; MPMessage msg = new MPMessage(); msg.Type = MSGType.DispayGraph; msg.SetContent(info); @@ -260,36 +264,35 @@ public partial class winMutiPlayer : Window } private void LoopP2PPacket() { - try - { - while (SteamNetworking.IsP2PPacketAvailable()) + while (isOPEN) + try { - var packet = SteamNetworking.ReadP2PPacket(); - if (packet.HasValue) + while (SteamNetworking.IsP2PPacketAvailable()) { - var From = packet.Value.SteamId; - var MSG = ConverTo(packet.Value.Data); - var To = MPFriends.Find(x => x.friend.Id == MSG.To); - switch (MSG.Type) + var packet = SteamNetworking.ReadP2PPacket(); + if (packet.HasValue) { - case MSGType.DispayGraph: - To.DisplayGraph(MSG.GetContent()); - break; - case MSGType.Chat: - To.DisplayMessage(MSG.GetContent()); - break; + var From = packet.Value.SteamId; + var MSG = ConverTo(packet.Value.Data); + var To = MPFriends.Find(x => x.friend.Id == MSG.To); + switch (MSG.Type) + { + case MSGType.DispayGraph: + To.DisplayGraph(MSG.GetContent()); + break; + case MSGType.Chat: + To.DisplayMessage(MSG.GetContent()); + break; + } } + Thread.Sleep(100); } - Thread.Sleep(100); + Thread.Sleep(1000); } - Thread.Sleep(1000); - if (isOPEN) - LoopP2PPacket(); - } - catch - { + catch + { - } + } } private void Window_Closed(object sender, EventArgs e) {