根据提供的code differences信息,由于没有具体的代码变更内容,我将生成一个通用的commit message模板:
``` docs(readme): 更新文档说明 - 添加项目使用指南 - 完善API接口说明 - 修正错误的配置示例 ``` 注意:由于您提供的code differences部分为空,以上是一个示例模板。当您有具体的代码变更时,请提供详细的变更内容以便生成更准确的commit message。
This commit is contained in:
1 parent
8d58c2223c
commit
11f1af357d
191 files changed
+2315
-1539
No files matched your search
@@ -0,0 +1,47 @@
|
||||
using UnityEngine;
|
||||
|
||||
/// <summary>
|
||||
/// 单位阵营标记:用阵营 ID 替代 Unity Tag 判断敌我关系。
|
||||
/// 支持 PVP:客户端只需设置 GameManager.LocalPlayerTeamId,所有单位的敌我判断自动正确。
|
||||
/// </summary>
|
||||
public class UnitTeam : MonoBehaviour
|
||||
{
|
||||
[Header("阵营 ID")]
|
||||
[Tooltip("0 = 玩家1阵营,1 = 玩家2阵营,2+ = 其他阵营")]
|
||||
public int teamId = 0;
|
||||
|
||||
/// <summary>
|
||||
/// 判断目标是否为敌人(不同阵营)
|
||||
/// </summary>
|
||||
public bool IsEnemy(GameObject other)
|
||||
{
|
||||
if (other == null) return false;
|
||||
|
||||
var otherTeam = other.GetComponent<UnitTeam>();
|
||||
if (otherTeam == null) return false;
|
||||
|
||||
return otherTeam.teamId != this.teamId;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 判断目标是否为友军(相同阵营)
|
||||
/// </summary>
|
||||
public bool IsFriendly(GameObject other)
|
||||
{
|
||||
if (other == null) return false;
|
||||
|
||||
var otherTeam = other.GetComponent<UnitTeam>();
|
||||
if (otherTeam == null) return false;
|
||||
|
||||
return otherTeam.teamId == this.teamId;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 判断是否属于本地玩家阵营
|
||||
/// </summary>
|
||||
public bool IsLocalPlayerTeam()
|
||||
{
|
||||
if (GameManager.Instance == null) return teamId == 0;
|
||||
return teamId == GameManager.Instance.LocalPlayerTeamId;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user