This commit is contained in:
2026-03-09 09:25:01 +08:00
parent 3dd5a9bf4e
commit e39164fed4
113 changed files with 5154 additions and 3828 deletions
+1 -1
View File
@@ -24,7 +24,7 @@ MonoBehaviour:
address: Assets/MyGame/aa/UI/Game/GameMainPanel_Default.prefab
- name: "\u661F\u9645\u8FF7\u822A"
type: 6
address: Assets/MyGame/aa/UI/Game/GameMainPanelXJMH.prefab
address: Assets/MyGame/aa/UI/Game/XJMH/GameMainPanelXJMH.prefab
- name: "\u4E2D\u56FD\u8C61\u68CB"
type: 5
address: Assets/MyGame/aa/UI/Game/ChineseChess/3GameMain.prefab
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);
});
}
}
File diff suppressed because it is too large Load Diff
@@ -2,7 +2,7 @@
using Assets.MyGame.Scripts.Net.API;
using Assets.MyGame.Scripts.Net.WebResponses;
using Newtonsoft.Json;
using Spine.Unity;
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
@@ -26,18 +26,34 @@ public class GameMainPanel_XJMH : GameMainPanel_Base
public Toggle toggle_Three;
bool isLock = false;
bool isThree = false;
MonsterContral monCotl_Lock;
//MonsterContral monCotl_Lock;
public GameObject LockFX;
public List<SitPosData> list_Sits = new List<SitPosData>();
public SitPosData currSitData;
int bulletCount = 0;
public void JoinGame(int sitNum, int goldNum, int consumeGlod, string currentTurretID, UserToken user = null)
public override void Awake()
{
base.Awake();
EventCenter.Instance.AddEventListener<SyncGameData>(ConstEventString.SyncGameData_Rotate, SyncGameData_Rotate);
EventCenter.Instance.AddEventListener<SyncGameData>(ConstEventString.SyncGameData_FireBullet, SyncGameData_FireBullit);
EventCenter.Instance.AddEventListener<SyncGameData>(ConstEventString.SyncGameData_ChangeTargetMonster, SyncGameData_ChangeTargetMonster);
}
private void OnDestroy()
{
EventCenter.Instance.RemoveEventListener<SyncGameData>(ConstEventString.SyncGameData_Rotate, SyncGameData_Rotate);
EventCenter.Instance.RemoveEventListener<SyncGameData>(ConstEventString.SyncGameData_FireBullet, SyncGameData_FireBullit);
EventCenter.Instance.RemoveEventListener<SyncGameData>(ConstEventString.SyncGameData_ChangeTargetMonster, SyncGameData_ChangeTargetMonster);
}
public void JoinGame(int sitNum, long goldNum, long consumeGlod, int currentTurretID, UserToken user = null)
{
foreach (var item in list_Sits)
{
if (item.posID == sitNum)
{
item.gameObject.SetActive(true);
@@ -49,7 +65,8 @@ public class GameMainPanel_XJMH : GameMainPanel_Base
item.goldNum = goldNum;
item.consumeGoldNum = consumeGlod;
item.tMP_GoldNum.text = goldNum.ToString();
item.currentTurretID = currentTurretID;
item.ChangeTurret(currentTurretID);
item.tMP_TurretConsumeNum.text = consumeGlod.ToString();
}
}
@@ -65,7 +82,6 @@ public class GameMainPanel_XJMH : GameMainPanel_Base
if (isOpenSetting)
{
StartCoroutine(CloseSettingList());
}
else
{
@@ -234,11 +250,14 @@ public class GameMainPanel_XJMH : GameMainPanel_Base
}
#endregion
foreach (var item in list_Sits)
{
}
if (isLock)
{
if (monCotl_Lock == null)
if (currSitData.monCotl_Lock == null)
{
CancelLock();
}
@@ -248,17 +267,47 @@ public class GameMainPanel_XJMH : GameMainPanel_Base
{
Vector2 worldPos = Camera.main.ScreenToWorldPoint(Touchscreen.current.primaryTouch.position.ReadValue());
RaycastHit2D hit = Physics2D.Raycast(worldPos, Vector2.zero, 50, LayerMask.GetMask("Fish"));
monCotl_Lock = hit.transform?.GetComponentInParent<MonsterContral>();
currSitData.monCotl_Lock = hit.transform?.GetComponentInParent<MonsterContral>();
if (monCotl_Lock != null && monCotl_Lock.gameObject.activeSelf) //这里为之后加对象池铺垫
if (currSitData.monCotl_Lock != null && currSitData.monCotl_Lock.gameObject.activeSelf) //这里为之后加对象池铺垫
{
foreach (BullitMove item in bulletParent.GetComponentsInChildren<BullitMove>())
{
item.Lock(monCotl_Lock);
item.Lock(currSitData.monCotl_Lock);
}
{
SyncGameData sgd = new SyncGameData
{
sitPos = currSitData.posID,
frameType = FrameDataType.changeAutoTarget,
frameData = new FrameData_ChangeAutoTarget
{
targetGuid = currSitData.monCotl_Lock.guid,
}
};
WebSocketSendList.SyncGameData(sgd);
}
if (!LockFX.activeSelf)
{
LockFX.SetActive(true);
{
SyncGameData sgd = new SyncGameData
{
sitPos = currSitData.posID,
frameType = FrameDataType.changeAutoTarget,
frameData = new FrameData_ChangeAutoTarget
{
targetGuid = currSitData.monCotl_Lock.guid,
}
};
WebSocketSendList.SyncGameData(sgd);
}
}
}
else
@@ -266,13 +315,13 @@ public class GameMainPanel_XJMH : GameMainPanel_Base
CancelLock();
}
}
if (monCotl_Lock != null)
if (currSitData.monCotl_Lock != null)
{
PaoTaRotate();
LockFX.transform.position = monCotl_Lock.transform.position;
SelfPaoTaRotate();
LockFX.transform.position = currSitData.monCotl_Lock.transform.position;
//FireBullit();
}
}
else
{
@@ -282,7 +331,7 @@ public class GameMainPanel_XJMH : GameMainPanel_Base
//FireBullit();
if (!isZD)
{
PaoTaRotate();
SelfPaoTaRotate();
}
}
@@ -295,7 +344,7 @@ public class GameMainPanel_XJMH : GameMainPanel_Base
if (isZD&&isLock==false)
{
PaoTaRotate();
SelfPaoTaRotate();
}
}
@@ -306,15 +355,15 @@ public class GameMainPanel_XJMH : GameMainPanel_Base
bulletCount = 0;
}
private void PaoTaRotate()
private void SelfPaoTaRotate()
{
#region 计算点击方向
Vector2 touchPos;
#region 计算点击方向
Vector2 touchPos;
// 获取触摸位置(屏幕坐标)
if (monCotl_Lock != null)
if (currSitData.monCotl_Lock != null)
{
touchPos = Camera.main.WorldToScreenPoint(monCotl_Lock.transform.position);
touchPos = Camera.main.WorldToScreenPoint(currSitData.monCotl_Lock.transform.position);
}
else
{
@@ -324,37 +373,193 @@ public class GameMainPanel_XJMH : GameMainPanel_Base
// 转换Canvas坐标
Vector2 worldPos;
RectTransformUtility.ScreenPointToLocalPointInRectangle(currSitData.tra_CurrTurret.transform.parent as RectTransform, touchPos, null, out worldPos);
// 计算方向
Vector2 dir = worldPos - currSitData.tra_CurrTurret.GetComponent<RectTransform>().anchoredPosition;
// 计算角度
float angle = Mathf.Atan2(dir.y, dir.x) * Mathf.Rad2Deg - 90f;
currSitData.tra_CurrTurret.transform.rotation = Quaternion.Euler(Vector3.forward * angle);
SetSitTurretRotame(currSitData,angle);
}
public void SyncGameData_Rotate(SyncGameData syncGameData)
{
if (syncGameData.sitPos!=currSitData.posID)
{
var rotateData = JsonConvert.DeserializeObject<FrameData_Rotate>(syncGameData.frameData.ToString());
SetSitTurretRotame(list_Sits[syncGameData.sitPos], rotateData.angle, false);
}
}
float frameTime=0;
//IEnumerator RotateIE(SitPosData sitPosData, Quaternion qua)
//{
// while (true)
// {
// yield return null;
// sitPosData.tra_CurrTurret.transform.rotation =Quaternion.Lerp(sitPosData.tra_CurrTurret.transform.rotation,qua,0.6f);
// }
//}
IEnumerator RotateIE_Angle(SitPosData sitPosData, Quaternion qua)
{
// 设置一个较小的阈值,判断是否旋转到位
float angleThreshold = 0.1f; // 当角度差小于0.1度时停止
while (true)
{
// 计算当前旋转和目标旋转之间的角度差
float angleDifference = Quaternion.Angle(sitPosData.tra_CurrTurret.transform.rotation, qua);
// 如果角度差很小,认为旋转完成
if (angleDifference <= angleThreshold)
{
// 强制设置最终旋转,避免微小误差
sitPosData.tra_CurrTurret.transform.rotation = qua;
break; // 退出循环
}
// 执行旋转插值
sitPosData.tra_CurrTurret.transform.rotation = Quaternion.Lerp(
sitPosData.tra_CurrTurret.transform.rotation,
qua,
0.6f // 这个系数决定了旋转速度
);
yield return null; // 等待下一帧
}
Debug.Log("旋转完成");
}
IEnumerator RotateIE_Time(SitPosData sitPosData, Quaternion qua)
{
float rotateDuration = 0.3f; // 旋转持续时间
float elapsedTime = 0f;
Quaternion startRotation = sitPosData.tra_CurrTurret.transform.rotation;
while (elapsedTime < rotateDuration)
{
elapsedTime += Time.deltaTime;
float t = elapsedTime / rotateDuration;
// 使用Slerp进行更平滑的球面插值
sitPosData.tra_CurrTurret.transform.rotation = Quaternion.Slerp(
startRotation,
qua,
t
);
yield return null;
}
// 确保最终旋转精确
sitPosData.tra_CurrTurret.transform.rotation = qua;
}
private Coroutine currentRotateCoroutine;
private void SetSitTurretRotame(SitPosData sitPosData,float angle, bool isSelf = true)
{
if (isSelf==false)
{
Vector3 v3 = Vector3.forward * angle;
// 如果已有协程在运行,先停止它
if (currentRotateCoroutine != null)
{
StopCoroutine(currentRotateCoroutine);
currentRotateCoroutine = null;
}
// 启动新的协程并保存引用
currentRotateCoroutine = StartCoroutine(RotateIE_Angle(sitPosData, Quaternion.Euler(v3)));
//StartCoroutine(RotateIE(sitPosData,));
return ;
}
else
{
sitPosData.tra_CurrTurret.transform.rotation = Quaternion.Euler(Vector3.forward * angle);
frameTime += Time.deltaTime;
if (frameTime > 0.1f)
{
{
SyncGameData sgd = new SyncGameData
{
sitPos = currSitData.posID,
frameType = FrameDataType.rotateTurrect,
frameData = new FrameData_Rotate
{
angle = angle,
}
};
WebSocketSendList.SyncGameData(sgd);
}
}
}
#endregion
clickTime += Time.deltaTime;
if (clickTime > attackTime)
{
clickTime = 0;
}
else
{
return;
}
FireBullit(angle);
FireBullit(currSitData,angle,isThree,isZD,isLock,isShuang);
{
SyncGameData sgd = new SyncGameData
{
sitPos = currSitData.posID,
frameType = FrameDataType.fireBullet,
frameData = new FrameData_FireBullit
{
angle = angle,
gold = currSitData.goldNum,
isSanShe = isThree,
twoRTruuect = isShuang,
isSuoDing = isLock,
auto = isZD
}
};
WebSocketSendList.SyncGameData(sgd);
}
}
private void CancelLock() { monCotl_Lock = null; LockFX.SetActive(false); }
private void FireBullit(float angle)
private void CancelLock() { currSitData.monCotl_Lock = null; LockFX.SetActive(false); }
public void SyncGameData_FireBullit(SyncGameData syncGameData)
{
if (syncGameData.sitPos != currSitData.posID)
{
var fireBullet = JsonConvert.DeserializeObject<FrameData_FireBullit>(syncGameData.frameData.ToString());
FireBullit(list_Sits[syncGameData.sitPos], fireBullet.angle, fireBullet.isSanShe, fireBullet.auto, fireBullet.isSuoDing, fireBullet.twoRTruuect, false);
}
}
public void SyncGameData_ChangeTargetMonster(SyncGameData syncGameData)
{
if (syncGameData.sitPos != currSitData.posID)
{
var fireBullet = JsonConvert.DeserializeObject<FrameData_ChangeAutoTarget>(syncGameData.frameData.ToString());
list_Sits[syncGameData.sitPos].monCotl_Lock = CreateFishManager.Instance.fishDatas_hashCodekey[fireBullet.targetGuid];
list_Sits[syncGameData.sitPos].isLock = true;
}
}
private void FireBullit(SitPosData sitPosData,float angle, bool isSanShe, bool auto, bool isSuoDing,bool twoRTruuect, bool isSelf=true)
{
//计算方向
Vector2 startV2;
startV2 = CoordinateTransformation.AnchoredPos_ToCanvas(currSitData.tra_CurrTurret.transform.GetChild(1).GetComponent<RectTransform>(), UIManager.Instance.uiRoot.GetComponent<Canvas>());
startV2 = CoordinateTransformation.AnchoredPos_ToCanvas(sitPosData.tra_CurrTurret.transform.GetChild(1).GetComponent<RectTransform>(), UIManager.Instance.uiRoot.GetComponent<Canvas>());
startV2 = CoordinateTransformation.CanvasToWorld(startV2, UIManager.Instance.uiRoot.GetComponent<RectTransform>(), Camera.main);
//Vector2 endV2 = touchPos;
@@ -363,24 +568,24 @@ public class GameMainPanel_XJMH : GameMainPanel_Base
//obj_CurrTurret.GetComponent<SkeletonAnimation>()
if (isThree)
if (isSanShe)
{
BullitMove bulletMove1 = CreateBullet(angle - 20, startV2);
BullitMove bulletMove2 = CreateBullet(angle, startV2);
BullitMove bulletMove3 = CreateBullet(angle + 20, startV2);
if (isLock)
BullitMove bulletMove1 = CreateBullet(angle - 20, startV2, sitPosData, Guid.NewGuid().ToString(), twoRTruuect);
BullitMove bulletMove2 = CreateBullet(angle, startV2, sitPosData, Guid.NewGuid().ToString(), twoRTruuect);
BullitMove bulletMove3 = CreateBullet(angle + 20, startV2, sitPosData, Guid.NewGuid().ToString(), twoRTruuect);
if (isSuoDing)
{
bulletMove1?.Lock(monCotl_Lock);
bulletMove2?.Lock(monCotl_Lock);
bulletMove3?.Lock(monCotl_Lock);
bulletMove1?.Lock(sitPosData.monCotl_Lock);
bulletMove2?.Lock(sitPosData.monCotl_Lock);
bulletMove3?.Lock(sitPosData.monCotl_Lock);
}
}
else
{
BullitMove bulletMove = CreateBullet(angle, startV2);
if (isLock)
BullitMove bulletMove = CreateBullet(angle, startV2, sitPosData, Guid.NewGuid().ToString(), twoRTruuect);
if (isSuoDing)
{
bulletMove?.Lock(monCotl_Lock);
bulletMove?.Lock(sitPosData.monCotl_Lock);
}
}
@@ -389,35 +594,37 @@ public class GameMainPanel_XJMH : GameMainPanel_Base
public Toggle toggle_Shuang;
bool isShuang= false;
private BullitMove CreateBullet(float angle, Vector2 startV2)
private BullitMove CreateBullet(float angle, Vector2 startV2, SitPosData roomJoinNotice,string guid,bool twoRTruuect)
{
GameObject bulletPrefab;
//这里有双倍炮台的需求
if (isShuang)
if (twoRTruuect)
{
bulletPrefab = currSitData.currentTurret.bulletPrefab_Two;
if (!currSitData.ConsumeGold(2))
bulletPrefab = roomJoinNotice.currentTurret.bulletPrefab_Two;
if (!roomJoinNotice.ConsumeGold(2))
{
return null;
}
}
else
{
bulletPrefab = currSitData.currentTurret.bulletPrefab;
if (!currSitData.ConsumeGold())
bulletPrefab = roomJoinNotice.currentTurret.bulletPrefab;
if (!roomJoinNotice.ConsumeGold())
{
return null;
}
}
var bulletMove = Instantiate(bulletPrefab, startV2, Quaternion.Euler(Vector3.forward * angle), bulletParent.transform).GetComponent<BullitMove>();
bulletMove.user = GameManager.Instance.gameData.roomJoinNotice;
bulletMove.playerID = GameManager.Instance.gameData.currUser;
currSitData.skeletonAnimation.AnimationState.SetAnimation(0, "shot", false);
bulletMove.user = roomJoinNotice.user;
bulletMove.playerID = roomJoinNotice.user.id;
bulletMove.bulletID= guid;
roomJoinNotice.skeletonAnimation.AnimationState.SetAnimation(0, "shot", false);
bulletCount++;
return bulletMove;
}
bool isfirstShow=false;
protected override void OnShow(object args = null)
{
base.OnShow(args);
@@ -425,11 +632,30 @@ public class GameMainPanel_XJMH : GameMainPanel_Base
var v = JsonConvert.DeserializeObject<WebSocketResponseBase<RoomJoinNotice>>(args.ToString());
if (v.arguments.Count > 0)
{
GameManager.Instance.gameData.roomJoinNotice = v.arguments[0];
RoomJoinNotice roomJoinNotice = v.arguments[0];
JoinGame(roomJoinNotice.position, roomJoinNotice.gold, roomJoinNotice.cannonMultiple, roomJoinNotice.cannonId);
currSitData = list_Sits[roomJoinNotice.position - 1];
currSitData.ChangeTurret(1);
if (isfirstShow == false)
{
foreach (var item in GameManager.Instance.gameData.currRoomData.players)
{
JoinGame(item.position, item.gold, item.cannonMultiple, 1);
}
GameManager.Instance.gameData.roomJoinNotice = v.arguments[0];
isfirstShow = true;
currSitData = list_Sits[roomJoinNotice.position];
//currSitData.ChangeTurret(1);
}
else
{
JoinGame(roomJoinNotice.position, roomJoinNotice.gold, roomJoinNotice.cannonMultiple, 1);
}
}
else
{
@@ -443,5 +669,7 @@ public class GameMainPanel_XJMH : GameMainPanel_Base
base.OnHide();
CreateFishManager.Instance.ExitRoom();
SceneManager.UnloadSceneAsync("XJMH");
WebSocketSendList.LeaveRoom(GameManager.Instance.gameData.currRoomData.roomId,currSitData.user.id);
}
}
@@ -5699,7 +5699,6 @@ RectTransform:
- {fileID: 4559688230590463030}
- {fileID: 928710527401417714}
- {fileID: 678913131303693655}
- {fileID: 1101226416299028320}
m_Father: {fileID: 0}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 0}
@@ -6189,147 +6188,3 @@ MonoBehaviour:
m_FillOrigin: 0
m_UseSpriteMesh: 0
m_PixelsPerUnitMultiplier: 1
--- !u!1001 &1690871251616316941
PrefabInstance:
m_ObjectHideFlags: 0
serializedVersion: 2
m_Modification:
serializedVersion: 3
m_TransformParent: {fileID: 3182697402847799673}
m_Modifications:
- target: {fileID: 1291800488841944919, guid: ad37004de2fb47f468b119a0b528ac78,
type: 3}
propertyPath: m_Name
value: 1District
objectReference: {fileID: 0}
- target: {fileID: 1445048545826174922, guid: ad37004de2fb47f468b119a0b528ac78,
type: 3}
propertyPath: m_IsActive
value: 1
objectReference: {fileID: 0}
- target: {fileID: 1747249211495485805, guid: ad37004de2fb47f468b119a0b528ac78,
type: 3}
propertyPath: m_Pivot.x
value: 0.5
objectReference: {fileID: 0}
- target: {fileID: 1747249211495485805, guid: ad37004de2fb47f468b119a0b528ac78,
type: 3}
propertyPath: m_Pivot.y
value: 0.5
objectReference: {fileID: 0}
- target: {fileID: 1747249211495485805, guid: ad37004de2fb47f468b119a0b528ac78,
type: 3}
propertyPath: m_AnchorMax.x
value: 0.5
objectReference: {fileID: 0}
- target: {fileID: 1747249211495485805, guid: ad37004de2fb47f468b119a0b528ac78,
type: 3}
propertyPath: m_AnchorMax.y
value: 0.5
objectReference: {fileID: 0}
- target: {fileID: 1747249211495485805, guid: ad37004de2fb47f468b119a0b528ac78,
type: 3}
propertyPath: m_AnchorMin.x
value: 0.5
objectReference: {fileID: 0}
- target: {fileID: 1747249211495485805, guid: ad37004de2fb47f468b119a0b528ac78,
type: 3}
propertyPath: m_AnchorMin.y
value: 0.5
objectReference: {fileID: 0}
- target: {fileID: 1747249211495485805, guid: ad37004de2fb47f468b119a0b528ac78,
type: 3}
propertyPath: m_SizeDelta.x
value: 582
objectReference: {fileID: 0}
- target: {fileID: 1747249211495485805, guid: ad37004de2fb47f468b119a0b528ac78,
type: 3}
propertyPath: m_SizeDelta.y
value: 1017
objectReference: {fileID: 0}
- target: {fileID: 1747249211495485805, guid: ad37004de2fb47f468b119a0b528ac78,
type: 3}
propertyPath: m_LocalPosition.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 1747249211495485805, guid: ad37004de2fb47f468b119a0b528ac78,
type: 3}
propertyPath: m_LocalPosition.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 1747249211495485805, guid: ad37004de2fb47f468b119a0b528ac78,
type: 3}
propertyPath: m_LocalPosition.z
value: 0
objectReference: {fileID: 0}
- target: {fileID: 1747249211495485805, guid: ad37004de2fb47f468b119a0b528ac78,
type: 3}
propertyPath: m_LocalRotation.w
value: 1
objectReference: {fileID: 0}
- target: {fileID: 1747249211495485805, guid: ad37004de2fb47f468b119a0b528ac78,
type: 3}
propertyPath: m_LocalRotation.x
value: -0
objectReference: {fileID: 0}
- target: {fileID: 1747249211495485805, guid: ad37004de2fb47f468b119a0b528ac78,
type: 3}
propertyPath: m_LocalRotation.y
value: -0
objectReference: {fileID: 0}
- target: {fileID: 1747249211495485805, guid: ad37004de2fb47f468b119a0b528ac78,
type: 3}
propertyPath: m_LocalRotation.z
value: -0
objectReference: {fileID: 0}
- target: {fileID: 1747249211495485805, guid: ad37004de2fb47f468b119a0b528ac78,
type: 3}
propertyPath: m_AnchoredPosition.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 1747249211495485805, guid: ad37004de2fb47f468b119a0b528ac78,
type: 3}
propertyPath: m_AnchoredPosition.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 1747249211495485805, guid: ad37004de2fb47f468b119a0b528ac78,
type: 3}
propertyPath: m_LocalEulerAnglesHint.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 1747249211495485805, guid: ad37004de2fb47f468b119a0b528ac78,
type: 3}
propertyPath: m_LocalEulerAnglesHint.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 1747249211495485805, guid: ad37004de2fb47f468b119a0b528ac78,
type: 3}
propertyPath: m_LocalEulerAnglesHint.z
value: 0
objectReference: {fileID: 0}
- target: {fileID: 3213656400481786378, guid: ad37004de2fb47f468b119a0b528ac78,
type: 3}
propertyPath: m_AnchorMax.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 3213656400481786378, guid: ad37004de2fb47f468b119a0b528ac78,
type: 3}
propertyPath: m_AnchorMax.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 7647910538216301643, guid: ad37004de2fb47f468b119a0b528ac78,
type: 3}
propertyPath: m_SizeDelta.y
value: 0
objectReference: {fileID: 0}
m_RemovedComponents: []
m_RemovedGameObjects: []
m_AddedGameObjects: []
m_AddedComponents: []
m_SourcePrefab: {fileID: 100100000, guid: ad37004de2fb47f468b119a0b528ac78, type: 3}
--- !u!224 &1101226416299028320 stripped
RectTransform:
m_CorrespondingSourceObject: {fileID: 1747249211495485805, guid: ad37004de2fb47f468b119a0b528ac78,
type: 3}
m_PrefabInstance: {fileID: 1690871251616316941}
m_PrefabAsset: {fileID: 0}
@@ -50,10 +50,10 @@ public class UIHome_BY_MySelectRoomPanel : SubUIBase
Hide();
});
panel_RoomItemPrefab.onClick.AddListener(() =>
{
GameManager.Instance.StartGame();
});
//panel_RoomItemPrefab.onClick.AddListener(() =>
//{
// GameManager.Instance.StartGame();
//});
}
private void Update()
{
@@ -67,7 +67,11 @@ public class UIHome_BY_MySelectRoomPanel : SubUIBase
public override void Show(object args = null)
{
base.Show(args);
foreach (var item in itemPage)
{
Destroy(item.gameObject);
}
itemPage.Clear();
text_PageNum.text = pageNum + "/" + itemPage.Count;
panel_PanelParent.SetActive(false);
if (args != null)
@@ -91,6 +95,10 @@ public class UIHome_BY_MySelectRoomPanel : SubUIBase
//itemListDic.Add Instantiate(panel_RoomItemPrefab, itemPage[(int)(i/15)-1]);
var tran = Instantiate(panel_RoomItemPrefab.gameObject, itemPage[(int)(i / 15)]).transform;
tran.GetComponent<Button>().onClick.AddListener(() =>
{
WebSocketSendList.GetRoomInfo(item.roomId);
});
tran.name = item.roomId;
itemListDic.Add(item.roomId, tran);
var slider = tran.transform.GetChild(1).GetComponent<Slider>();
@@ -1,4 +1,5 @@
using Assets.MyGame.Scripts.Net;
using Assets.MyGame.Scripts.Net.WebResponses;
using System;
using System.Collections;
using System.Collections.Generic;
@@ -24,6 +25,7 @@ public class BG_SelectRoom
}
public class UIHome_BY_SelectRoomLevelPanel : SubUIBase
{
[Header("DefaultGame")]
[Header("快速进入")]
public Button SelectRoom1;
@@ -38,50 +40,87 @@ public class UIHome_BY_SelectRoomLevelPanel : SubUIBase
public List<BG_SelectRoom> bG_SelectRooms=new List<BG_SelectRoom>();
public Image img_BG;
int leave = 1;
public bool isMySelectRoom=false;
public override void Awake()
{
base.Awake();
WebSocketManager.Instance.Connect(SocketType.room);
MySelectRoom1.onClick.AddListener(() =>
{
OnSelectRoom(currGameType);
isMySelectRoom=true;
leave = 1;
OnSelectRoom(leave);
});
MySelectRoom2.onClick.AddListener(() =>
{
OnSelectRoom(currGameType);
isMySelectRoom = true;
leave = 2;
OnSelectRoom(leave);
});
MySelectRoom3.onClick.AddListener(() =>
{
OnSelectRoom(currGameType);
isMySelectRoom=true;
leave = 3;
OnSelectRoom(leave);
});
SelectRoom1.onClick.AddListener(() =>
{
StartGame(currGameType);
//StartGame(currGameType);
isMySelectRoom = false;
leave = 1;
OnSelectRoom(leave);
});
SelectRoom2.onClick.AddListener(() =>
{
StartGame(currGameType);
isMySelectRoom = false;
leave = 2;
OnSelectRoom(leave);
});
SelectRoom3.onClick.AddListener(() =>
{
StartGame(currGameType);
isMySelectRoom = false;
leave = 3;
OnSelectRoom(leave);
});
}
public void OnSelectRoom(object json)
public void OnSelectRoom(int leave)
{
WebSocketSendList.GetRoomListFish(1,1);
//这里有问题 玩的人多了就不能完了
WebSocketSendList.GetRoomListFish(leave, 1);
//WebSocketManager.Instance.Send(SocketType.room, "{\"type\":1,\"target\":\"GetRoomList\",\"invocationId\":\"1\",\"arguments\":[\""+GameManager.Instance.user.id+"\","+(int)GameManager.Instance.gameData.currGameType+","+leave+",1]}");
//这里想websocket发送链接请求
//panel_UIHome_BY_MySelectRoomPenel.Show(json);
}
public void StartGame(object o)
public static void StartGame(RoomChangeResponse o)
{
//这里写判断条件
GameManager.Instance.StartGame();
Dictionary<int,bool> keyValuePairs = new Dictionary<int,bool>();
for (int i = 0; i < o.maxPlayerCount; i++)
{
keyValuePairs.Add(i, true);
}
foreach (var item in o.players)
{
keyValuePairs[item.position] = false;
}
foreach(var item in keyValuePairs)
{
if (item.Value)
{
GameManager.Instance.StartGame(() =>
{
WebSocketSendList.JoinRoom(o.roomId, GameManager.Instance.user.id, item.Key);
});
break;
}
}
//这里写判断条件
}
public override void Show(object args = null)