冰冻+人机
This commit is contained in:
@@ -9,6 +9,8 @@ public class SitPosData : MonoBehaviour
|
||||
{
|
||||
/// <summary>本地玩家的座位引用(由游戏面板初始化时设置)</summary>
|
||||
public static SitPosData localPlayerSit;
|
||||
/// <summary>当前房间房主座位(人机请求由房主发送,房主退出后自动继承)</summary>
|
||||
public static SitPosData roomOwnerSit;
|
||||
|
||||
// -------------------------
|
||||
// 玩家基础信息
|
||||
@@ -17,6 +19,8 @@ public class SitPosData : MonoBehaviour
|
||||
public string user;
|
||||
[Tooltip("座位编号 0~3。0,1=下方 2,3=上方")]
|
||||
public int posID;
|
||||
[Tooltip("是否为人机")]
|
||||
public bool isBot = false;
|
||||
|
||||
/// <summary>posID>=2 = 上方,需要翻转(0,1=下方;2,3=上方)</summary>
|
||||
public bool IsFlipped => posID >= 2;
|
||||
@@ -93,6 +97,33 @@ public class SitPosData : MonoBehaviour
|
||||
{
|
||||
if (localPlayerSit == this)
|
||||
localPlayerSit = null;
|
||||
// 房主退出 → 自动继承给第一个非人机玩家
|
||||
if (roomOwnerSit == this)
|
||||
{
|
||||
roomOwnerSit = null;
|
||||
TransferRoomOwner();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>房主退出后,将房主身份转移给第一个活跃的非人机玩家</summary>
|
||||
public static void TransferRoomOwner()
|
||||
{
|
||||
var list = FindObjectsOfType<SitPosData>();
|
||||
foreach (var sit in list)
|
||||
{
|
||||
if (!sit.isBot && sit.gameObject.activeInHierarchy && sit != roomOwnerSit)
|
||||
{
|
||||
roomOwnerSit = sit;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>分配房主(首个非人机玩家)</summary>
|
||||
public static void AssignRoomOwner(SitPosData sit)
|
||||
{
|
||||
if (roomOwnerSit == null && !sit.isBot)
|
||||
roomOwnerSit = sit;
|
||||
}
|
||||
|
||||
// ==================== 炮台加载(动态克隆) ====================
|
||||
|
||||
Reference in New Issue
Block a user