hch
2025-07-16 305cf5f85998f47e1ae87ae965f9830b1352f130
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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
using System;
using System.Collections.Generic;
 
//  阵型基础
 
public partial class TeamBase
{
 
    // 区分一下阵营跟阵容 阵营为一个TeamBase列表 可能是多个玩家组合而成
    // 阵容为一个TeamBase 是玩家的一个队伍
    private int teamIndex = 0;//该阵营的第几个队伍
 
    private uint playerId = 0; //该阵容的玩家id
 
    private int ShapeType; //本阵容阵型,0为默认阵型,可扩展不同的阵型,如boss特殊战斗阵型,或者其他不同站位的阵型
 
    public bool IsPlayer
    {
        get
        {
            return playerId == 0;
        }
    }
 
    public TeamHero[] teamHeros = new TeamHero[TeamConst.MaxTeamSlotCount];
 
    public TeamBase()
    {
 
    }
 
    public TeamBase(HB424_tagSCTurnFightInit.tagSCTurnFightLineup lineUp)
    {
        teamIndex = lineUp.Num;
        playerId = lineUp.OwnerID;
        ShapeType = lineUp.ShapeType;
 
        for (int i = 0; i < lineUp.ObjCnt; i++)
        {
            if (i < teamHeros.Length)
            {
                TeamHero hero = new TeamHero(lineUp.ObjList[i], this);
                AddTeamHero(hero);
            }
        }
 
        Update();
 
 
    }
 
    protected void Update()
    {
        //  检查国籍
 
        //  检查羁绊
 
        //  检查阵型
 
        //  更新队伍英雄属性
        foreach (var teamHero in teamHeros)
        {
            teamHero.Update();
        }
 
        //  更新队伍属性
        // UpdateProperties();
 
        // CalculatePower();
    }
 
    public void SetShapeType(int shapeType)
    {
        ShapeType = shapeType;
    }
 
    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 AddHeroInfos(List<HeroInfo> heroInfos)
    {
        for (int i = 0; i < heroInfos.Count; i++)
        {
            AddHeroInfo(heroInfos[i]);
        }
 
        UpdateProperties();
    }
 
 
    public bool AddHeroInfo(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 void AddTeamHero(TeamHero teamHero)
    {
        if (null == teamHero)
        {
            return;
        }
 
        teamHeros[teamHero.heroIndex] = teamHero;
    }
 
 
    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;
    }
 
 
#if UNITY_EDITOR
    public void FillWithFakeData()
    {
        for (int i = 0; i < TeamConst.MaxTeamHeroCount; i++)
        {
            TeamHero hero = new TeamHero();
            hero.curHp = 100;
            hero.heroInfo = new HeroInfo();
            hero.teamBase = this;
            hero.heroIndex = i;
            teamHeros[i] = hero;
        }
    }
#endif
}