lcy
2025-10-16 3b64befcd8b2ab5abef1a33c5c8f73a6b245aff0
Main/System/Team/TeamBase.cs
@@ -187,9 +187,10 @@
        }
        return null;
    }
    public TeamHero GetHeroByHeroID(int heroId)
    {
    {
        foreach (var hero in tempHeroes)
        {
            if (hero != null && hero.heroId == heroId)
@@ -238,6 +239,49 @@
        return false;
    }
    public TeamHero GetServerHeroByIndex(int index)
    {
        if (index < 0 || index >= serverHeroes.Length)
        {
            return null;
        }
        return serverHeroes[index];
    }
    public TeamHero GetNextServerHero(string guid)
    {
        if (string.IsNullOrEmpty(guid))
        {
            //取第一个
            foreach (var hero in serverHeroes)
            {
                if (hero != null)
                {
                    return hero;
                }
            }
            return null;
        }
        else
        {
            //取下一个
            bool findNext = false;
            foreach (var hero in serverHeroes)
            {
                if (hero != null && hero.guid == guid)
                {
                    findNext = true;
                }
                else if (findNext && hero != null)
                {
                    return hero;
                }
            }
            //没找到 取第一个
            return GetNextServerHero("");
        }
    }
    //客户端从0开始,服务端从1开始
    public int GetEmptyPosition()
    {
@@ -251,6 +295,18 @@
        return -1; // No empty position
    }
    public int GetPosition(string guid)
    {
        foreach (var hero in serverHeroes)
        {
            if (hero != null && hero.guid == guid)
            {
                return hero.positionNum;
            }
        }
        return  -1;
    }
    //  布阵接口
    private void SetTeamHero(int posNum, TeamHero hero)
    {