122 lines
4.6 KiB
C#
122 lines
4.6 KiB
C#
using Assets.MyGame.Scripts.Net;
|
|
using Assets.MyGame.Scripts.Net.WebResponses.ChineseChess;
|
|
using Newtonsoft.Json;
|
|
using System;
|
|
using Unity.VisualScripting;
|
|
|
|
public partial class WebSocketSendList
|
|
{
|
|
/// <summary>
|
|
/// 获取房间信息
|
|
/// </summary>
|
|
public static void GetRoomListFish(int leave,int district)
|
|
{
|
|
WebSocketManager.Instance.Send(SocketType.room, "{\"type\":1,\"target\":\"GetRoomList\",\"invocationId\":\"1\",\"arguments\":[\"" + GameManager.Instance.user.id + "\"," + (int)GameManager.Instance.gameData.currGameType + "," + leave + ","+ district + "]}");
|
|
}
|
|
|
|
/// <summary>
|
|
/// 打中鱼
|
|
/// </summary>
|
|
/// <param name="roomId"></param>
|
|
/// <param name="userId"></param>
|
|
/// <param name="fishNumber">配置id</param>
|
|
/// <param name="fishId">唯一id</param>
|
|
public static void KillFish(string roomId, string userId, string fishNumber, string fishId,int paoBei)
|
|
{
|
|
var sendObj = new WebSocketSendList("KillFish", roomId, userId, fishNumber, fishId, paoBei, DateTimeOffset.UtcNow.ToUnixTimeSeconds());
|
|
WebSocketManager.Instance.Send(SocketType.game, JsonConvert.SerializeObject(sendObj));
|
|
}
|
|
/// <summary>
|
|
/// 发射子弹
|
|
/// </summary>
|
|
/// <param name="roomId"></param>
|
|
/// <param name="userId"></param>
|
|
/// <param name="gold">单价</param>
|
|
/// <param name="count">数量</param>
|
|
public static void ShootBullet(string roomId, string userId, int gold, int count)
|
|
{
|
|
var sendObj = new WebSocketSendList("ShootBullet", roomId, userId, gold, count);
|
|
WebSocketManager.Instance.Send(SocketType.game, JsonConvert.SerializeObject(sendObj));
|
|
}
|
|
/// <summary>
|
|
/// 链接登录界面ws
|
|
/// </summary>
|
|
/// <param name="userId"></param>
|
|
public static void Bind(string userId)
|
|
{
|
|
var sendObj = new WebSocketSendList("Bind", userId);
|
|
WebSocketManager.Instance.Send(SocketType.login, JsonConvert.SerializeObject(sendObj));
|
|
}
|
|
/// <summary>
|
|
/// 加入房间
|
|
/// </summary>
|
|
/// <param name="roomId"></param>
|
|
/// <param name="userId"></param>
|
|
/// <param name="level">房间等级</param>
|
|
public static void JoinRoom(string roomId, string userId, int sitID)
|
|
{
|
|
var sendObj = new WebSocketSendList("JoinRoom", roomId, userId, sitID);
|
|
WebSocketManager.Instance.Send(SocketType.game, JsonConvert.SerializeObject(sendObj));
|
|
}
|
|
/// <summary>
|
|
/// 获取房间信息
|
|
/// </summary>
|
|
/// <param name="roomId">房间id</param>
|
|
public static void GetRoomInfo(string roomId)
|
|
{
|
|
var sendObj = new WebSocketSendList("GetRoomInfo", roomId);
|
|
WebSocketManager.Instance.Send(SocketType.room, JsonConvert.SerializeObject(sendObj));
|
|
}
|
|
/// <summary>
|
|
/// 使用道具
|
|
/// </summary>
|
|
/// <param name="roomId"></param>
|
|
/// <param name="userId"></param>
|
|
/// <param name="propNumber">道具id</param>
|
|
/// <param name="diamond">道具消耗</param>
|
|
public static void UseProp(string roomId, string userId, string propNumber, int diamond)
|
|
{
|
|
var sendObj = new WebSocketSendList("UseProp", roomId, userId, propNumber, diamond);
|
|
WebSocketManager.Instance.Send(SocketType.game, JsonConvert.SerializeObject(sendObj));
|
|
}
|
|
/// <summary>
|
|
/// 离开房间
|
|
/// </summary>
|
|
/// <param name="roomId"></param>
|
|
/// <param name="userId"></param>
|
|
public static void LeaveRoom(string roomId, string userId)
|
|
{
|
|
var sendObj = new WebSocketSendList("LeaveRoom", roomId, userId);
|
|
WebSocketManager.Instance.Send(SocketType.game, JsonConvert.SerializeObject(sendObj));
|
|
}
|
|
/// <summary>
|
|
/// 更改炮倍
|
|
/// </summary>
|
|
/// <param name="roomId"></param>
|
|
/// <param name="userId"></param>
|
|
/// <param name="multiple"></param>
|
|
public static void ChangeGunMultiple(string roomId, string userId,int multiple)
|
|
{
|
|
var sendObj = new WebSocketSendList("ChangeGunMultiple", roomId, userId, multiple);
|
|
WebSocketManager.Instance.Send(SocketType.game, JsonConvert.SerializeObject(sendObj));
|
|
}
|
|
|
|
/// <summary>
|
|
/// 数据同步
|
|
/// </summary>
|
|
public static void SyncGameData(object obj)
|
|
{
|
|
WebSocketSendList sendObj = new WebSocketSendList
|
|
{
|
|
type = 1,
|
|
invocationId = "1",
|
|
target = "SyncGameData",
|
|
arguments = new System.Collections.Generic.List<object>()
|
|
};
|
|
|
|
sendObj.arguments.Add(GameManager.Instance.gameData.currRoomData.roomId);
|
|
sendObj.arguments.Add(obj);
|
|
WebSocketManager.Instance.Send(SocketType.game, JsonConvert.SerializeObject(sendObj));
|
|
}
|
|
}
|