新增请求方式

This commit is contained in:
mnjnhuang 2025-11-18 17:43:30 +08:00
parent 209795f075
commit 2d1098001c
4 changed files with 23 additions and 2 deletions

View File

@ -18,8 +18,8 @@ public enum EVENT_ENUM
public enum EVENT_METHODS // 事件方法
{
GET = 0, // 获取
GET = 1, // 获取
PUT = 3, // 修改
POST = 1, // 发送
POST = 0, // 默认发送, 不需要任何返回
DELETE = 2, // 删除
}

View File

@ -7,6 +7,7 @@ public struct EVENT_STRUCT
// ************** 系统数据结构 ****************
public struct STRUCT_EVENT_OS_DEAL_CARD
{
public EVENT_METHODS METHOD;
public int HAND_CARD_COUNT; // 手牌数量
public int DECK_CARD_COUNT; // 牌堆数量
public float DURATION; // 动画时长
@ -16,6 +17,7 @@ public struct EVENT_STRUCT
// ************** 卡牌数据结构 ****************
public struct STRUCT_EVENT_CARD_DRAW_CARD
{
public EVENT_METHODS METHOD;
public int ID;
public Vector3 POSITION;
public Quaternion ROTATION;
@ -26,6 +28,7 @@ public struct EVENT_STRUCT
public struct STRUCT_EVENT_CARD_DROP_CARD
{
public EVENT_METHODS METHOD;
public int ID;
public Vector3 POSITION;
public float DURATION;

View File

@ -117,6 +117,12 @@ public class Card : MonoBehaviour
void callback(EVENT_STRUCT.STRUCT_EVENT_CARD_DRAW_CARD args)
{
if (args.METHOD != EVENT_METHODS.POST)
{
Debug.LogError($"消息回调失败: [{args.GetType()}], 不允许的消息类型: {args.METHOD}");
return;
}
if (args.ID != ID) return; // 不接受其他ID的卡牌以及其他消息
Vector3 move_position = args.POSITION;
Quaternion rotation = args.ROTATION;
@ -152,6 +158,12 @@ public class Card : MonoBehaviour
void callback(EVENT_STRUCT.STRUCT_EVENT_CARD_DROP_CARD args)
{
if (args.METHOD != EVENT_METHODS.DELETE)
{
Debug.LogError($"消息回调失败: [{args.GetType()}], 不允许的消息类型: {args.METHOD}");
return;
}
if (args.ID != ID) return; // 不接受其他ID的卡牌以及其他消息
float duration_scale = args.DURATION / 3f;
float duration_move = args.DURATION - duration_scale;

View File

@ -42,6 +42,12 @@ public class TurnHandlerDealCard : MonoBehaviour
void callback(EVENT_STRUCT.STRUCT_EVENT_OS_DEAL_CARD args)
{
if (args.METHOD != EVENT_METHODS.POST)
{
Debug.LogError($"消息回调失败: [{args.GetType()}], 不允许的消息类型: {args.METHOD}");
return;
}
print("系统发牌");
int handCardCount = args.HAND_CARD_COUNT;
int deckCardCount = args.DECK_CARD_COUNT;