2026-04-01 12:23:27 -04:00
|
|
|
|
using System;
|
2025-10-03 00:02:43 -04:00
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
|
using System.Linq;
|
|
|
|
|
|
using Continentis.MainGame.Card;
|
|
|
|
|
|
using Continentis.MainGame.Character;
|
|
|
|
|
|
using Continentis.MainGame.Commands;
|
2026-04-01 12:23:27 -04:00
|
|
|
|
using Continentis.MainGame.Saving;
|
2025-10-03 00:02:43 -04:00
|
|
|
|
using Continentis.MainGame.UI;
|
2026-04-17 12:01:50 -04:00
|
|
|
|
using SLSUtilities.General;
|
2025-10-03 00:02:43 -04:00
|
|
|
|
using UnityEngine;
|
|
|
|
|
|
|
2025-10-23 00:49:44 -04:00
|
|
|
|
namespace Continentis.MainGame.Combat
|
2025-10-03 00:02:43 -04:00
|
|
|
|
{
|
2026-04-01 12:23:27 -04:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 战斗进行状态枚举
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
public enum CombatState
|
|
|
|
|
|
{
|
|
|
|
|
|
InProgress,
|
|
|
|
|
|
ConfirmingRound,
|
|
|
|
|
|
Victory,
|
|
|
|
|
|
Defeat
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2025-10-03 00:02:43 -04:00
|
|
|
|
public partial class CombatMainManager : Singleton<CombatMainManager>
|
|
|
|
|
|
{
|
2025-10-23 00:49:44 -04:00
|
|
|
|
public CombatCharacterController characterController;
|
2025-10-03 00:02:43 -04:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public partial class CombatMainManager
|
|
|
|
|
|
{
|
2025-10-23 00:49:44 -04:00
|
|
|
|
[Header("Combat State")]
|
2025-10-03 00:02:43 -04:00
|
|
|
|
public int currentRound;
|
|
|
|
|
|
public int currentActionIndex;
|
|
|
|
|
|
public CharacterBase currentCharacter;
|
2026-04-01 12:23:27 -04:00
|
|
|
|
public CombatState combatState;
|
2025-10-03 00:02:43 -04:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public partial class CombatMainManager
|
|
|
|
|
|
{
|
2025-10-23 00:49:44 -04:00
|
|
|
|
[Header("Events")]
|
2025-10-03 00:02:43 -04:00
|
|
|
|
public CombatEventCollection eventCollection;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public partial class CombatMainManager
|
|
|
|
|
|
{
|
|
|
|
|
|
protected override void Awake()
|
|
|
|
|
|
{
|
|
|
|
|
|
base.Awake();
|
2025-10-23 00:49:44 -04:00
|
|
|
|
characterController = new CombatCharacterController();
|
2025-10-03 00:02:43 -04:00
|
|
|
|
eventCollection = new CombatEventCollection();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void Start()
|
|
|
|
|
|
{
|
2026-03-20 11:56:50 -04:00
|
|
|
|
characterController.Initialize(
|
|
|
|
|
|
MainGameManager.Instance.playerHeroDataList,
|
|
|
|
|
|
MainGameManager.Instance.enemyDataList);
|
2025-10-03 00:02:43 -04:00
|
|
|
|
StartCombat();
|
2025-11-13 10:42:05 -05:00
|
|
|
|
CombatUIManager.Instance.UpdateAll();
|
2025-10-03 00:02:43 -04:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public partial class CombatMainManager
|
|
|
|
|
|
{
|
|
|
|
|
|
public void StartCombat()
|
|
|
|
|
|
{
|
2026-04-01 12:23:27 -04:00
|
|
|
|
combatState = CombatState.InProgress;
|
|
|
|
|
|
|
2025-10-23 00:49:44 -04:00
|
|
|
|
foreach (CharacterBase character in characterController.characters)
|
|
|
|
|
|
character.InitializeCards();
|
2026-03-20 11:56:50 -04:00
|
|
|
|
|
2025-10-03 00:02:43 -04:00
|
|
|
|
currentRound = 0;
|
2026-03-20 11:56:50 -04:00
|
|
|
|
|
2025-10-03 00:02:43 -04:00
|
|
|
|
eventCollection.onCombatStart.Invoke();
|
2026-03-20 11:56:50 -04:00
|
|
|
|
|
2025-10-23 00:49:44 -04:00
|
|
|
|
foreach (CharacterBase character in characterController.characters)
|
2026-04-01 12:23:27 -04:00
|
|
|
|
character.DispatchCombatStart();
|
2026-03-20 11:56:50 -04:00
|
|
|
|
|
2026-04-01 12:23:27 -04:00
|
|
|
|
// 1.2b — 初始化 CombatLogs 并订阅事件
|
|
|
|
|
|
CombatLogs.Instance.Initialize(this);
|
2026-03-20 11:56:50 -04:00
|
|
|
|
|
2025-10-03 00:02:43 -04:00
|
|
|
|
NextRound();
|
|
|
|
|
|
}
|
2026-03-20 11:56:50 -04:00
|
|
|
|
|
2025-10-03 00:02:43 -04:00
|
|
|
|
public void NextRound()
|
|
|
|
|
|
{
|
2026-04-01 12:23:27 -04:00
|
|
|
|
// 战斗已结束则不再推进
|
|
|
|
|
|
if (combatState != CombatState.InProgress) return;
|
|
|
|
|
|
|
2025-10-03 00:02:43 -04:00
|
|
|
|
currentRound++;
|
2026-03-20 11:56:50 -04:00
|
|
|
|
|
|
|
|
|
|
// UI 反馈:回合提示动画(同步,纯 UI 无逻辑影响)
|
2025-12-12 01:37:30 -05:00
|
|
|
|
CombatUIManager.Instance.combatMainPage.roundHint.PlayRoundHint(currentRound);
|
2026-03-20 11:56:50 -04:00
|
|
|
|
|
|
|
|
|
|
// ── 纯逻辑初始化(无视觉反馈,同步执行)────────────────────────────
|
2025-10-03 00:02:43 -04:00
|
|
|
|
eventCollection.onRoundStart.Invoke();
|
2025-10-23 00:49:44 -04:00
|
|
|
|
foreach (CharacterBase character in characterController.characters)
|
|
|
|
|
|
character.actionCountThisRound = 0;
|
2025-10-03 00:02:43 -04:00
|
|
|
|
|
2025-10-23 00:49:44 -04:00
|
|
|
|
characterController.SetActionOrder();
|
|
|
|
|
|
CombatUIManager.Instance.combatMainPage.actionOrderDisplayer.InitializeTurnOrder();
|
2025-10-03 00:02:43 -04:00
|
|
|
|
currentActionIndex = 0;
|
2026-03-20 11:56:50 -04:00
|
|
|
|
|
|
|
|
|
|
// ── NPC 意图决策(同步,不产生视觉效果)────────────────────────────
|
2025-10-23 00:49:44 -04:00
|
|
|
|
foreach (CharacterBase character in characterController.characters)
|
2025-10-03 00:02:43 -04:00
|
|
|
|
{
|
|
|
|
|
|
if (character is CombatNPC npc)
|
|
|
|
|
|
{
|
2025-11-15 09:08:36 -05:00
|
|
|
|
npc.IntentionBrain();
|
2025-11-15 12:17:34 -05:00
|
|
|
|
npc.deckSubmodule.PoolPile.ForEach(card => card.weightSubmodule.RefreshCurrentWeight());
|
2025-10-03 00:02:43 -04:00
|
|
|
|
npc.intentionSubmodule.getIntendedCards.Invoke();
|
2026-03-20 11:56:50 -04:00
|
|
|
|
|
2025-10-03 00:02:43 -04:00
|
|
|
|
foreach (IntendedCard intendedCard in npc.intentionSubmodule.intendedCards)
|
|
|
|
|
|
{
|
|
|
|
|
|
intendedCard.cardInstance.GenerateIntentionCardView();
|
2025-10-23 00:49:44 -04:00
|
|
|
|
if (intendedCard.targets.Count > 0)
|
|
|
|
|
|
{
|
2025-11-15 12:17:34 -05:00
|
|
|
|
CardInstance card = intendedCard.cardInstance;
|
2026-04-01 12:23:27 -04:00
|
|
|
|
card.Targeting(intendedCard.targets[0]);
|
2025-11-15 12:17:34 -05:00
|
|
|
|
card.contentSubmodule.dirtyMark = true;
|
2025-10-23 00:49:44 -04:00
|
|
|
|
}
|
2025-10-03 00:02:43 -04:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2026-03-20 11:56:50 -04:00
|
|
|
|
|
2026-04-01 12:23:27 -04:00
|
|
|
|
// ── 进入"回合前确认"阶段:等待玩家点击 Confirm ───────────────────
|
|
|
|
|
|
combatState = CombatState.ConfirmingRound;
|
|
|
|
|
|
CommandQueueManager.Instance.AddCommand(Cmd.Do(() =>
|
|
|
|
|
|
{
|
|
|
|
|
|
CombatMainPage page = CombatUIManager.Instance.combatMainPage;
|
|
|
|
|
|
page.SetButtonAction(ConfirmRound, "Confirm", true);
|
|
|
|
|
|
}));
|
|
|
|
|
|
|
|
|
|
|
|
CommandBase waitSignal = Cmd.WaitForSignal(out confirmRoundSignal);
|
|
|
|
|
|
CommandQueueManager.Instance.AddCommand(waitSignal);
|
|
|
|
|
|
|
|
|
|
|
|
// ── 玩家确认后,回合正式开始:Buff 触发链入队 ────────────────────
|
|
|
|
|
|
CommandQueueManager.Instance.AddCommand(Cmd.Do(() =>
|
|
|
|
|
|
{
|
|
|
|
|
|
combatState = CombatState.InProgress;
|
|
|
|
|
|
CombatUIManager.Instance.combatMainPage.SetButtonAction(
|
|
|
|
|
|
EndAction, "Waiting...", false);
|
|
|
|
|
|
}));
|
|
|
|
|
|
|
2026-03-20 11:56:50 -04:00
|
|
|
|
foreach (CharacterBase character in characterController.characters)
|
|
|
|
|
|
{
|
|
|
|
|
|
CharacterBase captured = character;
|
2026-04-01 12:23:27 -04:00
|
|
|
|
CommandQueueManager.Instance.AddCommand(Cmd.Do(() => captured.DispatchRoundStart()));
|
2026-03-20 11:56:50 -04:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// ── 所有回合开始事件处理完毕后,进入第一个行动 ────────────────────
|
|
|
|
|
|
CommandQueueManager.Instance.AddCommand(Cmd.Do(NextAction));
|
2025-10-03 00:02:43 -04:00
|
|
|
|
}
|
2026-03-20 11:56:50 -04:00
|
|
|
|
|
2026-04-01 12:23:27 -04:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 玩家在"回合前确认"阶段点击 Confirm 后调用,释放队列暂停信号。
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
public void ConfirmRound()
|
|
|
|
|
|
{
|
|
|
|
|
|
if (combatState != CombatState.ConfirmingRound) return;
|
|
|
|
|
|
confirmRoundSignal?.Invoke();
|
|
|
|
|
|
confirmRoundSignal = null;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// 持有当前回合的信号委托,ConfirmRound() 调用后置 null 防止重复触发
|
|
|
|
|
|
private Action confirmRoundSignal;
|
|
|
|
|
|
|
2025-10-03 00:02:43 -04:00
|
|
|
|
public void NextAction()
|
|
|
|
|
|
{
|
2026-04-01 12:23:27 -04:00
|
|
|
|
// 战斗已结束则不再推进
|
|
|
|
|
|
if (combatState != CombatState.InProgress) return;
|
|
|
|
|
|
|
2025-10-23 00:49:44 -04:00
|
|
|
|
if (characterController.actionOrderList.Count == 0)
|
2025-10-03 00:02:43 -04:00
|
|
|
|
{
|
2026-03-20 11:56:50 -04:00
|
|
|
|
// 回合结束:所有角色的 onRoundEnd 和 Buff 触发均入队
|
2025-10-30 12:07:59 -04:00
|
|
|
|
foreach (CharacterBase character in characterController.characters)
|
|
|
|
|
|
{
|
2026-03-20 11:56:50 -04:00
|
|
|
|
CharacterBase captured = character;
|
2026-04-01 12:23:27 -04:00
|
|
|
|
CommandQueueManager.Instance.AddCommand(Cmd.Do(() => captured.DispatchRoundEnd()));
|
2025-10-30 12:07:59 -04:00
|
|
|
|
}
|
|
|
|
|
|
|
2026-03-20 11:56:50 -04:00
|
|
|
|
CommandQueueManager.Instance.AddCommand(Cmd.Do(NextRound));
|
2025-10-03 00:02:43 -04:00
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2025-10-23 00:49:44 -04:00
|
|
|
|
currentCharacter = characterController.actionOrderList[0];
|
2026-03-20 11:56:50 -04:00
|
|
|
|
|
|
|
|
|
|
CharacterBase actionCharacter = currentCharacter;
|
|
|
|
|
|
CommandQueueManager.Instance.AddCommand(Cmd.Do(() =>
|
|
|
|
|
|
{
|
2026-04-01 12:23:27 -04:00
|
|
|
|
actionCharacter.DispatchActionStart();
|
2026-03-20 11:56:50 -04:00
|
|
|
|
actionCharacter.recordSubmodule.SetAction(currentRound, ++currentActionIndex);
|
|
|
|
|
|
}));
|
|
|
|
|
|
|
2026-04-01 12:23:27 -04:00
|
|
|
|
CombatMainPage combatMainPage = CombatUIManager.Instance.combatMainPage;
|
|
|
|
|
|
|
2025-10-03 00:02:43 -04:00
|
|
|
|
if (currentCharacter is PlayerHero playerHero)
|
|
|
|
|
|
{
|
2025-10-23 00:49:44 -04:00
|
|
|
|
playerHero.deckSubmodule.SetUpHandCardViews();
|
|
|
|
|
|
combatMainPage.handPile.isUpdatingLayout = false;
|
2026-03-20 11:56:50 -04:00
|
|
|
|
|
|
|
|
|
|
CommandQueueManager.Instance.AddCommand(
|
|
|
|
|
|
playerHero.deckSubmodule.DrawCards(playerHero.GetAttribute("DrawCardAmountPerAction")));
|
|
|
|
|
|
|
|
|
|
|
|
CommandQueueManager.Instance.AddCommand(Cmd.Do(() =>
|
2025-10-24 09:11:22 -04:00
|
|
|
|
{
|
|
|
|
|
|
combatMainPage.handPile.isUpdatingLayout = true;
|
|
|
|
|
|
}));
|
2026-03-20 11:56:50 -04:00
|
|
|
|
|
2025-10-23 00:49:44 -04:00
|
|
|
|
combatMainPage.combatResourcesDisplayer.SetCharacter(playerHero);
|
2026-04-01 12:23:27 -04:00
|
|
|
|
combatMainPage.SetButtonAction(EndAction, "End Action", true);
|
2025-10-03 00:02:43 -04:00
|
|
|
|
}
|
|
|
|
|
|
else if (currentCharacter is CombatNPC)
|
|
|
|
|
|
{
|
2026-04-01 12:23:27 -04:00
|
|
|
|
string npcLabel = currentCharacter.fraction switch
|
|
|
|
|
|
{
|
|
|
|
|
|
Fraction.Enemy => "Enemy Action",
|
|
|
|
|
|
Fraction.Ally => "Ally Action",
|
|
|
|
|
|
_ => "Others Action"
|
|
|
|
|
|
};
|
|
|
|
|
|
combatMainPage.SetButtonAction(null, npcLabel, false);
|
2025-10-03 00:02:43 -04:00
|
|
|
|
|
2026-03-20 11:56:50 -04:00
|
|
|
|
CommandQueueManager.Instance.AddCommand(Cmd.Wait(0.25f));
|
|
|
|
|
|
|
2026-04-01 12:23:27 -04:00
|
|
|
|
// 2.3e — PreAction 钩子:NPC 出牌前
|
|
|
|
|
|
CommandQueueManager.Instance.AddCommand(Cmd.Do(() =>
|
|
|
|
|
|
currentCharacter.intentionSubmodule.currentIntention.PreAction()));
|
|
|
|
|
|
|
2025-10-03 00:02:43 -04:00
|
|
|
|
foreach (IntendedCard intendedCard in currentCharacter.intentionSubmodule.intendedCards)
|
|
|
|
|
|
{
|
2026-03-20 11:56:50 -04:00
|
|
|
|
IntendedCard captured = intendedCard;
|
|
|
|
|
|
currentCharacter.CheckAvailabilityAndSetTargets(captured.cardInstance, out captured.targets);
|
|
|
|
|
|
|
|
|
|
|
|
CommandQueueManager.Instance.AddCommand(Cmd.Sequential(
|
|
|
|
|
|
Cmd.Do(() => {
|
|
|
|
|
|
captured.cardInstance.Play(captured.targets, currentCharacter);
|
|
|
|
|
|
captured.cardInstance.DestroyIntentionCardView();
|
2026-04-01 12:23:27 -04:00
|
|
|
|
}),
|
2026-03-20 11:56:50 -04:00
|
|
|
|
Cmd.Wait(0.25f)
|
|
|
|
|
|
));
|
2025-10-03 00:02:43 -04:00
|
|
|
|
}
|
2026-03-20 11:56:50 -04:00
|
|
|
|
|
2026-04-01 12:23:27 -04:00
|
|
|
|
// 2.3e — PostAction 钩子:NPC 出完全部卡牌后
|
|
|
|
|
|
CommandQueueManager.Instance.AddCommand(Cmd.Do(() =>
|
|
|
|
|
|
currentCharacter.intentionSubmodule.currentIntention.PostAction()));
|
|
|
|
|
|
|
2026-03-20 11:56:50 -04:00
|
|
|
|
CommandQueueManager.Instance.AddCommand(Cmd.Do(EndAction));
|
2025-10-03 00:02:43 -04:00
|
|
|
|
}
|
|
|
|
|
|
|
2025-11-13 08:52:30 -05:00
|
|
|
|
currentCharacter.characterView.hudContainer.UpdateAllHUD();
|
2026-03-20 11:56:50 -04:00
|
|
|
|
CombatUIManager.Instance.combatMainPage.actionOrderDisplayer.avatars
|
|
|
|
|
|
.Find(avatar => avatar.character == currentCharacter)?.Highlight(true);
|
2025-10-23 00:49:44 -04:00
|
|
|
|
currentCharacter.actionCountThisRound++;
|
|
|
|
|
|
}
|
2026-03-20 11:56:50 -04:00
|
|
|
|
|
2025-10-03 00:02:43 -04:00
|
|
|
|
public void EndAction()
|
|
|
|
|
|
{
|
2026-04-01 12:23:27 -04:00
|
|
|
|
CombatUIManager.Instance.combatMainPage.SetButtonAction(null, "Waiting...", false);
|
2025-10-03 00:02:43 -04:00
|
|
|
|
|
2026-03-20 11:56:50 -04:00
|
|
|
|
CommandQueueManager.Instance.AddCommand(Cmd.Do(() =>
|
2025-10-03 00:02:43 -04:00
|
|
|
|
{
|
2026-04-01 12:23:27 -04:00
|
|
|
|
currentCharacter.DispatchActionEnd();
|
2026-03-20 11:56:50 -04:00
|
|
|
|
|
2025-10-23 00:49:44 -04:00
|
|
|
|
if (currentCharacter is PlayerHero playerHero)
|
2025-10-03 00:02:43 -04:00
|
|
|
|
{
|
2025-10-23 00:49:44 -04:00
|
|
|
|
List<CardInstance> handPile = new List<CardInstance>(playerHero.deckSubmodule.HandPile);
|
2026-03-20 11:56:50 -04:00
|
|
|
|
List<CardInstance> cardToRetain = handPile.Where(c => c.HasKeyword("Retain")).ToList();
|
|
|
|
|
|
List<CardInstance> cardToExhaust = handPile.Where(c => c.HasKeyword("Ethereal")).ToList();
|
|
|
|
|
|
List<CardInstance> cardsToDiscard = handPile.Except(cardToRetain).Except(cardToExhaust).ToList();
|
|
|
|
|
|
|
2025-10-30 23:31:29 -04:00
|
|
|
|
CommandQueueManager.Instance.AddCommand(playerHero.deckSubmodule.ExhaustCards(cardToExhaust));
|
2025-10-31 10:02:30 -04:00
|
|
|
|
CommandQueueManager.Instance.AddCommand(playerHero.deckSubmodule.DiscardCards(cardsToDiscard, false));
|
2025-10-03 00:02:43 -04:00
|
|
|
|
}
|
2026-03-20 11:56:50 -04:00
|
|
|
|
|
2025-10-23 00:49:44 -04:00
|
|
|
|
characterController.actionOrderList.Remove(currentCharacter);
|
|
|
|
|
|
CombatUIManager.Instance.combatMainPage.actionOrderDisplayer.EndAction();
|
2026-03-20 11:56:50 -04:00
|
|
|
|
|
|
|
|
|
|
CommandQueueManager.Instance.AddCommand(Cmd.Do(CombatUIManager.Instance.combatMainPage.ClearAllCardViews));
|
|
|
|
|
|
CommandQueueManager.Instance.AddCommand(Cmd.Wait(0.5f));
|
|
|
|
|
|
CommandQueueManager.Instance.AddCommand(Cmd.Do(NextAction));
|
2025-10-23 00:49:44 -04:00
|
|
|
|
}));
|
2025-10-03 00:02:43 -04:00
|
|
|
|
}
|
|
|
|
|
|
}
|
2026-04-01 12:23:27 -04:00
|
|
|
|
|
|
|
|
|
|
public partial class CombatMainManager
|
|
|
|
|
|
{
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 结束战斗,触发胜负流程。由 CombatCharacterController.CheckCombatEnd() 调用。
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
public void EndCombat(bool isVictory)
|
|
|
|
|
|
{
|
|
|
|
|
|
// 防止重复触发
|
|
|
|
|
|
if (combatState != CombatState.InProgress) return;
|
|
|
|
|
|
|
|
|
|
|
|
combatState = isVictory ? CombatState.Victory : CombatState.Defeat;
|
|
|
|
|
|
|
|
|
|
|
|
// 触发战斗结束全局事件
|
|
|
|
|
|
eventCollection.onCombatEnd.Invoke();
|
|
|
|
|
|
|
|
|
|
|
|
foreach (CharacterBase character in characterController.characters)
|
|
|
|
|
|
character.DispatchCombatEnd();
|
|
|
|
|
|
|
|
|
|
|
|
// 清理所有卡牌 Logic 的托管订阅
|
|
|
|
|
|
foreach (CharacterBase character in characterController.characters)
|
|
|
|
|
|
foreach (CardInstance card in character.deckSubmodule.GetAllCards())
|
|
|
|
|
|
card.cardLogic?.Dispose();
|
|
|
|
|
|
|
|
|
|
|
|
if (isVictory)
|
|
|
|
|
|
{
|
|
|
|
|
|
CombatVictory();
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
CombatDefeat();
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 战斗胜利处理:收集战后英雄 HP,通知 MainGameManager 推进节点并存档。
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
private void CombatVictory()
|
|
|
|
|
|
{
|
|
|
|
|
|
CombatUIManager.Instance.combatMainPage.SetButtonAction(null, "Victory!", false);
|
|
|
|
|
|
|
|
|
|
|
|
// 将玩家英雄的战后 HP 与 RunSave 中的 HeroSave 对应:按 currentRun.heroes 顺序匹配
|
|
|
|
|
|
var heroResults = new List<(string heroID, int currentHP)>();
|
|
|
|
|
|
List<HeroSave> runHeroes = MainGameManager.Instance.currentRun?.heroes;
|
|
|
|
|
|
if (runHeroes != null)
|
|
|
|
|
|
{
|
|
|
|
|
|
for (int i = 0; i < Mathf.Min(characterController.playerHeroes.Count, runHeroes.Count); i++)
|
|
|
|
|
|
{
|
|
|
|
|
|
int hp = Mathf.RoundToInt(characterController.playerHeroes[i].GetAttribute("Health"));
|
|
|
|
|
|
heroResults.Add((runHeroes[i].characterDataID, hp));
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// CommandQueue 执行完毕后再切场景,避免队列中残余命令在新场景报错
|
|
|
|
|
|
CommandQueueManager.Instance.AddCommand(Cmd.Do(() =>
|
|
|
|
|
|
MainGameManager.Instance.ExitCombat(isVictory: true, heroResults)));
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 战斗失败处理:通知 MainGameManager 删档并返回主菜单。
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
private void CombatDefeat()
|
|
|
|
|
|
{
|
|
|
|
|
|
CombatUIManager.Instance.combatMainPage.SetButtonAction(null, "Defeat...", false);
|
|
|
|
|
|
|
|
|
|
|
|
CommandQueueManager.Instance.AddCommand(Cmd.Do(() =>
|
|
|
|
|
|
MainGameManager.Instance.ExitCombat(isVictory: false)));
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2026-03-20 11:56:50 -04:00
|
|
|
|
}
|