2026-06-21 00:07:26 +08:00
|
|
|
using Assets.MyGame.Scripts.Net;
|
2026-03-09 09:25:01 +08:00
|
|
|
using Assets.MyGame.Scripts.Net.WebResponses;
|
2026-02-03 11:35:19 +08:00
|
|
|
using System;
|
2025-12-26 11:15:56 +08:00
|
|
|
using System.Collections;
|
2025-12-11 16:40:24 +08:00
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using UnityEngine;
|
2026-05-02 00:04:13 +08:00
|
|
|
using UnityEngine.Rendering.Universal;
|
2025-12-13 18:18:28 +08:00
|
|
|
using UnityEngine.UI;
|
2025-12-11 16:40:24 +08:00
|
|
|
|
2025-12-26 11:15:56 +08:00
|
|
|
public enum GameType
|
|
|
|
|
{
|
|
|
|
|
JQQD = 0,
|
2026-02-03 11:35:19 +08:00
|
|
|
defaultPanel =999,
|
2026-03-12 10:48:53 +08:00
|
|
|
FLZY = 1,
|
2026-05-07 03:46:03 +08:00
|
|
|
YYSC = 2,
|
2026-02-03 11:35:19 +08:00
|
|
|
ZGXQ = 3,
|
|
|
|
|
XJMH = 4,
|
|
|
|
|
HHWK = 5,
|
2025-12-26 11:15:56 +08:00
|
|
|
}
|
2025-12-11 16:40:24 +08:00
|
|
|
public class UIHome_BY_SelectRoomLevelPanel : SubUIBase
|
|
|
|
|
{
|
2026-03-09 09:25:01 +08:00
|
|
|
|
2025-12-26 11:15:56 +08:00
|
|
|
[Header("DefaultGame")]
|
2025-12-15 16:25:01 +08:00
|
|
|
[Header("快速进入")]
|
|
|
|
|
public Button SelectRoom1;
|
|
|
|
|
public Button SelectRoom2;
|
|
|
|
|
public Button SelectRoom3;
|
|
|
|
|
[Header("手动选择")]
|
2025-12-13 18:18:28 +08:00
|
|
|
public Button MySelectRoom1;
|
|
|
|
|
public Button MySelectRoom2;
|
|
|
|
|
public Button MySelectRoom3;
|
2026-05-01 06:26:50 +08:00
|
|
|
|
|
|
|
|
public GameObject ui_Default;
|
|
|
|
|
SelectGameLeave_DefaultUIItem currUIDefault;
|
2025-12-26 11:15:56 +08:00
|
|
|
public UIHome_BY_MySelectRoomPanel panel_UIHome_BY_MySelectRoomPenel;
|
|
|
|
|
public GameType currGameType;
|
2026-07-06 22:18:28 +08:00
|
|
|
public int leave = 1;
|
2026-03-09 09:25:01 +08:00
|
|
|
public bool isMySelectRoom=false;
|
2026-05-02 00:04:13 +08:00
|
|
|
public List<Camera> subCameras;
|
2026-06-11 19:37:56 +08:00
|
|
|
|
2026-07-08 20:49:22 +08:00
|
|
|
/// <summary>检查当前用户是否有手动选座权限</summary>
|
|
|
|
|
private bool CanSelectRoom()
|
|
|
|
|
{
|
|
|
|
|
var limit = GameManager.Instance?.gameConfig?.fishRoomConfig?.seatSelectLimit;
|
|
|
|
|
if (limit == null || limit.Count == 0) return true; // 没配限制,默认允许
|
|
|
|
|
|
|
|
|
|
// 用户身份:vipLevel > 0 → 1(VIP),否则 3(普通)
|
|
|
|
|
int userType = GameManager.Instance.user.assets.vipLevel > 0 ? 1 : 3;
|
|
|
|
|
return limit.Contains(userType);
|
|
|
|
|
}
|
|
|
|
|
|
2026-06-11 19:37:56 +08:00
|
|
|
|
2025-12-13 18:18:28 +08:00
|
|
|
public override void Awake()
|
2025-12-11 16:40:24 +08:00
|
|
|
{
|
2025-12-13 18:18:28 +08:00
|
|
|
base.Awake();
|
2026-05-02 00:04:13 +08:00
|
|
|
//foreach (var item in subCameras)
|
|
|
|
|
//{
|
|
|
|
|
// UniversalAdditionalCameraData mainCameraData = GameManager.Instance.ZhuCam.GetUniversalAdditionalCameraData();
|
|
|
|
|
// //mainCameraData.renderType = CameraRenderType.Overlay;
|
|
|
|
|
// mainCameraData.cameraStack.Add(item);
|
|
|
|
|
//}
|
2026-02-03 11:35:19 +08:00
|
|
|
WebSocketManager.Instance.Connect(SocketType.room);
|
2026-05-01 06:26:50 +08:00
|
|
|
|
2026-05-02 00:04:13 +08:00
|
|
|
|
2025-12-11 16:40:24 +08:00
|
|
|
}
|
2026-03-09 09:25:01 +08:00
|
|
|
public void OnSelectRoom(int leave)
|
2025-12-11 16:40:24 +08:00
|
|
|
{
|
2026-03-09 09:25:01 +08:00
|
|
|
//这里有问题 玩的人多了就不能完了
|
|
|
|
|
WebSocketSendList.GetRoomListFish(leave, 1);
|
2026-02-13 19:23:01 +08:00
|
|
|
//WebSocketManager.Instance.Send(SocketType.room, "{\"type\":1,\"target\":\"GetRoomList\",\"invocationId\":\"1\",\"arguments\":[\""+GameManager.Instance.user.id+"\","+(int)GameManager.Instance.gameData.currGameType+","+leave+",1]}");
|
2026-02-03 11:35:19 +08:00
|
|
|
//这里想websocket发送链接请求
|
|
|
|
|
//panel_UIHome_BY_MySelectRoomPenel.Show(json);
|
2025-12-11 16:40:24 +08:00
|
|
|
}
|
2026-03-09 09:25:01 +08:00
|
|
|
public static void StartGame(RoomChangeResponse o)
|
2025-12-15 16:25:01 +08:00
|
|
|
{
|
2026-02-03 11:35:19 +08:00
|
|
|
|
2026-03-09 09:25:01 +08:00
|
|
|
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;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
//这里写判断条件
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2025-12-15 16:25:01 +08:00
|
|
|
|
|
|
|
|
}
|
2025-12-26 11:15:56 +08:00
|
|
|
public override void Show(object args = null)
|
|
|
|
|
{
|
|
|
|
|
base.Show(args);
|
|
|
|
|
if (args != null && args is GameType)
|
|
|
|
|
{
|
|
|
|
|
currGameType = (GameType)args;
|
|
|
|
|
GameManager.Instance.gameData.currGameType = currGameType;
|
2026-06-16 02:28:58 +08:00
|
|
|
switch (currGameType)
|
|
|
|
|
{
|
|
|
|
|
case GameType.JQQD:
|
|
|
|
|
break;
|
|
|
|
|
case GameType.defaultPanel:
|
|
|
|
|
break;
|
|
|
|
|
case GameType.FLZY:
|
|
|
|
|
AudioManager.Instance.ChangeBG(62025);
|
|
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
case GameType.YYSC:
|
|
|
|
|
break;
|
|
|
|
|
case GameType.ZGXQ:
|
|
|
|
|
break;
|
|
|
|
|
case GameType.XJMH:
|
|
|
|
|
break;
|
|
|
|
|
case GameType.HHWK:
|
|
|
|
|
AudioManager.Instance.ChangeBG(61001);
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
break;
|
|
|
|
|
}
|
2025-12-26 11:15:56 +08:00
|
|
|
if (currGameType!= GameType.JQQD)
|
|
|
|
|
{
|
2026-05-01 06:26:50 +08:00
|
|
|
GameObject LV1 = SelectRoom1.transform.GetChild(((int)currGameType)).gameObject;
|
|
|
|
|
LV1.SetActive(true);
|
2026-05-02 00:04:13 +08:00
|
|
|
var Lv1Item = LV1.GetComponent<SeccionItem>();
|
2026-06-21 00:07:26 +08:00
|
|
|
if (Lv1Item.txt_VenueInfo != null) Lv1Item.txt_VenueInfo.text = "初级场";
|
2026-05-02 00:04:13 +08:00
|
|
|
MySelectRoom1 = Lv1Item.btn_SelectGameRoom;
|
2026-05-01 06:26:50 +08:00
|
|
|
MySelectRoom1.onClick.RemoveAllListeners();
|
|
|
|
|
GameObject LV2 = SelectRoom2.transform.GetChild(((int)currGameType) ).gameObject;
|
|
|
|
|
LV2.SetActive(true);
|
2026-05-02 00:04:13 +08:00
|
|
|
var Lv2Item = LV2.GetComponent<SeccionItem>();
|
2026-06-21 00:07:26 +08:00
|
|
|
if (Lv2Item.txt_VenueInfo != null) Lv2Item.txt_VenueInfo.text = "中级场";
|
2026-05-02 00:04:13 +08:00
|
|
|
MySelectRoom2 = Lv2Item.btn_SelectGameRoom;
|
2026-05-01 06:26:50 +08:00
|
|
|
MySelectRoom2.onClick.RemoveAllListeners();
|
|
|
|
|
GameObject LV3 = SelectRoom3.transform.GetChild(((int)currGameType)).gameObject;
|
|
|
|
|
LV3.SetActive(true);
|
2026-05-02 00:04:13 +08:00
|
|
|
|
|
|
|
|
var Lv3Item = LV3.GetComponent<SeccionItem>();
|
2026-06-21 00:07:26 +08:00
|
|
|
if (Lv3Item.txt_VenueInfo != null) Lv3Item.txt_VenueInfo.text = "高级场";
|
2026-05-02 00:04:13 +08:00
|
|
|
MySelectRoom3 = Lv3Item.btn_SelectGameRoom;
|
|
|
|
|
|
2026-06-21 00:07:26 +08:00
|
|
|
// 入场条件:从 RoomConfig 读取 roomGoldLimit
|
|
|
|
|
var gameConfig = GameManager.Instance?.gameConfig;
|
|
|
|
|
var roomConfigs = gameConfig?.roomConfigs;
|
|
|
|
|
if (roomConfigs != null && roomConfigs.Count > 0)
|
|
|
|
|
{
|
|
|
|
|
string gameTypeStr = ((int)currGameType).ToString();
|
|
|
|
|
var lv1Cfg = roomConfigs.Find(r => r.gameType.ToString() == gameTypeStr && r.roomLevel == 1);
|
|
|
|
|
var lv2Cfg = roomConfigs.Find(r => r.gameType.ToString() == gameTypeStr && r.roomLevel == 2);
|
|
|
|
|
var lv3Cfg = roomConfigs.Find(r => r.gameType.ToString() == gameTypeStr && r.roomLevel == 3);
|
|
|
|
|
if (lv1Cfg != null && Lv1Item.txt_EntryCondition != null)
|
|
|
|
|
Lv1Item.txt_EntryCondition.text = string.Format("入场: {0:N0} 金币", lv1Cfg.roomGoldLimit);
|
|
|
|
|
if (lv2Cfg != null && Lv2Item.txt_EntryCondition != null)
|
|
|
|
|
Lv2Item.txt_EntryCondition.text = string.Format("入场: {0:N0} 金币", lv2Cfg.roomGoldLimit);
|
|
|
|
|
if (lv3Cfg != null && Lv3Item.txt_EntryCondition != null)
|
|
|
|
|
Lv3Item.txt_EntryCondition.text = string.Format("入场: {0:N0} 金币", lv3Cfg.roomGoldLimit);
|
|
|
|
|
}
|
|
|
|
|
|
2026-05-02 00:04:13 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2026-05-01 06:26:50 +08:00
|
|
|
MySelectRoom1.onClick.AddListener(() =>
|
2025-12-26 11:15:56 +08:00
|
|
|
{
|
2026-07-08 20:49:22 +08:00
|
|
|
if (!CanSelectRoom()) { UIManager.Instance.ShowBoardError("无选座权限"); return; }
|
2026-05-01 06:26:50 +08:00
|
|
|
isMySelectRoom = true;
|
|
|
|
|
leave = 1;
|
|
|
|
|
OnSelectRoom(leave);
|
|
|
|
|
});
|
|
|
|
|
MySelectRoom2.onClick.AddListener(() =>
|
|
|
|
|
{
|
2026-07-08 20:49:22 +08:00
|
|
|
if (!CanSelectRoom()) { UIManager.Instance.ShowBoardError("无选座权限"); return; }
|
2026-05-01 06:26:50 +08:00
|
|
|
isMySelectRoom = true;
|
|
|
|
|
leave = 2;
|
|
|
|
|
OnSelectRoom(leave);
|
|
|
|
|
});
|
|
|
|
|
MySelectRoom3.onClick.AddListener(() =>
|
|
|
|
|
{
|
2026-07-08 20:49:22 +08:00
|
|
|
if (!CanSelectRoom()) { UIManager.Instance.ShowBoardError("无选座权限"); return; }
|
2026-05-01 06:26:50 +08:00
|
|
|
isMySelectRoom = true;
|
|
|
|
|
leave = 3;
|
|
|
|
|
OnSelectRoom(leave);
|
|
|
|
|
});
|
2026-05-02 00:04:13 +08:00
|
|
|
|
|
|
|
|
Lv1Item.btn_JoinGame.onClick.RemoveAllListeners();
|
|
|
|
|
Lv2Item.btn_JoinGame.onClick.RemoveAllListeners();
|
|
|
|
|
Lv3Item.btn_JoinGame.onClick.RemoveAllListeners();
|
|
|
|
|
Lv1Item.btn_JoinGame.onClick.AddListener(() =>
|
|
|
|
|
{
|
|
|
|
|
//StartGame(currGameType);
|
|
|
|
|
isMySelectRoom = false;
|
|
|
|
|
leave = 1;
|
|
|
|
|
OnSelectRoom(leave);
|
|
|
|
|
});
|
|
|
|
|
Lv2Item.btn_JoinGame.onClick.AddListener(() =>
|
|
|
|
|
{
|
|
|
|
|
isMySelectRoom = false;
|
|
|
|
|
leave = 2;
|
|
|
|
|
OnSelectRoom(leave);
|
|
|
|
|
});
|
|
|
|
|
Lv3Item.btn_JoinGame.onClick.AddListener(() =>
|
|
|
|
|
{
|
|
|
|
|
isMySelectRoom = false;
|
|
|
|
|
leave = 3;
|
|
|
|
|
OnSelectRoom(leave);
|
|
|
|
|
});
|
2026-05-01 06:26:50 +08:00
|
|
|
currUIDefault = ui_Default.transform.GetChild(((int)currGameType)).GetComponent<SelectGameLeave_DefaultUIItem>();
|
|
|
|
|
currUIDefault.gameObject.SetActive(true);
|
|
|
|
|
btn_Close = currUIDefault.btn_FanHui;
|
|
|
|
|
btn_Close.onClick.RemoveAllListeners();
|
|
|
|
|
btn_Close.onClick.AddListener(() =>
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
uIManager.Hide(this);
|
|
|
|
|
});
|
2026-06-21 22:38:18 +08:00
|
|
|
currUIDefault.btn_SheZhi.onClick.RemoveAllListeners();
|
|
|
|
|
currUIDefault.btn_SheZhi.onClick.AddListener(() =>
|
|
|
|
|
{
|
|
|
|
|
UIManager.Instance.Get<UIHomeMain>(UIPanel.HomeMainPanel).subUIManager.ShowAsync(UIPanel.SettingPanel);
|
|
|
|
|
});
|
|
|
|
|
|
2026-06-11 19:37:56 +08:00
|
|
|
currUIDefault.UpdateData(GameManager.Instance.user.BaseInfo.userName, GameManager.Instance.user.assets.gold.ToString(), GameManager.Instance.user.assets.diamond.ToString());
|
2026-07-06 02:08:18 +08:00
|
|
|
// 头像/头像框:初始加载 + 之后由事件自动刷新
|
2026-06-21 18:20:55 +08:00
|
|
|
GameManager.Instance.user.BaseInfo.UpdateAvatar((a) => { if (a != null) currUIDefault.sprite_Avatar.sprite = a; });
|
2026-07-06 02:08:18 +08:00
|
|
|
var frameSprite = GameManager.Instance.GetAvatarFrameSprite(GameManager.Instance.user.BaseInfo.avatarFrame);
|
|
|
|
|
if (currUIDefault.sprite_AvatarFrame != null && frameSprite != null)
|
|
|
|
|
currUIDefault.sprite_AvatarFrame.sprite = frameSprite;
|
2025-12-26 11:15:56 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
public override void Hide()
|
|
|
|
|
{
|
|
|
|
|
base.Hide();
|
2026-04-29 23:53:55 +08:00
|
|
|
AudioManager.Instance.ChangeBG(69001);
|
|
|
|
|
|
2026-04-23 17:24:31 +08:00
|
|
|
//img_BG.color = new Color(1,1,1,0);
|
2025-12-26 11:15:56 +08:00
|
|
|
if (currGameType != GameType.JQQD)
|
|
|
|
|
{
|
2026-05-01 06:26:50 +08:00
|
|
|
SelectRoom1.transform.GetChild((int)currGameType).gameObject.SetActive(false);
|
|
|
|
|
SelectRoom2.transform.GetChild((int)currGameType).gameObject.SetActive(false);
|
|
|
|
|
SelectRoom3.transform.GetChild((int)currGameType).gameObject.SetActive(false);
|
|
|
|
|
ui_Default.transform.GetChild((int)currGameType).gameObject.SetActive(false);
|
2025-12-26 11:15:56 +08:00
|
|
|
currGameType = GameType.JQQD;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
2026-06-21 00:07:26 +08:00
|
|
|
}
|