象棋基础
This commit is contained in:
@@ -22,8 +22,6 @@ namespace Assets.MyGame.Scripts.Net.WebResponses.ChineseChess
|
||||
/// 用户ID
|
||||
/// </summary>
|
||||
public string userId { get; set; }
|
||||
/// <summary>
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 游戏类型 1 我方黑 2 我方红
|
||||
@@ -61,7 +59,7 @@ namespace Assets.MyGame.Scripts.Net.WebResponses.ChineseChess
|
||||
public DateTime createTime { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 游戏类型 1 我方黑 2 我方红
|
||||
/// 游戏类型 1 房主黑 2 房主红
|
||||
/// </summary>
|
||||
public int gameType { get; set; }
|
||||
|
||||
|
||||
@@ -6,6 +6,7 @@ using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using UnityEngine;
|
||||
using static Assets.MyGame.Scripts.Net.WebResponses.ChineseChess.ChineseChessGameClassList;
|
||||
|
||||
namespace Assets.MyGame.Scripts.Net
|
||||
{
|
||||
@@ -39,14 +40,14 @@ namespace Assets.MyGame.Scripts.Net
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
#endregion
|
||||
|
||||
}
|
||||
private static void ChineseChess(string msg, WebSocketResponseBase<object> v)
|
||||
{
|
||||
|
||||
var roomMainPanel = UIManager.Instance.Get<ChineseChessMainPanel>(UIPanel.MainGamePanelZGXQ);
|
||||
switch ((MessageType)v.type)
|
||||
{
|
||||
case MessageType.Invocation:
|
||||
@@ -56,6 +57,85 @@ namespace Assets.MyGame.Scripts.Net
|
||||
UIManager.Instance.ShowAsync(UIPanel.MainGamePanelZGXQ, msg);
|
||||
Screen.orientation = ScreenOrientation.Portrait;
|
||||
break;
|
||||
case "BeginGame":
|
||||
|
||||
roomMainPanel.subUIManager.CloseAll();
|
||||
roomMainPanel.StartGame(msg);
|
||||
|
||||
break;
|
||||
case "CreateRoomNotice":
|
||||
{
|
||||
var va = JsonConvert.DeserializeObject<WebSocketResponseBase<ChessGameRoom>>(msg.ToString()).arguments[0];
|
||||
var panel = roomMainPanel.subUIManager.Get<UIChineseChessDistrict>(UIPanel.ZGXQDistrict);
|
||||
if (panel != null)
|
||||
{
|
||||
panel.UpdataRoom(va);
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
case "JoinRoomNotice":
|
||||
{
|
||||
var va = JsonConvert.DeserializeObject<WebSocketResponseBase<ChessGameRoom>>(msg.ToString()).arguments[0];
|
||||
var panel = roomMainPanel.subUIManager.Get<UIChineseChessDistrict>(UIPanel.ZGXQDistrict);
|
||||
if (panel != null)
|
||||
{
|
||||
panel.UpdataRoom(va);
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
//所有人
|
||||
case "GoldConfigRoomNotice":
|
||||
roomMainPanel.subUIManager.CloseAll();
|
||||
roomMainPanel.subUIManager.ShowAsync(UIPanel.ZGXQGameExplain, msg);
|
||||
|
||||
break;
|
||||
//单发给触发人
|
||||
case "GoldConfigSuccess":
|
||||
|
||||
break;
|
||||
case "ReadyNotice":
|
||||
//roomMainPanel.subUIManager.CloseAll();
|
||||
roomMainPanel.InitRoomData();
|
||||
break;
|
||||
case "GameOperation":
|
||||
{
|
||||
var va = JsonConvert.DeserializeObject<WebSocketResponseBase<Dictionary<string, object>>>(msg).arguments[0];
|
||||
roomMainPanel.IsShowHint(va["data"].ToString(), Convert.ToInt32(va["type"]));
|
||||
}
|
||||
|
||||
break;
|
||||
case "EndGameSuccess":
|
||||
{
|
||||
var va = JsonConvert.DeserializeObject<WebSocketResponseBase<string>>(msg).arguments[0];
|
||||
if (va == GameManager.Instance.user.id)
|
||||
{
|
||||
roomMainPanel.subUIManager.ShowAsync(UIPanel.ZGXQWin);
|
||||
}
|
||||
else
|
||||
{
|
||||
roomMainPanel.subUIManager.ShowAsync(UIPanel.ZGXQDefeated);
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case "ExitRoomNotice":
|
||||
{
|
||||
{
|
||||
var va = JsonConvert.DeserializeObject<WebSocketResponseBase<ChessGameRoom>>(msg.ToString()).arguments[0];
|
||||
var panel = roomMainPanel.subUIManager.Get<UIChineseChessDistrict>(UIPanel.ZGXQDistrict);
|
||||
if (panel != null)
|
||||
{
|
||||
panel.UpdataRoom(va);
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
case "Disconnect":
|
||||
roomMainPanel.subUIManager.ShowAsync(UIPanel.ZGXQWin);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -20,6 +20,11 @@ namespace Assets.MyGame.Scripts.Net
|
||||
{
|
||||
var var1 = UIManager.Instance.Show<UIChineseChessDistrict>(UIPanel.MainGamePanelZGXQ,msg);
|
||||
}
|
||||
public static void GetGoldConfigSuccessChineseChessResult(string msg)
|
||||
{
|
||||
UIManager.Instance.Get<ChineseChessMainPanel>(UIPanel.MainGamePanelZGXQ).subUIManager.ShowAsync(UIPanel.ZGXQGameExplain);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取房间列表 room
|
||||
/// </summary>
|
||||
|
||||
@@ -0,0 +1,40 @@
|
||||
using Assets.MyGame.Scripts.Net;
|
||||
using Assets.MyGame.Scripts.Net.WebResponses.ChineseChess;
|
||||
using Newtonsoft.Json;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
[Serializable]
|
||||
public partial class WebSocketSendList
|
||||
{
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// SignalR 消息类型,客户端调用服务器永远是 1
|
||||
/// </summary>
|
||||
public int type = 1;
|
||||
|
||||
/// <summary>
|
||||
/// 调用 ID(字符串也可以)
|
||||
/// 用来区分不同请求,可随便填
|
||||
/// </summary>
|
||||
public string invocationId;
|
||||
|
||||
/// <summary>
|
||||
/// 要调用的服务器方法名,例如:JoinRoom、KillFish、Fire
|
||||
/// </summary>
|
||||
public string target;
|
||||
|
||||
/// <summary>
|
||||
/// 参数数组(SignalR 要求必须是数组)
|
||||
/// </summary>
|
||||
public List<object> arguments;
|
||||
public WebSocketSendList(string target, params object[] param)
|
||||
{
|
||||
|
||||
invocationId = "1";
|
||||
this.target = target;
|
||||
arguments = param.ToList();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: b48ede6145c60ee4ab59b4bd2d35864c
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,35 @@
|
||||
using Assets.MyGame.Scripts.Net;
|
||||
using Assets.MyGame.Scripts.Net.WebResponses.ChineseChess;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
public partial class WebSocketSendList
|
||||
{
|
||||
public static void CreateRoomChineseChess(ChineseChessGameClassList.CreateRoomParam param)
|
||||
{
|
||||
WebSocketManager.Instance.Send(SocketType.chess, "{\"type\":1,\"target\":\"CreateRoom\",\"invocationId\":\"1\",\"arguments\":[" + JsonConvert.SerializeObject(param) + "]}");
|
||||
}
|
||||
public static void GetRoomListChineseChess(int district)
|
||||
{
|
||||
WebSocketManager.Instance.Send(SocketType.chess, "{\"type\":1,\"target\":\"GetRoomList\",\"invocationId\":\"1\",\"arguments\":[" + district + "]}");
|
||||
}
|
||||
public static void SelectGlodChineseChess(string roomId,int gold,string userId)
|
||||
{
|
||||
WebSocketManager.Instance.Send(SocketType.chess, "{\"type\":1,\"target\":\"GoldConfig\",\"invocationId\":\"1\",\"arguments\":[\"" + roomId+ "\"," + gold + ",\"" + userId+ "\"]}");
|
||||
}
|
||||
public static void JoinGameChineseChess(string roomId, string pwd, string userId)
|
||||
{
|
||||
WebSocketManager.Instance.Send(SocketType.chess, "{\"type\":1,\"target\":\"JoinGame\",\"invocationId\":\"1\",\"arguments\":[\"" + roomId + "\",\"" + pwd + "\",\"" + userId+ "\"]}");
|
||||
}
|
||||
public static void EndGameChineseChess(string roomId, string userId)
|
||||
{
|
||||
WebSocketManager.Instance.Send(SocketType.chess, "{\"type\":1,\"target\":\"EndGame\",\"invocationId\":\"1\",\"arguments\":[\"" + roomId + "\",\"" + userId + "\"]}");
|
||||
}
|
||||
public static void GameReadyChineseChess(string roomId, string userId)
|
||||
{
|
||||
WebSocketManager.Instance.Send(SocketType.chess, "{\"type\":1,\"target\":\"GameReady\",\"invocationId\":\"1\",\"arguments\":[\"" + roomId + "\",\"" + userId + "\"]}");
|
||||
}
|
||||
public static void GameOperationChineseChess(string roomId,int operateID, string userId)
|
||||
{
|
||||
WebSocketManager.Instance.Send(SocketType.chess, "{\"type\":1,\"target\":\"GameOperation\",\"invocationId\":\"1\",\"arguments\":[\"" + roomId + "\"," + operateID + ",\"" + userId + "\"]}");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 826f5d8ab548b23408757e4931fdafee
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
+1
-53
@@ -2,61 +2,9 @@
|
||||
using Assets.MyGame.Scripts.Net.WebResponses.ChineseChess;
|
||||
using Newtonsoft.Json;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
[Serializable]
|
||||
public class WebSocketSendList
|
||||
public partial class WebSocketSendList
|
||||
{
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// SignalR 消息类型,客户端调用服务器永远是 1
|
||||
/// </summary>
|
||||
public int type = 1;
|
||||
|
||||
/// <summary>
|
||||
/// 调用 ID(字符串也可以)
|
||||
/// 用来区分不同请求,可随便填
|
||||
/// </summary>
|
||||
public string invocationId;
|
||||
|
||||
/// <summary>
|
||||
/// 要调用的服务器方法名,例如:JoinRoom、KillFish、Fire
|
||||
/// </summary>
|
||||
public string target;
|
||||
|
||||
/// <summary>
|
||||
/// 参数数组(SignalR 要求必须是数组)
|
||||
/// </summary>
|
||||
public List<object> arguments;
|
||||
public WebSocketSendList(string target, params object[] param)
|
||||
{
|
||||
|
||||
invocationId = "1";
|
||||
this.target = target;
|
||||
arguments = param.ToList();
|
||||
}
|
||||
public static void GetRoomListChineseChess(int district)
|
||||
{
|
||||
WebSocketManager.Instance.Send(SocketType.chess, "{\"type\":1,\"target\":\"GetRoomList\",\"invocationId\":\"1\",\"arguments\":[" + district + "]}");
|
||||
}
|
||||
public static void SelectGlodChineseChess(string roomId,int gold,string userId)
|
||||
{
|
||||
WebSocketManager.Instance.Send(SocketType.chess, "{\"type\":1,\"target\":\"GoldConfig\",\"invocationId\":\"1\",\"arguments\":[" + roomId+","+ gold + ","+ userId+ "]}");
|
||||
}
|
||||
public static void CreateRoomChineseChess(ChineseChessGameClassList.CreateRoomParam param)
|
||||
{
|
||||
WebSocketManager.Instance.Send(SocketType.chess, "{\"type\":1,\"target\":\"CreateRoom\",\"invocationId\":\"1\",\"arguments\":[" + JsonConvert.SerializeObject(param) + "]}");
|
||||
}
|
||||
public static void JoinGameChineseChess(string roomId, string pwd, string userId)
|
||||
{
|
||||
WebSocketManager.Instance.Send(SocketType.chess, "{\"type\":1,\"target\":\"JoinGame\",\"invocationId\":\"1\",\"arguments\":[" +roomId + "," + pwd + "," + userId+ "]}");
|
||||
}
|
||||
public static void EndGameChineseChess(string roomId, string userId)
|
||||
{
|
||||
WebSocketManager.Instance.Send(SocketType.chess, "{\"type\":1,\"target\":\"EndGame\",\"invocationId\":\"1\",\"arguments\":[" + roomId + "," + userId + "]}");
|
||||
}
|
||||
/// <summary>
|
||||
/// 获取房间信息
|
||||
/// </summary>
|
||||
Reference in New Issue
Block a user