using System.Collections.Generic;
|
using UnityEngine;
|
using UnityEngine.UI;
|
|
public class HeroCountryComponent : MonoBehaviour
|
{
|
[SerializeField] Button countryOnBtn;
|
[SerializeField] Image countryOnImg; //上阵阵型激活国家
|
[SerializeField] UIEffectPlayer countryEffect;
|
[SerializeField] List<Image> OnCountImgs; //上阵数量激活
|
List<TeamHero> teamHeroes;
|
void Awake()
|
{
|
countryOnBtn.AddListener(() =>
|
{
|
HeroUIManager.Instance.isCustonHeroFormation = true;
|
HeroUIManager.Instance.custonTeamHeroes = teamHeroes;
|
UIManager.Instance.OpenWindow<HeroFormationWin>();
|
});
|
}
|
|
//上阵武将国家光环激活
|
public void RefreshOnTeamCountry(List<TeamHero> teamHeroes, bool playEffect = false)
|
{
|
this.teamHeroes = teamHeroes;
|
|
// 1. 先检查混搭阵型
|
var mixedConfig = HeroUIManager.Instance.GetMixedFormationConfig(teamHeroes);
|
if (mixedConfig != null)
|
{
|
countryOnImg.SetSprite("heroTeamCountryHe");
|
var participatingCountries = HeroUIManager.Instance.GetParticipatingCountriesByPriority(teamHeroes);
|
int totalPoints = mixedConfig.Countrys * mixedConfig.NeedHeroCount;
|
for (int i = 0; i < OnCountImgs.Count; i++)
|
{
|
if (i < totalPoints)
|
{
|
int countryIndex = i / mixedConfig.NeedHeroCount;
|
OnCountImgs[i].SetActive(true);
|
OnCountImgs[i].SetSprite("heroTeamCountryPoint" + participatingCountries[countryIndex]);
|
}
|
else
|
{
|
OnCountImgs[i].SetActive(false);
|
}
|
}
|
if (playEffect)
|
countryEffect.Play();
|
return;
|
}
|
|
Int2 result = HeroUIManager.Instance.GetMaxCountHeroCountry(teamHeroes);
|
|
var config = HeroLineupHaloConfig.GetConfig(result.x, result.y);
|
if (config == null)
|
{
|
countryOnImg.SetSprite("heroTeamCountry0");
|
for (int i = 0; i < OnCountImgs.Count; i++)
|
{
|
OnCountImgs[i].SetActive(false);
|
}
|
}
|
else
|
{
|
countryOnImg.SetSprite("heroTeamCountry" + result.x);
|
for (int i = 0; i < OnCountImgs.Count; i++)
|
{
|
if (i < result.y)
|
{
|
OnCountImgs[i].SetActive(true);
|
OnCountImgs[i].SetSprite("heroTeamCountryPoint" + result.x);
|
}
|
else
|
{
|
OnCountImgs[i].SetActive(false);
|
}
|
}
|
if (playEffect)
|
countryEffect.Play();
|
}
|
|
}
|
}
|