1
This commit is contained in:
@@ -319,6 +319,13 @@ public class GameMainPanel_FishBase : GameMainPanel_Base
|
||||
public ProgressBar JinDuTiao;
|
||||
#region UI
|
||||
bool isfirstShow = true;
|
||||
|
||||
/// <summary>加载到 100% 是否已完成(进房初始化/入场动画等需在加载完成后执行:玩家可见、位置就绪)</summary>
|
||||
public bool IsGameLoadCompleted { get; private set; }
|
||||
/// <summary>进房"首个初始化"(座位/房间信息)已挂起、等加载到 100% 后执行</summary>
|
||||
private bool _pendingFirstShowInit;
|
||||
/// <summary>挂起时保存的进房通知(ApplyFirstShowInit 里写入 gameData.roomJoinNotice)</summary>
|
||||
private RoomJoinNotice _pendingRoomJoinNotice;
|
||||
protected override void OnShow(object args = null)
|
||||
{
|
||||
base.OnShow(args);
|
||||
@@ -358,61 +365,10 @@ public class GameMainPanel_FishBase : GameMainPanel_Base
|
||||
}
|
||||
if (isfirstShow)
|
||||
{
|
||||
string roomId = GameManager.Instance.gameData.currRoomData.roomId;
|
||||
//string roomId = GameManager.Instance.gameData.currRoomData;
|
||||
|
||||
|
||||
foreach (var item in GameManager.Instance.gameData.currRoomData.players)
|
||||
{
|
||||
JoinGame(item.position, item.gold, item.diamond, item.cannonMultiple, 0, item.userId, item.cannonId, item.wingsId, item.warGodId);
|
||||
// ⭐ 优先用后端 isBot 字段,兼容 userId.StartsWith("bot_")
|
||||
var sit = list_Sits.Find(s => s.posID == item.position);
|
||||
if (sit != null)
|
||||
{
|
||||
bool isBot = item.isBot ||
|
||||
(!string.IsNullOrEmpty(item.userId) && item.userId.StartsWith("bot_"));
|
||||
if (isBot) sit.isBot = true;
|
||||
}
|
||||
}
|
||||
GameManager.Instance.gameData.roomJoinNotice = v.arguments[0];
|
||||
isfirstShow = false;
|
||||
|
||||
foreach (var item in list_Sits)
|
||||
{
|
||||
// ⭐ 座位镜像:本地玩家的显示座位 = 服务端座位转显示空间(上方座位翻转后落回下方)
|
||||
if (item.posID == SeatMirror.ToDisplay(roomJoinNotice.Position))
|
||||
{
|
||||
currSitData = item;
|
||||
// ⭐ 长按本地座位的 img_OpenPT 开关炮台面板(与 btn_ChangeTurret 同逻辑)
|
||||
HookOpenPTLongPress(currSitData);
|
||||
// ⭐ 本地座位自动攻击关闭时广播 Idle 状态给其他客户端
|
||||
HookAutoAttackOff(currSitData);
|
||||
}
|
||||
else
|
||||
{
|
||||
// ⭐ 非本地座位隐藏加减炮倍:Normal 藏座位按钮(未拖引用为 null 跳过),
|
||||
// XJMH 藏炮台上的加减倍(TurretData.obj_Add / obj_Down)
|
||||
item.HideTurretAddMinusUI();
|
||||
// ⭐ 自动攻击开关与加减倍按钮一样:非本地座位隐藏
|
||||
if (item.toggle_AutoAttack != null)
|
||||
item.toggle_AutoAttack.gameObject.SetActive(false);
|
||||
}
|
||||
|
||||
}
|
||||
//// currSitData.ChangeTurret(1); — 已由 SitPosData.OnEnable 自动加载
|
||||
if (currSitData.currentTurret != null)
|
||||
SyncChangeTurret(currSitData.currentTurret.turretNumber);
|
||||
currSitData.lockFX.transform.GetChild(0).gameObject.SetActive(false);
|
||||
currSitData.lockFX.transform.GetChild(1).gameObject.SetActive(true);
|
||||
if (mySitAnim != null && currSitData.turretParent != null)
|
||||
{
|
||||
// ⭐ 座位位置 + 左右座位各自的偏移:把"我在这"圆圈摆到座位上面
|
||||
// (左右座位镜像后需要的偏移不一样,分左/右两套配置,面板上调)
|
||||
Vector3 sitAnimOffset = IsLeftSeat(currSitData) ? mySitAnimOffsetLeft : mySitAnimOffsetRight;
|
||||
mySitAnim.transform.position = currSitData.turretParent.position + sitAnimOffset;
|
||||
// ⭐ 进入游戏圆圈:6 秒后自动消失(点击屏幕立即消失的逻辑在 HandleInput)
|
||||
StartCoroutine(HideMySitAnimAfter(6f));
|
||||
}
|
||||
// ⭐ 座位/房间信息初始化推迟到"加载到 100%"后执行(见 ApplyFirstShowInit 与加载完成点):
|
||||
// 原来在这里立即 JoinGame/摆座位,进房入场动画会在加载期播放——玩家看不到、位置未就绪。
|
||||
_pendingFirstShowInit = true;
|
||||
_pendingRoomJoinNotice = roomJoinNotice;
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -454,6 +410,72 @@ public class GameMainPanel_FishBase : GameMainPanel_Base
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 进房首个初始化(座位/房间信息):原 OnShow 里 isfirstShow 的整段逻辑(原样搬入),
|
||||
/// 现由"加载到 100%"的加载完成点调用——保证入场动画等在玩家可见、位置就绪后才初始化/播放。
|
||||
/// </summary>
|
||||
private void ApplyFirstShowInit()
|
||||
{
|
||||
RoomJoinNotice roomJoinNotice = _pendingRoomJoinNotice;
|
||||
if (roomJoinNotice == null) return;
|
||||
|
||||
string roomId = GameManager.Instance.gameData.currRoomData.roomId;
|
||||
|
||||
|
||||
foreach (var item in GameManager.Instance.gameData.currRoomData.players)
|
||||
{
|
||||
JoinGame(item.position, item.gold, item.diamond, item.cannonMultiple, 0, item.userId, item.cannonId, item.wingsId, item.warGodId);
|
||||
// ⭐ 优先用后端 isBot 字段,兼容 userId.StartsWith("bot_")
|
||||
var sit = list_Sits.Find(s => s.posID == item.position);
|
||||
if (sit != null)
|
||||
{
|
||||
bool isBot = item.isBot ||
|
||||
(!string.IsNullOrEmpty(item.userId) && item.userId.StartsWith("bot_"));
|
||||
if (isBot) sit.isBot = true;
|
||||
}
|
||||
}
|
||||
GameManager.Instance.gameData.roomJoinNotice = roomJoinNotice;
|
||||
isfirstShow = false;
|
||||
|
||||
foreach (var item in list_Sits)
|
||||
{
|
||||
// ⭐ 座位镜像:本地玩家的显示座位 = 服务端座位转显示空间(上方座位翻转后落回下方)
|
||||
if (item.posID == SeatMirror.ToDisplay(roomJoinNotice.Position))
|
||||
{
|
||||
currSitData = item;
|
||||
// ⭐ 长按本地座位的 img_OpenPT 开关炮台面板(与 btn_ChangeTurret 同逻辑)
|
||||
HookOpenPTLongPress(currSitData);
|
||||
// ⭐ 本地座位自动攻击关闭时广播 Idle 状态给其他客户端
|
||||
HookAutoAttackOff(currSitData);
|
||||
}
|
||||
else
|
||||
{
|
||||
// ⭐ 非本地座位隐藏加减炮倍:Normal 藏座位按钮(未拖引用为 null 跳过),
|
||||
// XJMH 藏炮台上的加减倍(TurretData.obj_Add / obj_Down)
|
||||
item.HideTurretAddMinusUI();
|
||||
// ⭐ 自动攻击开关与加减倍按钮一样:非本地座位隐藏
|
||||
if (item.toggle_AutoAttack != null)
|
||||
item.toggle_AutoAttack.gameObject.SetActive(false);
|
||||
}
|
||||
|
||||
}
|
||||
//// currSitData.ChangeTurret(1); — 已由 SitPosData.OnEnable 自动加载
|
||||
if (currSitData.currentTurret != null)
|
||||
SyncChangeTurret(currSitData.currentTurret.turretNumber);
|
||||
currSitData.lockFX.transform.GetChild(0).gameObject.SetActive(false);
|
||||
currSitData.lockFX.transform.GetChild(1).gameObject.SetActive(true);
|
||||
if (mySitAnim != null && currSitData.turretParent != null)
|
||||
{
|
||||
// ⭐ 座位位置 + 左右座位各自的偏移:把"我在这"圆圈摆到座位上面
|
||||
// (左右座位镜像后需要的偏移不一样,分左/右两套配置,面板上调)
|
||||
Vector3 sitAnimOffset = IsLeftSeat(currSitData) ? mySitAnimOffsetLeft : mySitAnimOffsetRight;
|
||||
mySitAnim.transform.position = currSitData.turretParent.position + sitAnimOffset;
|
||||
// ⭐ 进入游戏圆圈:6 秒后自动消失(点击屏幕立即消失的逻辑在 HandleInput)
|
||||
StartCoroutine(HideMySitAnimAfter(6f));
|
||||
}
|
||||
}
|
||||
|
||||
private void RefreshGGKCount()
|
||||
{
|
||||
var user = GameManager.Instance.user;
|
||||
@@ -1401,6 +1423,15 @@ public class GameMainPanel_FishBase : GameMainPanel_Base
|
||||
else if (JinDuTiao != null)
|
||||
JinDuTiao.Hide();
|
||||
|
||||
// ⭐ 加载到 100%(进度条已隐藏):标记完成 + 执行挂起的进房初始化(座位/房间信息)。
|
||||
// 入场动画等表现由初始化链路在此之后触发——玩家可见、位置已就绪
|
||||
IsGameLoadCompleted = true;
|
||||
if (_pendingFirstShowInit)
|
||||
{
|
||||
_pendingFirstShowInit = false;
|
||||
ApplyFirstShowInit();
|
||||
}
|
||||
|
||||
// ⭐ 无操作自动退出:加载完成,从现在开始计无操作时间
|
||||
ArmIdleAutoExit();
|
||||
}
|
||||
@@ -3065,7 +3096,8 @@ public class GameMainPanel_FishBase : GameMainPanel_Base
|
||||
{
|
||||
// ⭐ 起飞炮台(FlyTurretData):
|
||||
// 飞行/悬停中 → 点击空白处=改目标(点到哪飞到哪),立即响应;
|
||||
// 未起飞 → 仅记录轻点判定,继续走下方正常开火流程(松开时判定轻点才起飞),
|
||||
// 未起飞 → 仅记录轻点判定,继续走下方正常开火流程(松开时判定轻点是否起飞,
|
||||
// 是否允许由 FlyTurretData.allowTapTakeoff 控制,默认关=没点起飞按钮不起飞),
|
||||
// 保证平时按住扫射/自动开火与普通炮台完全一致
|
||||
if (currSitData.currentTurret is FlyTurretData flyTurret)
|
||||
{
|
||||
@@ -3129,7 +3161,7 @@ public class GameMainPanel_FishBase : GameMainPanel_Base
|
||||
return;
|
||||
}
|
||||
|
||||
// ⭐ 起飞炮台:轻点空白处=起飞(按下时已正常开火,松开时判定轻点→触发起飞)
|
||||
// ⭐ 起飞炮台:轻点空白处=起飞(受 allowTapTakeoff 控制,默认关;按下时已正常开火)
|
||||
// 长按/拖动扫射时此判定不通过,正常走下方 Idle,普通开火完全不受影响
|
||||
if (_flyTapPending)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user