mirror of
https://github.com/LorisYounger/VPet.git
synced 2024-08-30 18:42:36 +00:00
多人游戏数据传输
This commit is contained in:
parent
2037ff22c8
commit
ea7088060f
@ -505,6 +505,10 @@ namespace VPet_Simulator.Core
|
|||||||
bool petgridcrlf = true;
|
bool petgridcrlf = true;
|
||||||
int nodisplayLoop = 0;
|
int nodisplayLoop = 0;
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
/// 显示过的动画
|
||||||
|
/// </summary>
|
||||||
|
public event Action<GraphInfo> GraphDisplayHandler;
|
||||||
|
/// <summary>
|
||||||
/// 显示动画 (自动多层切换)
|
/// 显示动画 (自动多层切换)
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="graph">动画</param>
|
/// <param name="graph">动画</param>
|
||||||
@ -540,6 +544,7 @@ namespace VPet_Simulator.Core
|
|||||||
// Dispatcher.Invoke(() => Say(graph.GraphType.ToString()));
|
// Dispatcher.Invoke(() => Say(graph.GraphType.ToString()));
|
||||||
//}
|
//}
|
||||||
DisplayType = graph.GraphInfo;
|
DisplayType = graph.GraphInfo;
|
||||||
|
GraphDisplayHandler?.Invoke(graph.GraphInfo);
|
||||||
var PetGridTag = Dispatcher.Invoke(() => PetGrid.Tag);
|
var PetGridTag = Dispatcher.Invoke(() => PetGrid.Tag);
|
||||||
var PetGrid2Tag = Dispatcher.Invoke(() => PetGrid2.Tag);
|
var PetGrid2Tag = Dispatcher.Invoke(() => PetGrid2.Tag);
|
||||||
if (PetGridTag == graph)
|
if (PetGridTag == graph)
|
||||||
@ -652,6 +657,9 @@ namespace VPet_Simulator.Core
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 显示夹层动画
|
/// 显示夹层动画
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
62
VPet-Simulator.Windows.Interface/MPMessage.cs
Normal file
62
VPet-Simulator.Windows.Interface/MPMessage.cs
Normal file
@ -0,0 +1,62 @@
|
|||||||
|
using LinePutScript;
|
||||||
|
using LinePutScript.Converter;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace VPet_Simulator.Windows.Interface;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 多人模式传输的消息
|
||||||
|
/// </summary>
|
||||||
|
public struct MPMessage
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 消息类型
|
||||||
|
/// </summary>
|
||||||
|
public enum MSGType
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 聊天消息 (string)
|
||||||
|
/// </summary>
|
||||||
|
Message,
|
||||||
|
/// <summary>
|
||||||
|
/// 显示动画 (graphinfo)
|
||||||
|
/// </summary>
|
||||||
|
DispayGraph,
|
||||||
|
/// <summary>
|
||||||
|
/// 摸身体
|
||||||
|
/// </summary>
|
||||||
|
TouchHead,
|
||||||
|
/// <summary>
|
||||||
|
/// 摸头
|
||||||
|
/// </summary>
|
||||||
|
TouchBody,
|
||||||
|
/// <summary>
|
||||||
|
/// 喂食
|
||||||
|
/// </summary>
|
||||||
|
Feed,
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// 消息类型
|
||||||
|
/// </summary>
|
||||||
|
public MSGType Type;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 消息内容
|
||||||
|
/// </summary>
|
||||||
|
public string Content;
|
||||||
|
/// <summary>
|
||||||
|
/// 操作来自者 (也可能是自己)
|
||||||
|
/// </summary>
|
||||||
|
public ulong From;
|
||||||
|
/// <summary>
|
||||||
|
/// 被操作者 (显示动画用)
|
||||||
|
/// </summary>
|
||||||
|
public ulong To;
|
||||||
|
|
||||||
|
public static string ConverTo(MPMessage data) => LPSConvert.SerializeObject(data).ToString();
|
||||||
|
public static MPMessage ConverTo(string data) => LPSConvert.DeserializeObject<MPMessage>(new LPS(data));
|
||||||
|
}
|
@ -5,7 +5,7 @@
|
|||||||
xmlns:ll="clr-namespace:LinePutScript.Localization.WPF;assembly=LinePutScript.Localization.WPF"
|
xmlns:ll="clr-namespace:LinePutScript.Localization.WPF;assembly=LinePutScript.Localization.WPF"
|
||||||
xmlns:pu="clr-namespace:Panuon.WPF.UI;assembly=Panuon.WPF.UI" Background="{x:Null}" WindowStyle="None"
|
xmlns:pu="clr-namespace:Panuon.WPF.UI;assembly=Panuon.WPF.UI" Background="{x:Null}" WindowStyle="None"
|
||||||
SizeToContent="Height" xmlns:local="clr-namespace:VPet_Simulator.Windows" mc:Ignorable="d" ShowInTaskbar="False"
|
SizeToContent="Height" xmlns:local="clr-namespace:VPet_Simulator.Windows" mc:Ignorable="d" ShowInTaskbar="False"
|
||||||
ResizeMode="NoResize" Title="MWFriends" Width="250" pu:WindowXCaption.Height="0">
|
ResizeMode="NoResize" Title="MWFriends" Width="250" pu:WindowXCaption.Height="0" Closed="WindowX_Closed">
|
||||||
<WindowChrome.WindowChrome>
|
<WindowChrome.WindowChrome>
|
||||||
<WindowChrome GlassFrameThickness="-1" />
|
<WindowChrome GlassFrameThickness="-1" />
|
||||||
</WindowChrome.WindowChrome>
|
</WindowChrome.WindowChrome>
|
||||||
|
@ -30,9 +30,10 @@ public partial class MPFriends : WindowX
|
|||||||
public Lobby lb;
|
public Lobby lb;
|
||||||
MainWindow mw;
|
MainWindow mw;
|
||||||
public Friend friend;
|
public Friend friend;
|
||||||
|
public winMutiPlayer wmp;
|
||||||
public GameCore Core { get; set; } = new GameCore();
|
public GameCore Core { get; set; } = new GameCore();
|
||||||
public List<Food> Foods { get; } = new List<Food>();
|
public List<Food> Foods { get; } = new List<Food>();
|
||||||
public ImageResources ImageSources { get; }
|
public ImageResources ImageSources { get; } = new ImageResources();
|
||||||
public List<PetLoader> Pets { get; set; } = new List<PetLoader>();
|
public List<PetLoader> Pets { get; set; } = new List<PetLoader>();
|
||||||
public ILine OnMod { get; set; }
|
public ILine OnMod { get; set; }
|
||||||
|
|
||||||
@ -44,8 +45,9 @@ public partial class MPFriends : WindowX
|
|||||||
return OnMod.Find(ModName.ToLower()) != null;
|
return OnMod.Find(ModName.ToLower()) != null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public MPFriends(MainWindow mw, Lobby lb, Friend friend)
|
public MPFriends(winMutiPlayer wmp, MainWindow mw, Lobby lb, Friend friend)
|
||||||
{
|
{
|
||||||
|
this.wmp = wmp;
|
||||||
this.mw = mw;
|
this.mw = mw;
|
||||||
this.lb = lb;
|
this.lb = lb;
|
||||||
this.friend = friend;
|
this.friend = friend;
|
||||||
@ -213,15 +215,6 @@ public partial class MPFriends : WindowX
|
|||||||
Main.PlayVoiceVolume = mw.Set.VoiceVolume;
|
Main.PlayVoiceVolume = mw.Set.VoiceVolume;
|
||||||
|
|
||||||
DisplayGrid.Child = Main;
|
DisplayGrid.Child = Main;
|
||||||
Task.Run(async () =>
|
|
||||||
{
|
|
||||||
while (Main.IsWorking)
|
|
||||||
{
|
|
||||||
Thread.Sleep(100);
|
|
||||||
}
|
|
||||||
await Dispatcher.InvokeAsync(() => LoadingText.Visibility = Visibility.Collapsed);
|
|
||||||
});
|
|
||||||
|
|
||||||
|
|
||||||
Main.SetMoveMode(mw.Set.AllowMove, mw.Set.SmartMove, mw.Set.SmartMoveInterval * 1000);
|
Main.SetMoveMode(mw.Set.AllowMove, mw.Set.SmartMove, mw.Set.SmartMoveInterval * 1000);
|
||||||
Main.SetLogicInterval(1500);
|
Main.SetLogicInterval(1500);
|
||||||
@ -239,8 +232,30 @@ public partial class MPFriends : WindowX
|
|||||||
new Point(pin[(gdbe)"px"], pin[(gdbe)"py"]), new Size(pin[(gdbe)"sw"], pin[(gdbe)"sh"])
|
new Point(pin[(gdbe)"px"], pin[(gdbe)"py"]), new Size(pin[(gdbe)"sw"], pin[(gdbe)"sh"])
|
||||||
, DisplayPinch, true));
|
, DisplayPinch, true));
|
||||||
}
|
}
|
||||||
|
SteamMatchmaking.OnLobbyMemberDataChanged += SteamMatchmaking_OnLobbyMemberDataChanged;
|
||||||
|
SteamMatchmaking.OnLobbyMemberLeave += SteamMatchmaking_OnLobbyMemberLeave;
|
||||||
|
Loaded = true;
|
||||||
|
|
||||||
|
LoadingText.Content = "{0}的{1}".Translate(friend.Name, Core.Save.Name);
|
||||||
|
LoadingText.Background = Function.ResourcesBrush(Function.BrushType.DARKPrimaryTransA);
|
||||||
|
LoadingText.VerticalAlignment = VerticalAlignment.Top;
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
public new bool Loaded = false;
|
||||||
|
private void SteamMatchmaking_OnLobbyMemberLeave(Lobby lobby, Friend friend)
|
||||||
|
{
|
||||||
|
if (lobby.Id == lb.Id && friend.Id == this.friend.Id)
|
||||||
|
Quit();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void SteamMatchmaking_OnLobbyMemberDataChanged(Lobby lobby, Friend friend)
|
||||||
|
{
|
||||||
|
if (lobby.Id == lb.Id && friend.Id == this.friend.Id)
|
||||||
|
{
|
||||||
|
Core.Save = GameSave_VPet.Load(new Line(lb.GetMemberData(friend, "save")));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 显示捏脸情况
|
/// 显示捏脸情况
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -297,4 +312,23 @@ public partial class MPFriends : WindowX
|
|||||||
Main.DisplayCEndtoNomal("pinch");
|
Main.DisplayCEndtoNomal("pinch");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void WindowX_Closed(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
wmp.MPFriends.Remove(this);
|
||||||
|
Loaded = false;
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// 播放关闭动画并关闭,如果10秒后还未关闭则强制关闭
|
||||||
|
/// </summary>
|
||||||
|
public void Quit()
|
||||||
|
{
|
||||||
|
Main.Display(GraphType.Shutdown, AnimatType.Single, () => Dispatcher.Invoke(Close));
|
||||||
|
Task.Run(() =>
|
||||||
|
{
|
||||||
|
Thread.Sleep(5000);
|
||||||
|
if (Loaded)
|
||||||
|
Dispatcher.Invoke(Close);
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,11 +1,23 @@
|
|||||||
<UserControl x:Class="VPet_Simulator.Windows.MPUserControl"
|
<Border x:Class="VPet_Simulator.Windows.MPUserControl" CornerRadius="5" BorderThickness="3"
|
||||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:pu="https://opensource.panuon.com/wpf-ui"
|
||||||
|
xmlns:ll="clr-namespace:LinePutScript.Localization.WPF;assembly=LinePutScript.Localization.WPF"
|
||||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:local="clr-namespace:VPet_Simulator.Windows"
|
||||||
xmlns:local="clr-namespace:VPet_Simulator.Windows"
|
mc:Ignorable="d" Margin="5" Width="360" Height="100" Background="{DynamicResource SecondaryLight}"
|
||||||
mc:Ignorable="d" Margin="5" Width="360" Height="200" >
|
BorderBrush="{DynamicResource Secondary}">
|
||||||
<Grid>
|
<Grid>
|
||||||
|
<Image x:Name="uimg" HorizontalAlignment="Left" Source="/Res/TopLogo2019.PNG" Margin="4" />
|
||||||
|
<TextBlock HorizontalAlignment="Left" VerticalAlignment="Center" Margin="110,0,0,0"
|
||||||
|
Foreground="{DynamicResource DARKPrimaryDarker}" FontSize="16">
|
||||||
|
<Run Text="{ll:Str 访客}" />: <Run x:Name="rPetName" Text="萝莉斯" FontSize="20" FontWeight="Bold" />
|
||||||
|
<LineBreak />
|
||||||
|
<Run Text="{ll:Str 来自}" />: <Run x:Name="hostName" Text="XXX" FontWeight="Bold" /><LineBreak />
|
||||||
|
<Run x:Name="info" Text="Lv 15" />
|
||||||
|
</TextBlock>
|
||||||
|
<Button Style="{DynamicResource ThemedButtonStyle}" HorizontalAlignment="Right" Content="{ll:Str 重置位置}"
|
||||||
|
VerticalAlignment="Top" Margin="10"/>
|
||||||
|
<Button Style="{DynamicResource ThemedButtonStyle}" HorizontalAlignment="Right" Content="{ll:Str 还没想好}"
|
||||||
|
VerticalAlignment="Bottom" Margin="10" />
|
||||||
</Grid>
|
</Grid>
|
||||||
</UserControl>
|
</Border>
|
||||||
|
@ -1,7 +1,10 @@
|
|||||||
using System;
|
using Steamworks;
|
||||||
|
using Steamworks.Data;
|
||||||
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
|
using System.Threading;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using System.Windows;
|
using System.Windows;
|
||||||
using System.Windows.Controls;
|
using System.Windows.Controls;
|
||||||
@ -11,16 +14,39 @@ using System.Windows.Input;
|
|||||||
using System.Windows.Media;
|
using System.Windows.Media;
|
||||||
using System.Windows.Media.Imaging;
|
using System.Windows.Media.Imaging;
|
||||||
using System.Windows.Navigation;
|
using System.Windows.Navigation;
|
||||||
using System.Windows.Shapes;
|
using VPet_Simulator.Windows.Interface;
|
||||||
|
|
||||||
namespace VPet_Simulator.Windows;
|
namespace VPet_Simulator.Windows;
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// MPUserControl.xaml 的交互逻辑
|
/// MPUserControl.xaml 的交互逻辑
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public partial class MPUserControl : UserControl
|
public partial class MPUserControl : Border
|
||||||
{
|
{
|
||||||
public MPUserControl()
|
Friend friend => mpf.friend;
|
||||||
|
winMutiPlayer wmp;
|
||||||
|
MPFriends mpf;
|
||||||
|
Lobby lb => mpf.lb;
|
||||||
|
public MPUserControl(winMutiPlayer wmp, MPFriends mpf)
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
|
this.wmp = wmp;
|
||||||
|
this.mpf = mpf;
|
||||||
|
Task.Run(LoadInfo);
|
||||||
|
}
|
||||||
|
public void LoadInfo()
|
||||||
|
{
|
||||||
|
//加载lobby传过来的数据
|
||||||
|
while (!mpf.Loaded)
|
||||||
|
{
|
||||||
|
Thread.Sleep(500);
|
||||||
|
}
|
||||||
|
Dispatcher.Invoke(async () =>
|
||||||
|
{
|
||||||
|
rPetName.Text = mpf.Core.Save.Name;
|
||||||
|
hostName.Text = friend.Name;
|
||||||
|
var img = await friend.GetMediumAvatarAsync();
|
||||||
|
uimg.Source = winMutiPlayer.ConvertToImageSource(img);
|
||||||
|
info.Text = "Lv " + mpf.Core.Save.Level;
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -12,7 +12,7 @@
|
|||||||
Source="/Res/TopLogo2019.PNG" />
|
Source="/Res/TopLogo2019.PNG" />
|
||||||
<TextBlock HorizontalAlignment="Left" VerticalAlignment="Top" Margin="120,20,0,0"
|
<TextBlock HorizontalAlignment="Left" VerticalAlignment="Top" Margin="120,20,0,0"
|
||||||
Foreground="{DynamicResource DARKPrimaryDarker}">
|
Foreground="{DynamicResource DARKPrimaryDarker}">
|
||||||
<Run Text="萝莉斯" FontSize="24" FontWeight="Bold" /> <Run Text="{ll:Str 的访客表}" />
|
<Run x:Name="hostPet" Text="萝莉斯" FontSize="24" FontWeight="Bold" /> <Run Text="{ll:Str 的访客表}" />
|
||||||
<LineBreak />
|
<LineBreak />
|
||||||
<Run Text="{ll:Str 主持人}" />: <Run x:Name="hostName" Text="XXX" /><LineBreak />
|
<Run Text="{ll:Str 主持人}" />: <Run x:Name="hostName" Text="XXX" /><LineBreak />
|
||||||
<Run Text="{ll:Str 访客表ID}" />:
|
<Run Text="{ll:Str 访客表ID}" />:
|
||||||
@ -22,7 +22,7 @@
|
|||||||
Foreground="{DynamicResource DARKPrimaryDarker}" Padding="0" />
|
Foreground="{DynamicResource DARKPrimaryDarker}" Padding="0" />
|
||||||
<TabControl x:Name="tabControl" HorizontalAlignment="Left" Margin="15,115,15,15">
|
<TabControl x:Name="tabControl" HorizontalAlignment="Left" Margin="15,115,15,15">
|
||||||
<TabItem Header="{ll:Str 访客列表}">
|
<TabItem Header="{ll:Str 访客列表}">
|
||||||
<StackPanel Background="{DynamicResource SecondaryLighter}" />
|
<StackPanel x:Name="MUUCList" Background="{DynamicResource SecondaryLighter}" />
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem Header="{ll:Str 消息日志}">
|
<TabItem Header="{ll:Str 消息日志}">
|
||||||
<TextBox x:Name="tbLog" Margin="0" BorderThickness="0" Background="{DynamicResource DARKPrimaryTrans4}"
|
<TextBox x:Name="tbLog" Margin="0" BorderThickness="0" Background="{DynamicResource DARKPrimaryTrans4}"
|
||||||
|
@ -1,13 +1,16 @@
|
|||||||
using LinePutScript;
|
using LinePutScript;
|
||||||
|
using LinePutScript.Converter;
|
||||||
using LinePutScript.Localization.WPF;
|
using LinePutScript.Localization.WPF;
|
||||||
using Panuon.WPF.UI;
|
using Panuon.WPF.UI;
|
||||||
using Steamworks;
|
using Steamworks;
|
||||||
using Steamworks.Data;
|
using Steamworks.Data;
|
||||||
|
using Steamworks.ServerList;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
|
using System.Threading;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using System.Windows;
|
using System.Windows;
|
||||||
using System.Windows.Controls;
|
using System.Windows.Controls;
|
||||||
@ -17,6 +20,8 @@ using System.Windows.Input;
|
|||||||
using System.Windows.Media;
|
using System.Windows.Media;
|
||||||
using System.Windows.Media.Imaging;
|
using System.Windows.Media.Imaging;
|
||||||
using System.Windows.Shapes;
|
using System.Windows.Shapes;
|
||||||
|
using VPet_Simulator.Core;
|
||||||
|
using VPet_Simulator.Windows.Interface;
|
||||||
|
|
||||||
namespace VPet_Simulator.Windows;
|
namespace VPet_Simulator.Windows;
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -29,7 +34,7 @@ public partial class winMutiPlayer : Window
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// 好友宠物模块
|
/// 好友宠物模块
|
||||||
/// </summary>
|
/// </summary>
|
||||||
List<MPFriends> mFriends = new List<MPFriends>();
|
public List<MPFriends> MPFriends = new List<MPFriends>();
|
||||||
public winMutiPlayer(MainWindow mw, ulong? lobbyid = null)
|
public winMutiPlayer(MainWindow mw, ulong? lobbyid = null)
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
@ -66,8 +71,13 @@ public partial class winMutiPlayer : Window
|
|||||||
swAllowJoin.Visibility = Visibility.Visible;
|
swAllowJoin.Visibility = Visibility.Visible;
|
||||||
ShowLobbyInfo();
|
ShowLobbyInfo();
|
||||||
}
|
}
|
||||||
public static BitmapFrame ConvertToImageSource(Steamworks.Data.Image image)
|
public static ImageSource ConvertToImageSource(Steamworks.Data.Image? img)
|
||||||
{
|
{
|
||||||
|
if (img == null)
|
||||||
|
{
|
||||||
|
return new BitmapImage(new Uri("pack://application:,,,/Res/vpeticon.png"));
|
||||||
|
}
|
||||||
|
var image = img.Value;
|
||||||
int stride = (int)((image.Width * 32 + 7) / 8); // 32 bits per pixel
|
int stride = (int)((image.Width * 32 + 7) / 8); // 32 bits per pixel
|
||||||
// Convert RGBA to BGRA
|
// Convert RGBA to BGRA
|
||||||
for (int i = 0; i < image.Data.Length; i += 4)
|
for (int i = 0; i < image.Data.Length; i += 4)
|
||||||
@ -103,19 +113,48 @@ public partial class winMutiPlayer : Window
|
|||||||
lb.SetMemberData("petgraph", mw.Set.PetGraph);
|
lb.SetMemberData("petgraph", mw.Set.PetGraph);
|
||||||
|
|
||||||
SteamMatchmaking.OnLobbyDataChanged += SteamMatchmaking_OnLobbyDataChanged;
|
SteamMatchmaking.OnLobbyDataChanged += SteamMatchmaking_OnLobbyDataChanged;
|
||||||
SteamMatchmaking.OnLobbyMemberDataChanged += SteamMatchmaking_OnLobbyMemberDataChanged;
|
|
||||||
SteamMatchmaking.OnLobbyMemberJoined += SteamMatchmaking_OnLobbyMemberJoined;
|
SteamMatchmaking.OnLobbyMemberJoined += SteamMatchmaking_OnLobbyMemberJoined;
|
||||||
hostName.Text = lb.Owner.Name;
|
hostName.Text = lb.Owner.Name;
|
||||||
lbLid.Text = lb.Id.Value.ToString("x");
|
lbLid.Text = lb.Id.Value.ToString("x");
|
||||||
Steamworks.Data.Image? img = await lb.Owner.GetMediumAvatarAsync();
|
Steamworks.Data.Image? img = await lb.Owner.GetMediumAvatarAsync();
|
||||||
if (img.HasValue)
|
|
||||||
{
|
|
||||||
HostHead.Source = ConvertToImageSource(img.Value);
|
HostHead.Source = ConvertToImageSource(img.Value);
|
||||||
}
|
|
||||||
else
|
//给自己动画添加绑定
|
||||||
|
mw.Main.GraphDisplayHandler += Main_GraphDisplayHandler;
|
||||||
|
if (lb.Owner.Id == SteamClient.SteamId)
|
||||||
{
|
{
|
||||||
HostHead.Source = new BitmapImage(new Uri("pack://application:,,,/Res/vpeticon.png"));
|
hostPet.Text = mw.GameSavesData.GameSave.Name;
|
||||||
|
Title = "{0}的访客表".Translate(mw.GameSavesData.GameSave.Name);
|
||||||
}
|
}
|
||||||
|
//获取成员列表
|
||||||
|
foreach (var v in lb.Members)
|
||||||
|
{
|
||||||
|
if (v.Id == SteamClient.SteamId) continue;
|
||||||
|
var mpf = new MPFriends(this, mw, lb, v);
|
||||||
|
MPFriends.Add(mpf);
|
||||||
|
mpf.Show();
|
||||||
|
var mpuc = new MPUserControl(this, mpf);
|
||||||
|
MUUCList.Children.Add(mpuc);
|
||||||
|
if (v.Id == lb.Owner.Id)
|
||||||
|
_ = Task.Run(() =>
|
||||||
|
{
|
||||||
|
//加载lobby传过来的数据
|
||||||
|
while (!mpf.Loaded)
|
||||||
|
{
|
||||||
|
Thread.Sleep(500);
|
||||||
|
}
|
||||||
|
Dispatcher.Invoke(() =>
|
||||||
|
{
|
||||||
|
Title = "{0}的访客表".Translate(mpf.Core.Save.Name);
|
||||||
|
hostPet.Text = mpf.Core.Save.Name;
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void Main_GraphDisplayHandler(GraphInfo info)
|
||||||
|
{
|
||||||
|
lb.SendChatString(MPMessage.ConverTo(new MPMessage() { Type = MPMessage.MSGType.DispayGraph, Content = LPSConvert.SerializeObject(info).ToString() }));
|
||||||
}
|
}
|
||||||
|
|
||||||
private void SteamMatchmaking_OnLobbyMemberJoined(Lobby lobby, Friend friend)
|
private void SteamMatchmaking_OnLobbyMemberJoined(Lobby lobby, Friend friend)
|
||||||
@ -146,11 +185,11 @@ public partial class winMutiPlayer : Window
|
|||||||
{
|
{
|
||||||
SteamMatchmaking.OnLobbyDataChanged -= SteamMatchmaking_OnLobbyDataChanged;
|
SteamMatchmaking.OnLobbyDataChanged -= SteamMatchmaking_OnLobbyDataChanged;
|
||||||
SteamMatchmaking.OnLobbyMemberDataChanged -= SteamMatchmaking_OnLobbyMemberDataChanged;
|
SteamMatchmaking.OnLobbyMemberDataChanged -= SteamMatchmaking_OnLobbyMemberDataChanged;
|
||||||
lb.SetMemberData("leave", DateTime.Now.ToString());
|
mw.Main.GraphDisplayHandler -= Main_GraphDisplayHandler;
|
||||||
lb.Leave();
|
lb.Leave();
|
||||||
foreach (var item in mFriends)
|
for (int i = 0; i < MPFriends.Count; i++)
|
||||||
{
|
{
|
||||||
item.Close();
|
MPFriends[i].Quit();
|
||||||
}
|
}
|
||||||
mw.winMutiPlayer = null;
|
mw.winMutiPlayer = null;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user