yyl
2025-07-29 6577831ab2883bd05448ce0b1f9f913a9944fc78
Main/System/Team/TeamBase.cs
@@ -28,9 +28,9 @@
    private int ShapeType;
    public int ServerShapeType { get; private set; }
    public TeamHero[] teamHeros = new TeamHero[TeamConst.MaxTeamHeroCount];
    public TeamHero[] tempHeroes = new TeamHero[TeamConst.MaxTeamHeroCount];
    public TeamHero[] serverData { get; private set; } = new TeamHero[TeamConst.MaxTeamHeroCount];
    public TeamHero[] serverHeroes { get; private set; } = new TeamHero[TeamConst.MaxTeamHeroCount];
    public TeamBase(TeamType _teamType)
    {
@@ -49,12 +49,12 @@
        for (int i = 0; i < lineUp.ObjCnt; i++)
        {
            if (i < teamHeros.Length)
            if (i < tempHeroes.Length)
            {
                var fightObj = lineUp.ObjList[i];
                TeamHero hero = new TeamHero(fightObj, this);
                teamHeros[fightObj.PosNum] = hero;
                serverData[fightObj.PosNum] = hero;
                tempHeroes[fightObj.PosNum] = hero;
                serverHeroes[fightObj.PosNum] = hero;
            }
            else
            {
@@ -70,9 +70,9 @@
    public int GetTeamHeroCount()
    {
        int count = 0;
        for (int i = 0; i < teamHeros.Length; i++)
        for (int i = 0; i < tempHeroes.Length; i++)
        {
            if (teamHeros[i] != null)
            if (tempHeroes[i] != null)
            {
                count++;
            }
@@ -83,7 +83,7 @@
    public bool IsFull()
    {
        return GetTeamHeroCount() >= teamHeros.Length;
        return GetTeamHeroCount() >= tempHeroes.Length;
    }
    public bool IsEmpty()
@@ -109,7 +109,7 @@
        savePack.PosCnt = (byte)GetTeamHeroCount();
        savePack.HeroPosList = new CB412_tagCSHeroLineupSave.tagCSHeroLineupPos[savePack.PosCnt];
        foreach (var hero in teamHeros)
        foreach (var hero in tempHeroes)
        {
            if (hero != null)
            {
@@ -160,7 +160,7 @@
        for (int i = 0; i < heroInfos.Count; i++)
        {
            if (i < teamHeros.Length)
            if (i < tempHeroes.Length)
            {
                var heroInfo = heroInfos[i];
                TeamHero hero = new TeamHero(heroInfo, i, this);
@@ -175,7 +175,7 @@
    public TeamHero GetHero(string guid)
    {
        foreach (var hero in teamHeros)
        foreach (var hero in tempHeroes)
        {
            if (hero != null && hero.guid == guid)
            {
@@ -187,7 +187,7 @@
    public TeamHero GetServerHero(string guid)
    {
        foreach (var hero in serverData)
        foreach (var hero in serverHeroes)
        {
            if (hero != null && hero.guid == guid)
            {
@@ -200,7 +200,7 @@
    //  布阵接口
    public bool HasHero(string guid)
    {
        foreach (var hero in teamHeros)
        foreach (var hero in tempHeroes)
        {
            if (hero != null && hero.guid == guid)
            {
@@ -212,9 +212,9 @@
    public int GetEmptyPosition()
    {
        for (int i = 0; i < teamHeros.Length; i++)
        for (int i = 0; i < tempHeroes.Length; i++)
        {
            if (teamHeros[i] == null)
            if (tempHeroes[i] == null)
            {
                return i;
            }
@@ -225,25 +225,25 @@
    //  布阵接口
    public void SetTeamHero(int posNum, TeamHero hero)
    {
        teamHeros[posNum] = hero;
        tempHeroes[posNum] = hero;
    }
    //  布阵接口
    public void SetServerTeamHero(int posNum, TeamHero hero)
    {
        serverData[posNum] = hero;
        teamHeros[posNum] = hero;
        serverHeroes[posNum] = hero;
        tempHeroes[posNum] = hero;
    }
    public void AddHero(HeroInfo heroInfo, int targetPosition)
    {
        if (targetPosition < 0 || targetPosition >= teamHeros.Length)
        if (targetPosition < 0 || targetPosition >= tempHeroes.Length)
        {
            Debug.LogError("Invalid target position for adding hero.");
            return;
        }
        TeamHero targetHero = teamHeros[targetPosition];
        TeamHero targetHero = tempHeroes[targetPosition];
        if (null == targetHero)
        {
@@ -308,9 +308,9 @@
    {
        if (teamHero == null) return false;
        for (int i = 0; i < teamHeros.Length; i++)
        for (int i = 0; i < tempHeroes.Length; i++)
        {
            if (teamHeros[i] != null && teamHeros[i].guid == teamHero.guid)
            if (tempHeroes[i] != null && tempHeroes[i].guid == teamHero.guid)
            {
                SetTeamHero(i, null);
                return true; // Hero removed successfully
@@ -321,19 +321,19 @@
    public void SwapPosition(int index1, int index2)
    {
        if (index1 < 0 || index1 >= teamHeros.Length || index2 < 0 || index2 >= teamHeros.Length)
        if (index1 < 0 || index1 >= tempHeroes.Length || index2 < 0 || index2 >= tempHeroes.Length)
        {
            Debug.LogError("Invalid indices for swapping positions.");
            return;
        }
        TeamHero temp = teamHeros[index1];
        teamHeros[index1] = teamHeros[index2];
        teamHeros[index2] = temp;
        TeamHero temp = tempHeroes[index1];
        tempHeroes[index1] = tempHeroes[index2];
        tempHeroes[index2] = temp;
        //  更新位置编号
        if (teamHeros[index1] != null) teamHeros[index1].positionNum = index1;
        if (teamHeros[index2] != null) teamHeros[index2].positionNum = index2;
        if (tempHeroes[index1] != null) tempHeroes[index1].positionNum = index1;
        if (tempHeroes[index2] != null) tempHeroes[index2].positionNum = index2;
    }
    
}