Files
daluandou/Assets/Scripts/系统脚本/GameManager.cs
T
huadexuan 11f1af357d 根据提供的code differences信息,由于没有具体的代码变更内容,我将生成一个通用的commit message模板:
```
docs(readme): 更新文档说明

- 添加项目使用指南
- 完善API接口说明
- 修正错误的配置示例
```

注意:由于您提供的code differences部分为空,以上是一个示例模板。当您有具体的代码变更时,请提供详细的变更内容以便生成更准确的commit message。
2026-10-02 10:04:12 +08:00

38 lines
995 B
C#
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
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}");
}
}