116 lines
3.4 KiB
C#
116 lines
3.4 KiB
C#
using System.Text;
|
|
using Logic.AI;
|
|
using MemoryPack;
|
|
using RuntimeData;
|
|
|
|
|
|
/*
|
|
* 房主开始游戏 -> 主端直接开始,广播所有客户端游戏开始,走从端开游戏逻辑
|
|
* 游戏开始后
|
|
* 回合结束回合开始都由主端进行广播
|
|
* 主端回合操作直接通过,广播操作行为,从端复刻
|
|
* 从端回合操作发往主端,主端验证完毕后广播操作行为,从端复刻
|
|
*/
|
|
namespace TH1_Logic.Steam
|
|
{
|
|
public enum P2PMsgType : byte
|
|
{
|
|
None = 0,
|
|
// 基础字符串消息
|
|
String = 1,
|
|
// 游戏开始 (房主 => 所有成员)
|
|
GameStart = 2,
|
|
// 请求行为 (成员 => 房主)
|
|
ActionConfirm = 3,
|
|
// 行为执行 (房主 => 所有成员)
|
|
ActionExcute = 4,
|
|
// 请求回合结束 (成员 => 房主)
|
|
TurnEnd = 5,
|
|
// 回合切换广播 (房主 => 所有成员)
|
|
TurnChange = 6,
|
|
// 游戏校验 (成员 => 房主)
|
|
MapConfirm = 7,
|
|
// 强制更新 (房主 => 所有成员)
|
|
ForceUpdate = 8,
|
|
}
|
|
|
|
|
|
[MemoryPackable]
|
|
[MemoryPackUnion(1, typeof(StringMessage))]
|
|
[MemoryPackUnion(2, typeof(GameStartMessage))]
|
|
[MemoryPackUnion(3, typeof(ActionConfirmMessage))]
|
|
[MemoryPackUnion(4, typeof(ActionExcuteMessage))]
|
|
[MemoryPackUnion(5, typeof(TurnEndMessage))]
|
|
[MemoryPackUnion(6, typeof(TurnChangeMessage))]
|
|
[MemoryPackUnion(7, typeof(MapConfirmMessage))]
|
|
[MemoryPackUnion(8, typeof(ForceUpdateMessage))]
|
|
public abstract partial class BaseMessage
|
|
{
|
|
public abstract P2PMsgType MessageType { get; }
|
|
}
|
|
|
|
|
|
[MemoryPackable]
|
|
public partial class StringMessage : BaseMessage
|
|
{
|
|
public override P2PMsgType MessageType => P2PMsgType.String;
|
|
public string Content { get; set; }
|
|
}
|
|
|
|
|
|
[MemoryPackable]
|
|
public partial class GameStartMessage : BaseMessage
|
|
{
|
|
public override P2PMsgType MessageType => P2PMsgType.GameStart;
|
|
public MapData MapData { get; set; }
|
|
}
|
|
|
|
|
|
[MemoryPackable]
|
|
public partial class ActionConfirmMessage : BaseMessage
|
|
{
|
|
public override P2PMsgType MessageType => P2PMsgType.ActionConfirm;
|
|
public ActionNetData ActionData { get; set; }
|
|
}
|
|
|
|
|
|
[MemoryPackable]
|
|
public partial class ActionExcuteMessage : BaseMessage
|
|
{
|
|
public override P2PMsgType MessageType => P2PMsgType.ActionExcute;
|
|
public ActionNetData ActionData { get; set; }
|
|
}
|
|
|
|
|
|
[MemoryPackable]
|
|
public partial class TurnEndMessage : BaseMessage
|
|
{
|
|
public override P2PMsgType MessageType => P2PMsgType.TurnEnd;
|
|
public uint PlayerId { get; set; }
|
|
}
|
|
|
|
|
|
[MemoryPackable]
|
|
public partial class TurnChangeMessage : BaseMessage
|
|
{
|
|
public override P2PMsgType MessageType => P2PMsgType.TurnChange;
|
|
public uint PlayerId { get; set; }
|
|
}
|
|
|
|
|
|
[MemoryPackable]
|
|
public partial class MapConfirmMessage : BaseMessage
|
|
{
|
|
public override P2PMsgType MessageType => P2PMsgType.MapConfirm;
|
|
public uint PlayerId { get; set; }
|
|
public ActionNetData ActionData { get; set; }
|
|
}
|
|
|
|
|
|
[MemoryPackable]
|
|
public partial class ForceUpdateMessage : BaseMessage
|
|
{
|
|
public override P2PMsgType MessageType => P2PMsgType.ForceUpdate;
|
|
public MapData MapData { get; set; }
|
|
}
|
|
} |