87 lines
2.2 KiB
C#
87 lines
2.2 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using Newtonsoft.Json;
|
|
|
|
namespace Com.Project.B.Lobby
|
|
{
|
|
/// <summary>
|
|
/// 大厅授权
|
|
/// </summary>
|
|
public enum LobbyAccessMode
|
|
{
|
|
/// <summary>
|
|
/// 私密大厅
|
|
/// </summary>
|
|
Private,
|
|
/// <summary>
|
|
/// 公开,可被搜索到
|
|
/// </summary>
|
|
Public,
|
|
/// <summary>
|
|
/// 仅好友可见
|
|
/// </summary>
|
|
FriendsOnly,
|
|
/// <summary>
|
|
/// 仅邀请可见
|
|
/// </summary>
|
|
InviteOnly,
|
|
/// <summary>
|
|
/// 好友和邀请
|
|
/// </summary>
|
|
FriendAndInvite,
|
|
}
|
|
/// <summary>
|
|
/// 大厅数据
|
|
/// </summary>
|
|
public interface ILobbyData
|
|
{
|
|
/// <summary>
|
|
/// 大厅ID,通常是玩家ID
|
|
/// </summary>
|
|
public Guid Id { get; }
|
|
/// <summary>
|
|
/// 开放模式
|
|
/// </summary>
|
|
LobbyAccessMode LobbyAccess { get; }
|
|
/// <summary>
|
|
/// 选择的场景
|
|
/// </summary>
|
|
public string Map { get; }
|
|
/// <summary>
|
|
/// 大厅名称
|
|
/// </summary>
|
|
public string Name { get; }
|
|
/// <summary>
|
|
/// 描述
|
|
/// </summary>
|
|
public string Description { get; }
|
|
/// <summary>
|
|
/// 主机ID,通常是玩家ID
|
|
/// </summary>
|
|
public Guid HostId { get; }
|
|
/// <summary>
|
|
/// 玩家ID
|
|
/// </summary>
|
|
public Guid[] PlayerIds { get; }
|
|
|
|
public bool Contain(Guid player);
|
|
}
|
|
public sealed class LobbyData:ILobbyData
|
|
{
|
|
public Guid Id { get; set; }
|
|
public LobbyAccessMode LobbyAccess { get; set; } = LobbyAccessMode.Public;
|
|
public string Map { get; set; }
|
|
public string Name { get; set; } = "Project B Lobby";
|
|
public string Description { get; set; }="Welcome";
|
|
public Guid HostId { get; set; }
|
|
[JsonIgnore]
|
|
Guid[] ILobbyData.PlayerIds=>Players.ToArray();
|
|
|
|
public bool Contain(Guid player)
|
|
{
|
|
return Players.Contains(player) || HostId == player;
|
|
}
|
|
|
|
public List<Guid> Players = new();
|
|
}
|
|
} |