yyl
2025-06-17 007fbd542c30f5fa8308128aac26ce6584b3067a
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
using System;
using System.Collections.Generic;
 
//  阵型基础
 
public partial class TeamBase
{
    public TeamHero[] teamHeros = new TeamHero[TeamConst.MaxTeamHeroCount];
 
    public int GetTeamHeroCount()
    {
        int count = 0;
        for (int i = 0; i < teamHeros.Length; i++)
        {
            if (teamHeros[i] != null)
            {
                count++;
            }
        }
 
        return count;
    } 
 
    public bool SwapTeamHero(int index1, int index2)
    {
        if (index1 < 0 || index1 >= teamHeros.Length || index2 < 0 || index2 >= teamHeros.Length)
        {
            return false;
        }
 
        TeamHero temp = teamHeros[index1];
        teamHeros[index1] = teamHeros[index2];
        teamHeros[index2] = temp;
        temp.heroIndex = index2;
        teamHeros[index1].heroIndex = index1;
 
        return true;
    }
 
    public void AddTeamHeros(List<HeroInfo> heroInfos)
    {
        for (int i = 0; i < heroInfos.Count; i++)
        {
            AddTeamHero(heroInfos[i]);
        }
 
        UpdateProperties();
    }
 
    public bool AddTeamHero(HeroInfo heroInfo)
    {
        if (heroInfo == null)
        {
            return false;
        }
 
        for (int i = 0; i < teamHeros.Length; i++)
        {
            if (teamHeros[i] == null)
            {
                teamHeros[i] = new TeamHero();
                teamHeros[i].heroInfo = heroInfo;
                teamHeros[i].heroIndex = i;
                UpdateProperties();
                return true;    
            }
        }
        return false;
    }
 
    public bool RemoveTeamHero(int index)
    {
        if (index < 0 || index >= teamHeros.Length)
        {
            return false;
        }
 
        teamHeros[index] = null;
        return true;
    }
 
    public bool IsFull()
    {
        return GetTeamHeroCount() >= teamHeros.Length;
    }
 
    public bool IsEmpty()
    {
        return GetTeamHeroCount() == 0;
    }
 
    public void InitByLevelId(int levelId)
    {
        
    }
}