38 lines
995 B
C#
38 lines
995 B
C#
using UnityEngine;
|
||
|
||
/// <summary>
|
||
/// 游戏管理器:管理全局游戏状态,包括本地玩家的阵营 ID。
|
||
/// PVE:LocalPlayerTeamId = 0(固定)
|
||
/// PVP:服务器分配后设置 LocalPlayerTeamId(比如 0 或 1)
|
||
/// </summary>
|
||
public class GameManager : MonoBehaviour
|
||
{
|
||
public static GameManager Instance { get; private set; }
|
||
|
||
[Header("本地玩家阵营")]
|
||
[Tooltip("PVE: 固定为0; PVP: 服务器分配")]
|
||
public int LocalPlayerTeamId = 0;
|
||
|
||
private void Awake()
|
||
{
|
||
// 单例模式
|
||
if (Instance != null && Instance != this)
|
||
{
|
||
Destroy(gameObject);
|
||
return;
|
||
}
|
||
|
||
Instance = this;
|
||
DontDestroyOnLoad(gameObject);
|
||
}
|
||
|
||
/// <summary>
|
||
/// 设置本地玩家阵营 ID(PVP 时由服务器调用)
|
||
/// </summary>
|
||
public void SetLocalPlayerTeam(int teamId)
|
||
{
|
||
LocalPlayerTeamId = teamId;
|
||
Debug.Log($"本地玩家阵营设置为: {teamId}");
|
||
}
|
||
}
|