113 lines
4.0 KiB
C#
113 lines
4.0 KiB
C#
using Continentis.MainGame.Card;
|
|
using Continentis.MainGame.Character;
|
|
using Continentis.MainGame.Combat;
|
|
using Continentis.MainGame.UI;
|
|
using UnityEngine;
|
|
using UnityEngine.InputSystem;
|
|
|
|
namespace Continentis.MainGame
|
|
{
|
|
public partial class CombatUIManager : UIManagerBase
|
|
{
|
|
public new static CombatUIManager Instance => instance as CombatUIManager;
|
|
|
|
public Camera combatCamera;
|
|
public Camera uiCamera;
|
|
public CombatMainPage combatMainPage;
|
|
public InformationPage informationPage;
|
|
public HUDPage hudPage;
|
|
public ArrowsPage arrowsPage;
|
|
}
|
|
|
|
public partial class CombatUIManager
|
|
{
|
|
public CardViewBase hoveringCardView;
|
|
public CardViewBase selectingCardView;
|
|
public CombatCharacterViewBase hoveringCharacterView;
|
|
public CombatCharacterViewBase selectingCharacterView;
|
|
}
|
|
|
|
public partial class CombatUIManager
|
|
{
|
|
private void Update()
|
|
{
|
|
ManageCharacterViews();
|
|
}
|
|
|
|
public bool IsNoOtherUIPageOpen()
|
|
{
|
|
return uiPageList.Count == 1 && uiPageList.Contains(combatMainPage);
|
|
}
|
|
|
|
public void UpdateAll()
|
|
{
|
|
combatMainPage.teamSwitchButton.UpdateTeamPileText(CombatMainManager.Instance.characterController.playerTeam);
|
|
}
|
|
|
|
/// <summary>是否正处于多目标选择模式(左键/右键由 HandCardView 接管)。</summary>
|
|
public bool IsInMultiTargetMode()
|
|
{
|
|
return selectingCardView is HandCardView handCard
|
|
&& handCard.card.attributeSubmodule.targetCount > 1;
|
|
}
|
|
}
|
|
|
|
public partial class CombatUIManager
|
|
{
|
|
private void ManageCharacterViews()
|
|
{
|
|
if (!IsNoOtherUIPageOpen())
|
|
{
|
|
return;
|
|
}
|
|
|
|
bool isMultiTargetMode = IsInMultiTargetMode();
|
|
|
|
Ray ray = combatCamera.ScreenPointToRay(Mouse.current.position.ReadValue());
|
|
|
|
if (Physics.Raycast(ray, out RaycastHit hit, 2048, LayerMask.GetMask("Combat")))
|
|
{
|
|
if (hit.collider.gameObject.CompareTag("Character"))
|
|
{
|
|
hoveringCharacterView ??= hit.collider.GetComponent<CombatCharacterViewBase>();
|
|
hoveringCharacterView.SetOutline(true);
|
|
|
|
// 多目标模式下,左键由 HandCardView 处理,跳过默认的角色面板选中逻辑
|
|
if (!isMultiTargetMode && Mouse.current.leftButton.wasPressedThisFrame)
|
|
{
|
|
if (hoveringCharacterView == selectingCharacterView)
|
|
{
|
|
informationPage.characterInformationPanel.Show();
|
|
informationPage.characterInformationPanel.Initialize(hoveringCharacterView.character);
|
|
}
|
|
else
|
|
{
|
|
selectingCharacterView?.hudContainer.DisableHUD("SelectingDot");
|
|
selectingCharacterView = hoveringCharacterView;
|
|
selectingCharacterView.hudContainer.EnableHUD("SelectingDot");
|
|
}
|
|
}
|
|
}
|
|
else
|
|
{
|
|
if (!isMultiTargetMode && Mouse.current.leftButton.wasPressedThisFrame)
|
|
{
|
|
selectingCharacterView?.hudContainer.DisableHUD("SelectingDot");
|
|
selectingCharacterView = null;
|
|
}
|
|
}
|
|
}
|
|
else
|
|
{
|
|
hoveringCharacterView?.SetOutline(false);
|
|
hoveringCharacterView = null;
|
|
|
|
if (!isMultiTargetMode && Mouse.current.leftButton.wasPressedThisFrame)
|
|
{
|
|
selectingCharacterView?.hudContainer.DisableHUD("SelectingDot");
|
|
selectingCharacterView = null;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
} |