| | |
| | | |
| | | public partial class TeamBase |
| | | { |
| | | public TeamCard[] teamCards = new TeamCard[TeamConst.MaxTeamCardCount]; |
| | | public TeamHero[] teamHeros = new TeamHero[TeamConst.MaxTeamHeroCount]; |
| | | |
| | | public int GetTeamCardCount() |
| | | public int GetTeamHeroCount() |
| | | { |
| | | int count = 0; |
| | | for (int i = 0; i < teamCards.Length; i++) |
| | | for (int i = 0; i < teamHeros.Length; i++) |
| | | { |
| | | if (teamCards[i] != null) |
| | | if (teamHeros[i] != null) |
| | | { |
| | | count++; |
| | | } |
| | |
| | | return count; |
| | | } |
| | | |
| | | public bool SwapTeamCard(int index1, int index2) |
| | | public bool SwapTeamHero(int index1, int index2) |
| | | { |
| | | if (index1 < 0 || index1 >= teamCards.Length || index2 < 0 || index2 >= teamCards.Length) |
| | | if (index1 < 0 || index1 >= teamHeros.Length || index2 < 0 || index2 >= teamHeros.Length) |
| | | { |
| | | return false; |
| | | } |
| | | |
| | | TeamCard temp = teamCards[index1]; |
| | | teamCards[index1] = teamCards[index2]; |
| | | teamCards[index2] = temp; |
| | | temp.cardIndex = index2; |
| | | teamCards[index1].cardIndex = index1; |
| | | TeamHero temp = teamHeros[index1]; |
| | | teamHeros[index1] = teamHeros[index2]; |
| | | teamHeros[index2] = temp; |
| | | temp.heroIndex = index2; |
| | | teamHeros[index1].heroIndex = index1; |
| | | |
| | | return true; |
| | | } |
| | | |
| | | public bool AddTeamCard(CardInfo cardInfo) |
| | | public bool AddTeamHero(HeroInfo heroInfo) |
| | | { |
| | | if (cardInfo == null) |
| | | if (heroInfo == null) |
| | | { |
| | | return false; |
| | | } |
| | | |
| | | for (int i = 0; i < teamCards.Length; i++) |
| | | for (int i = 0; i < teamHeros.Length; i++) |
| | | { |
| | | if (teamCards[i] == null) |
| | | if (teamHeros[i] == null) |
| | | { |
| | | teamCards[i] = new TeamCard(); |
| | | teamCards[i].cardInfo = cardInfo; |
| | | teamCards[i].cardIndex = i; |
| | | teamHeros[i] = new TeamHero(); |
| | | teamHeros[i].heroInfo = heroInfo; |
| | | teamHeros[i].heroIndex = i; |
| | | return true; |
| | | } |
| | | } |
| | | return false; |
| | | } |
| | | |
| | | public bool RemoveTeamCard(int index) |
| | | public bool RemoveTeamHero(int index) |
| | | { |
| | | if (index < 0 || index >= teamCards.Length) |
| | | if (index < 0 || index >= teamHeros.Length) |
| | | { |
| | | return false; |
| | | } |
| | | |
| | | teamCards[index] = null; |
| | | teamHeros[index] = null; |
| | | return true; |
| | | } |
| | | |
| | | public bool IsFull() |
| | | { |
| | | return GetTeamCardCount() >= teamCards.Length; |
| | | return GetTeamHeroCount() >= teamHeros.Length; |
| | | } |
| | | |
| | | public bool IsEmpty() |
| | | { |
| | | return GetTeamCardCount() == 0; |
| | | return GetTeamHeroCount() == 0; |
| | | } |
| | | |
| | | public void InitByLevelId(int levelId) |