1
This commit is contained in:
File diff suppressed because it is too large
Load Diff
@@ -1,7 +1,9 @@
|
||||
using Assets.MyGame.Scripts.Net;
|
||||
using Newtonsoft.Json;
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using TMPro;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
using static Assets.MyGame.Scripts.Net.WebResponses.ChineseChess.ChineseChessGameClassList;
|
||||
@@ -18,35 +20,49 @@ public class ChineseChessMainPanel : GameMainPanel_Base
|
||||
public Button btn_RenShu;
|
||||
public ChessGameRoom roomData;
|
||||
public static Dictionary<string,ChessGameRoom> dic_RoomData=new Dictionary<string, ChessGameRoom>();
|
||||
public Button btn_FanHuiDaTing;
|
||||
[Header("Bottom")]
|
||||
public TextMeshProUGUI tmp_Name_Bottom;
|
||||
public TextMeshProUGUI tmp_CoinCount_Bottom;
|
||||
public Image img_Title_Bottom;
|
||||
[Header("Top")]
|
||||
public TextMeshProUGUI tmp_Name_Top;
|
||||
public TextMeshProUGUI tmp_CoinCount_Top;
|
||||
public Image img_Title_Top;
|
||||
|
||||
public void StartGame(string msg)
|
||||
{
|
||||
|
||||
|
||||
|
||||
var va = JsonConvert.DeserializeObject<WebSocketResponseBase<ChessGameRoom>>(msg.ToString());
|
||||
ChessGameRoom chessGameRoom = va.arguments[0];
|
||||
//UpdateUserData(chessGameRoom);
|
||||
//这里要提前设置房间头像金币信息
|
||||
switch (chessGameRoom.users.Count)
|
||||
{
|
||||
case 1:
|
||||
{
|
||||
//等待加入 文字显示
|
||||
|
||||
tmp_Name_Top.text = "";
|
||||
tmp_CoinCount_Top.text = "金币:" + "";
|
||||
img_Title_Top.gameObject.SetActive(false);
|
||||
}
|
||||
break;
|
||||
case 2:
|
||||
{
|
||||
img_Title_Top.gameObject.SetActive(true);
|
||||
foreach (var item in chessGameRoom.users)
|
||||
{
|
||||
if (item.userId==GameManager.Instance.user.id)
|
||||
if (item.userId == GameManager.Instance.user.id)
|
||||
{
|
||||
if (item.type==2)
|
||||
if (item.type == 2)
|
||||
{
|
||||
subUIManager.ShowAsync(UIPanel.ZGXQSelectCoin,chessGameRoom);
|
||||
subUIManager.ShowAsync(UIPanel.ZGXQSelectCoin, chessGameRoom);
|
||||
}
|
||||
}
|
||||
}
|
||||
//subUIManager.ShowAsync(UIPanel.)
|
||||
|
||||
|
||||
}
|
||||
break;
|
||||
default:
|
||||
@@ -55,10 +71,39 @@ public class ChineseChessMainPanel : GameMainPanel_Base
|
||||
|
||||
|
||||
}
|
||||
|
||||
public void UpdateUserData(ChessGameRoom chessGameRoom)
|
||||
{
|
||||
foreach (var item in chessGameRoom.users)
|
||||
{
|
||||
if (item.userId == GameManager.Instance.user.id)
|
||||
{
|
||||
tmp_Name_Bottom.text = item.userName;
|
||||
tmp_CoinCount_Bottom.text = "金币:" + item.gold.ToString();
|
||||
StartCoroutine(item.DownTexture2d((t2d) =>
|
||||
{
|
||||
img_Title_Bottom.sprite = Sprite.Create(t2d, new Rect(0, 0, 100, 100), new Vector2(0.5f, 0.5f));
|
||||
}));
|
||||
}
|
||||
else
|
||||
{
|
||||
tmp_Name_Top.text = item.userName;
|
||||
tmp_CoinCount_Top.text = "金币:" + item.gold.ToString();
|
||||
StartCoroutine(item.DownTexture2d((t2d) =>
|
||||
{
|
||||
img_Title_Top.sprite = Sprite.Create(t2d, new Rect(0, 0, 100, 100), new Vector2(0.5f, 0.5f));
|
||||
}));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public override void Awake()
|
||||
{
|
||||
base.Awake();
|
||||
|
||||
btn_FanHuiDaTing.onClick.AddListener(() =>
|
||||
{
|
||||
UIManager.Instance.Close(UIPanel.MainGamePanelZGXQ);
|
||||
});
|
||||
}
|
||||
protected override void OnShow(object args = null)
|
||||
{
|
||||
@@ -89,12 +134,12 @@ public class ChineseChessMainPanel : GameMainPanel_Base
|
||||
});
|
||||
btn_RenShu.onClick.AddListener(() =>
|
||||
{
|
||||
WebSocketSendList.GameOperationChineseChess(roomData.roomId, 2, GameManager.Instance.user.id);
|
||||
//subUIManager.ShowAsync(UIPanel.ZGXQHint, new HintData
|
||||
//{
|
||||
// roomData = roomData,
|
||||
// hintType = 2
|
||||
//});
|
||||
//WebSocketSendList.GameOperationChineseChess(roomData.roomId, 2, GameManager.Instance.user.id);
|
||||
subUIManager.ShowAsync(UIPanel.ZGXQHint, new HintData
|
||||
{
|
||||
roomData = roomData,
|
||||
hintType = 2
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
@@ -105,6 +150,7 @@ public class ChineseChessMainPanel : GameMainPanel_Base
|
||||
protected override void OnHide()
|
||||
{
|
||||
base.OnHide();
|
||||
WebSocketManager.Instance.Close(SocketType.chess);
|
||||
Screen.orientation = ScreenOrientation.LandscapeLeft;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -113,7 +113,7 @@ public class UIChineseChessDistrict : SubUIBase
|
||||
string roomID= item.roomId;
|
||||
ChineseChessMainPanel.dic_RoomData[roomID] = item;
|
||||
|
||||
|
||||
|
||||
var tran=itemListDic[roomID];
|
||||
var slider = tran.transform.GetChild(1).GetComponent<Slider>();
|
||||
int allPlayerCount = item.users.Count;
|
||||
|
||||
@@ -41,6 +41,7 @@ public class UIChineseChessHint : SubUIBase
|
||||
}
|
||||
TongYi.onClick.AddListener(() =>
|
||||
{
|
||||
//WebSocketSendList.GameOperationChineseChess(v.roomData.roomId, 2, GameManager.Instance.user.id);
|
||||
WebSocketSendList.EndGameChineseChess(v.roomData.roomId,targetID);
|
||||
uIManager.Hide(UIPanel.ZGXQHint);
|
||||
});
|
||||
|
||||
@@ -16,11 +16,7 @@ public class UIChineseChessRoomExplain : SubUIBase
|
||||
public override void Awake()
|
||||
{
|
||||
|
||||
btn_Close.onClick.AddListener(() =>
|
||||
{
|
||||
uIManager.CloseAll();
|
||||
WebSocketSendList.GetRoomListChineseChess(1);
|
||||
});
|
||||
|
||||
}
|
||||
protected override void OnShow(object args = null)
|
||||
{
|
||||
@@ -38,6 +34,14 @@ public class UIChineseChessRoomExplain : SubUIBase
|
||||
WebSocketSendList.GameReadyChineseChess(v.roomId,GameManager.Instance.user.id);
|
||||
uIManager.Close(UIPanel.ZGXQGameExplain);
|
||||
});
|
||||
btn_Close.onClick.RemoveAllListeners();
|
||||
btn_Close.onClick.AddListener(() =>
|
||||
{
|
||||
uIManager.CloseAll();
|
||||
|
||||
WebSocketSendList.ExitRoomChineseChess(v.roomId, GameManager.Instance.user.id);
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user