1
This commit is contained in:
@@ -107,6 +107,14 @@ using Random = UnityEngine.Random;
|
||||
|
||||
public class GameMainPanel_FishBase : GameMainPanel_Base
|
||||
{
|
||||
[Header("离开游戏倒计时")]
|
||||
public GameObject obj_DJSPanel;
|
||||
public TextMeshProUGUI tmp_DJS; //确认(10)
|
||||
public Button btn_QueRen;
|
||||
public Button btn_QuXiao;
|
||||
/// <summary>是否正在退出倒计时(期间屏蔽帧同步和爆奖特效)</summary>
|
||||
private bool _isLeavingCountdown = false;
|
||||
private Coroutine _leaveCountdownCoroutine;
|
||||
[Header("游戏场景")]
|
||||
public string sceneName;
|
||||
public GameTypeEnum gameType;
|
||||
@@ -324,8 +332,7 @@ public class GameMainPanel_FishBase : GameMainPanel_Base
|
||||
btn_Setting.onClick.AddListener(() => {subUIManager.ShowAsync(UIPanel.SettingPanel); });
|
||||
btn_TuiChu.onClick.AddListener(() =>
|
||||
{
|
||||
WebSocketSendList.LeaveRoom(GameManager.Instance.gameData.currRoomData.roomId, currSitData.user);
|
||||
CreateFishManager.Instance.fangzhu = false;
|
||||
StartLeaveCountdown();
|
||||
});
|
||||
|
||||
// 服务器广播监听
|
||||
@@ -350,6 +357,64 @@ public class GameMainPanel_FishBase : GameMainPanel_Base
|
||||
});
|
||||
|
||||
}
|
||||
/// <summary>开始离开游戏倒计时:10秒倒计时期间屏蔽帧同步和爆奖特效,结束后点确认才退出</summary>
|
||||
public void StartLeaveCountdown()
|
||||
{
|
||||
if (_isLeavingCountdown) return;
|
||||
_isLeavingCountdown = true;
|
||||
if (obj_DJSPanel != null) obj_DJSPanel.SetActive(true);
|
||||
// 倒计时期间按钮禁用
|
||||
if (btn_QueRen != null) btn_QueRen.interactable = false;
|
||||
// 绑定按钮事件
|
||||
if (btn_QueRen != null)
|
||||
{
|
||||
btn_QueRen.onClick.RemoveAllListeners();
|
||||
btn_QueRen.onClick.AddListener(() =>
|
||||
{
|
||||
// 确认:直接退出房间
|
||||
WebSocketSendList.LeaveRoom(GameManager.Instance.gameData.currRoomData.roomId, currSitData.user);
|
||||
CreateFishManager.Instance.fangzhu = false;
|
||||
CancelLeaveCountdown();
|
||||
});
|
||||
}
|
||||
if (btn_QuXiao != null)
|
||||
{
|
||||
btn_QuXiao.onClick.RemoveAllListeners();
|
||||
btn_QuXiao.onClick.AddListener(CancelLeaveCountdown);
|
||||
}
|
||||
if (_leaveCountdownCoroutine != null) StopCoroutine(_leaveCountdownCoroutine);
|
||||
_leaveCountdownCoroutine = StartCoroutine(LeaveCountdownRoutine(10));
|
||||
}
|
||||
|
||||
/// <summary>是否正在离开倒计时</summary>
|
||||
public bool IsLeavingCountdown() => _isLeavingCountdown;
|
||||
|
||||
/// <summary>取消离开倒计时</summary>
|
||||
public void CancelLeaveCountdown()
|
||||
{
|
||||
_isLeavingCountdown = false;
|
||||
if (_leaveCountdownCoroutine != null)
|
||||
{
|
||||
StopCoroutine(_leaveCountdownCoroutine);
|
||||
_leaveCountdownCoroutine = null;
|
||||
}
|
||||
if (obj_DJSPanel != null) obj_DJSPanel.SetActive(false);
|
||||
}
|
||||
|
||||
private IEnumerator LeaveCountdownRoutine(int seconds)
|
||||
{
|
||||
int remaining = seconds;
|
||||
while (remaining > 0)
|
||||
{
|
||||
if (tmp_DJS != null) tmp_DJS.text = $"确认({remaining})";
|
||||
yield return new WaitForSeconds(1f);
|
||||
remaining--;
|
||||
}
|
||||
// 倒计时结束:按钮启用,文本显示"确认"
|
||||
if (tmp_DJS != null) tmp_DJS.text = "确认";
|
||||
if (btn_QueRen != null) btn_QueRen.interactable = true;
|
||||
}
|
||||
|
||||
public virtual void OnDestroy()
|
||||
{
|
||||
EventCenter.Instance.RemoveEventListener<SyncGameData>(ConstEventString.SyncGameData_Rotate, SyncGameData_Rotate);
|
||||
@@ -1675,6 +1740,7 @@ public class GameMainPanel_FishBase : GameMainPanel_Base
|
||||
#region ⑦ 服务器广播处理(NetReceiveModule)
|
||||
public void SyncGameData_Rotate(SyncGameData sync)
|
||||
{
|
||||
if (_isLeavingCountdown) return;
|
||||
if (sync.sitPos == currSitData.posID) return;
|
||||
|
||||
var data = FrameDataParser.Parse<FrameData_Rotate>(sync.frameData);
|
||||
@@ -1683,6 +1749,7 @@ public class GameMainPanel_FishBase : GameMainPanel_Base
|
||||
|
||||
public void SyncGameData_FireBullit(FireCannonSendData sync)
|
||||
{
|
||||
if (_isLeavingCountdown) return;
|
||||
// 机器人开火:extra 中可能没有完整 fireData,从 botLastFireData 还原
|
||||
if (sync.extra == null || sync.extra.frameData == null)
|
||||
{
|
||||
@@ -1715,6 +1782,7 @@ public class GameMainPanel_FishBase : GameMainPanel_Base
|
||||
/// </summary>
|
||||
public void SyncGameData_BotFireAngle(SyncGameData sync)
|
||||
{
|
||||
if (_isLeavingCountdown) return;
|
||||
if (sync == null || sync.frameData == null) return;
|
||||
if (sync.sitPos < 0 || sync.sitPos >= list_Sits.Count) return;
|
||||
|
||||
@@ -1730,6 +1798,7 @@ public class GameMainPanel_FishBase : GameMainPanel_Base
|
||||
|
||||
public void SyncGameData_ChangeTargetMonster(SyncGameData sync)
|
||||
{
|
||||
if (_isLeavingCountdown) return;
|
||||
if (sync.sitPos == currSitData.posID) return;
|
||||
|
||||
var data = FrameDataParser.Parse<FrameData_ChangeAutoTarget>(sync.frameData);
|
||||
@@ -1754,6 +1823,7 @@ public class GameMainPanel_FishBase : GameMainPanel_Base
|
||||
|
||||
public void SyncGameData_RendromDieFish(SyncGameData sync)
|
||||
{
|
||||
if (_isLeavingCountdown) return;
|
||||
var data = JsonConvert.DeserializeObject<FrameData_RandomDieFish>(sync.frameData.ToString());
|
||||
|
||||
CreateFishManager.Instance.Id_DieListFish_FX(
|
||||
@@ -1767,6 +1837,7 @@ public class GameMainPanel_FishBase : GameMainPanel_Base
|
||||
|
||||
public void SyncGameData_TurretState(SyncGameData sync)
|
||||
{
|
||||
if (_isLeavingCountdown) return;
|
||||
if (sync.sitPos == currSitData.posID) return;
|
||||
|
||||
var data = FrameDataParser.Parse<FrameData_TurretState>(sync.frameData);
|
||||
@@ -1777,6 +1848,7 @@ public class GameMainPanel_FishBase : GameMainPanel_Base
|
||||
|
||||
public void SyncGameData_ChangeTurret(SyncGameData sync)
|
||||
{
|
||||
if (_isLeavingCountdown) return;
|
||||
if (sync.sitPos == currSitData.posID) return;
|
||||
|
||||
var data = FrameDataParser.Parse<FrameData_ChangeTurret>(sync.frameData);
|
||||
@@ -1785,6 +1857,7 @@ public class GameMainPanel_FishBase : GameMainPanel_Base
|
||||
|
||||
public void SyncGameData_ChangeWing(SyncGameData sync)
|
||||
{
|
||||
if (_isLeavingCountdown) return;
|
||||
if (sync.sitPos == currSitData.posID) return;
|
||||
|
||||
var data = FrameDataParser.Parse<FrameData_ChangeTurret>(sync.frameData);
|
||||
@@ -1793,6 +1866,7 @@ public class GameMainPanel_FishBase : GameMainPanel_Base
|
||||
|
||||
public void SyncGameData_ChangeCannonMultiple(SyncGameData sync)
|
||||
{
|
||||
if (_isLeavingCountdown) return;
|
||||
if (sync.sitPos == currSitData.posID) return;
|
||||
|
||||
var data = FrameDataParser.Parse<FrameData_ChangeCannonMultiple>(sync.frameData);
|
||||
@@ -1816,6 +1890,7 @@ public class GameMainPanel_FishBase : GameMainPanel_Base
|
||||
|
||||
public void SyncGameData_FreezeFish(SyncGameData sync)
|
||||
{
|
||||
if (_isLeavingCountdown) return;
|
||||
if (sync.sitPos == currSitData.posID) return; // 自己发的不管
|
||||
|
||||
var data = FrameDataParser.Parse<FrameData_FreezeFish>(sync.frameData);
|
||||
|
||||
Reference in New Issue
Block a user