42 lines
1.5 KiB
C#
42 lines
1.5 KiB
C#
using System.Collections.Generic;
|
|
using Lean.Pool;
|
|
using UnityEngine;
|
|
|
|
namespace Continentis.MainGame.UI
|
|
{
|
|
public class ArrowsPage : UIPageBase
|
|
{
|
|
public PointerArrow mainPointerArrow;
|
|
public List<PointerArrow> pointerArrows;
|
|
|
|
public List<PointerArrow> otherPointerArrows =>
|
|
pointerArrows.FindAll(pointerArrow => pointerArrow != mainPointerArrow);
|
|
|
|
public void GeneratePointerArrow(Vector3 startPosition, Vector3 endPosition, bool isMain)
|
|
{
|
|
var pointerArrow = LeanPool.Spawn(MainGameManager.Instance.basePrefabs.pointerArrow, transform)
|
|
.GetComponent<PointerArrow>();
|
|
pointerArrow.SetArrow(startPosition, endPosition);
|
|
pointerArrows.Add(pointerArrow);
|
|
|
|
if (isMain) mainPointerArrow = pointerArrow;
|
|
}
|
|
|
|
public void ClearPointerArrows()
|
|
{
|
|
foreach (var pointerArrow in pointerArrows) LeanPool.Despawn(pointerArrow.gameObject);
|
|
pointerArrows.Clear();
|
|
mainPointerArrow = null;
|
|
}
|
|
|
|
/// <summary>移除并回收最后一支箭头(用于多目标选择的撤销操作)。</summary>
|
|
public void RemoveLastPointerArrow()
|
|
{
|
|
if (pointerArrows.Count == 0) return;
|
|
PointerArrow last = pointerArrows[^1];
|
|
pointerArrows.RemoveAt(pointerArrows.Count - 1);
|
|
if (last == mainPointerArrow) mainPointerArrow = null;
|
|
LeanPool.Despawn(last.gameObject);
|
|
}
|
|
}
|
|
} |