mirror of
https://github.com/EggLinks/DanhengServer-OpenSource.git
synced 2026-01-03 04:36:03 +08:00
39 lines
1.1 KiB
C#
39 lines
1.1 KiB
C#
using EggLink.DanhengServer.GameServer.Game.Lobby;
|
|
using EggLink.DanhengServer.GameServer.Game.MultiPlayer.MarbleGame;
|
|
using EggLink.DanhengServer.Proto;
|
|
|
|
namespace EggLink.DanhengServer.GameServer.Game.MultiPlayer;
|
|
|
|
public class MultiPlayerGameServerManager
|
|
{
|
|
public Dictionary<long, BaseMultiPlayerGameRoomInstance> Rooms { get; } = [];
|
|
public long CurRoomId { get; set; }
|
|
|
|
public BaseMultiPlayerGameRoomInstance? CreateRoom(LobbyRoomInstance lobbyRoom)
|
|
{
|
|
if (lobbyRoom.GameMode != FightGameMode.Marble) return null;
|
|
var roomId = ++CurRoomId;
|
|
var room = new MarbleGameRoomInstance(roomId, lobbyRoom);
|
|
Rooms.Add(roomId, room);
|
|
|
|
return room;
|
|
}
|
|
|
|
public void RemoveRoom(long roomId)
|
|
{
|
|
Rooms.Remove(roomId, out _);
|
|
}
|
|
|
|
public BaseMultiPlayerGameRoomInstance? GetPlayerJoinedRoom(int uid)
|
|
{
|
|
foreach (var room in Rooms.Values)
|
|
{
|
|
if (room.Players.Any(x => x.LobbyPlayer.Player.Uid == uid))
|
|
{
|
|
return room;
|
|
}
|
|
}
|
|
|
|
return null;
|
|
}
|
|
} |