| | |
| | | { |
| | | var fightObj = lineUp.ObjList[i]; |
| | | TeamHero hero = new TeamHero(fightObj, this); |
| | | tempHeroes[fightObj.PosNum] = hero; |
| | | serverHeroes[fightObj.PosNum] = hero; |
| | | tempHeroes[hero.positionNum] = hero; |
| | | serverHeroes[hero.positionNum] = hero; |
| | | } |
| | | else |
| | | { |
| | |
| | | } |
| | | return null; |
| | | } |
| | | |
| | | |
| | | public TeamHero GetHeroByHeroID(int heroId) |
| | | { |
| | | { |
| | | foreach (var hero in tempHeroes) |
| | | { |
| | | if (hero != null && hero.heroId == heroId) |
| | |
| | | return false; |
| | | } |
| | | |
| | | public bool HasHeroInServer(string guid) |
| | | { |
| | | foreach (var hero in serverHeroes) |
| | | { |
| | | if (hero != null && hero.guid == guid) |
| | | { |
| | | return true; |
| | | } |
| | | } |
| | | 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() |
| | | { |
| | |
| | | } |
| | | } |
| | | 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; |
| | | } |
| | | |
| | | // 布阵接口 |
| | |
| | | tempHeroes[posNum] = hero; |
| | | } |
| | | |
| | | // 布阵接口: 恢复阵容 |
| | | public void RestoreTeam() |
| | | { |
| | | for (int i = 0; i < tempHeroes.Length; i++) |
| | | { |
| | | tempHeroes[i] = serverHeroes[i]; |
| | | } |
| | | } |
| | | |
| | | |
| | | public void AddHero(HeroInfo heroInfo, int targetPosition) |
| | | { |
| | | if (targetPosition < 0 || targetPosition >= tempHeroes.Length) |
| | |
| | | return; |
| | | } |
| | | |
| | | TeamHero targetHero = tempHeroes[targetPosition]; |
| | | |
| | | if (null == targetHero) |
| | | { |
| | | TeamHero newHero = new TeamHero(heroInfo, targetPosition, this); |
| | | SetTeamHero(targetPosition, newHero); |
| | | } |
| | | else |
| | | { |
| | | SetTeamHero(targetPosition, new TeamHero(heroInfo, targetPosition, this)); |
| | | } |
| | | SetTeamHero(targetPosition, new TeamHero(heroInfo, targetPosition, this)); |
| | | } |
| | | |
| | | |