using System;
|
using System.Collections.Generic;
|
|
// 阵型基础
|
|
public partial class TeamBase
|
{
|
public TeamHero[] teamHeros = new TeamHero[TeamConst.MaxTeamSlotCount];
|
|
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)
|
{
|
|
}
|
|
#if UNITY_EDITOR
|
public void FillWithFakeData()
|
{
|
for (int i = 0; i < TeamConst.MaxTeamHeroCount; i++)
|
{
|
TeamHero hero = new TeamHero();
|
hero.curHp = 100;
|
hero.attack = UnityEngine.Random.Range(300, 500);
|
hero.defense = UnityEngine.Random.Range(80, 100);
|
hero.heroInfo = new HeroInfo();
|
hero.teamBase = this;
|
hero.heroIndex = i;
|
teamHeros[i] = hero;
|
}
|
}
|
#endif
|
}
|