using System.Collections.Generic;
|
using UnityEngine;
|
using UnityEngine.UI;
|
|
public class StoryBossBattleWin : BaseBattleWin
|
{
|
[SerializeField]
|
public BossLifeBar bossLifeBar;
|
[SerializeField]
|
public SkillWordCell[] skillWordCells;
|
[SerializeField]
|
public BossHeadCell bossHeadCell;
|
[SerializeField]
|
public Text txtBossName;
|
|
private BattleObject bossBattleObject = null;
|
|
[SerializeField] public List<BattleBuffCell> buffCells;
|
|
protected override void OnPreOpen()
|
{
|
base.OnPreOpen();
|
|
UIManager.Instance.CloseWindow<MainWin>();
|
}
|
|
protected override void OnPreClose()
|
{
|
base.OnPreClose();
|
|
if (!UIManager.Instance.IsOpened<MainWin>())
|
UIManager.Instance.OpenWindow<MainWin>();
|
|
if (null != bossBattleObject)
|
{
|
bossBattleObject.buffMgr.onBuffChanged -= OnBuffChanged;
|
bossBattleObject = null;
|
}
|
}
|
|
protected override void OnCreateBattleField(string guid, BattleField field)
|
{
|
if (field is StoryBossBattleField)
|
{
|
SetBattleField(field);
|
}
|
}
|
|
protected override void RefreshSpecific()
|
{
|
StoryBossBattleField storyBossField = battleField as StoryBossBattleField;
|
if (storyBossField == null) return;
|
|
NPCLineupConfig lineupConfig = storyBossField.GetBossLineupConfig();
|
|
if (null != bossBattleObject)
|
{
|
bossBattleObject.buffMgr.onBuffChanged -= OnBuffChanged;
|
bossBattleObject = null;
|
}
|
|
bossBattleObject = storyBossField.FindBoss();
|
|
DisplaySkillWordsList(lineupConfig);
|
|
if (null != bossBattleObject)
|
{
|
TeamHero teamHero = bossBattleObject.teamHero;
|
bossHeadCell.SetTeamHero(teamHero);
|
txtBossName.text = teamHero.name;
|
NPCConfig npcConfig = NPCConfig.Get(teamHero.NPCID);
|
bossLifeBar.SetBaseInfo(Mathf.Max(1, npcConfig.LifeBarCount), (ulong)teamHero.curHp, (ulong)teamHero.maxHp);
|
bossBattleObject.buffMgr.onBuffChanged -= OnBuffChanged;
|
bossBattleObject.buffMgr.onBuffChanged += OnBuffChanged;
|
}
|
else
|
{
|
bossHeadCell.SetTeamHero(null);
|
txtBossName.text = string.Empty;
|
bossLifeBar.SetBaseInfo(2, 2, 2);
|
Debug.LogError("找不到boss");
|
}
|
|
OnRoundChange(battleField.round, battleField.turnMax); // 确保回合显示被调用
|
OnBuffChanged();
|
}
|
|
private void OnBuffChanged()
|
{
|
var buffList = new List<HB428_tagSCBuffRefresh>();
|
if (null != bossBattleObject)
|
{
|
buffList = bossBattleObject.buffMgr.GetBuffList();
|
}
|
RefreshBuff(buffList);
|
}
|
|
private void RefreshHP()
|
{
|
if (null != bossBattleObject)
|
{
|
TeamHero teamHero = bossBattleObject.teamHero;
|
bossLifeBar.Show((ulong)teamHero.curHp, (ulong)teamHero.maxHp);
|
}
|
}
|
|
protected override void OnDamageTaken(BattleDmgInfo info)
|
{
|
base.OnDamageTaken(info);
|
if (battleField == null || info.battleFieldGuid != battleField.guid)
|
return;
|
if (bossBattleObject != null && info.hurtObj.ObjID == bossBattleObject.ObjID)
|
{
|
RefreshHP();
|
}
|
}
|
|
|
public void DisplaySkillWordsList(NPCLineupConfig lineUPConfig)
|
{
|
if (skillWordCells.IsNullOrEmpty())
|
return;
|
|
if (null == lineUPConfig)
|
return;
|
|
for (int i = 0; i < skillWordCells.Length; i++)
|
{
|
if (i < lineUPConfig.SkillIDExList.Length)
|
{
|
skillWordCells[i].SetActive(true);
|
int skillID = lineUPConfig.SkillIDExList[i];
|
skillWordCells[i].Init(skillID, () =>
|
{
|
SmallTipWin.showText = Language.Get("SmallTipFomat", SkillConfig.Get(skillID)?.SkillName, SkillConfig.Get(skillID)?.Description);
|
SmallTipWin.worldPos = CameraManager.uiCamera.ScreenToWorldPoint(Input.mousePosition);
|
SmallTipWin.isDownShow = true;
|
UIManager.Instance.OpenWindow<SmallTipWin>();
|
});
|
}
|
else
|
{
|
skillWordCells[i].SetActive(false);
|
}
|
}
|
}
|
|
public void RefreshBuff(List<HB428_tagSCBuffRefresh> datas)
|
{
|
if (buffCells.IsNullOrEmpty())
|
return;
|
|
|
for (int i = 0; i < buffCells.Count; i++)
|
{
|
if (i < datas.Count)
|
{
|
buffCells[i].SetActive(true);
|
HB428_tagSCBuffRefresh buffData = datas[i];
|
buffCells[i].Init(buffData, () =>
|
{
|
// 点击buff图标 显示buff描述/当前身上所有buff
|
});
|
}
|
else
|
{
|
buffCells[i].SetActive(false);
|
}
|
}
|
}
|
|
}
|