NLDClient-yudde/ProjectNLD/Assets/Code/Scripts/Gameplay/Level/Level.Select.cs

49 lines
1.2 KiB
C#
Raw Normal View History

2024-09-27 19:05:49 +08:00
using Gameplay.Level.Select;
2023-12-13 16:20:41 +08:00
using Gameplay.Unit;
using PhxhSDK;
2023-08-22 19:08:45 +08:00
namespace Gameplay.Level
{
public partial class Level
{
2024-09-27 19:05:49 +08:00
public GameUnit selectUnit
{
get
{
return selectView.selectUnit;
}
}
public SelectView selectView { get; private set; }
2023-08-22 19:08:45 +08:00
public void SelectUnit(GameUnit newUnit)
{
if (selectUnit == newUnit) return;
2023-10-19 15:00:19 +08:00
if (!newUnit.commonData.canSelect)
2023-08-22 19:08:45 +08:00
return;
UnSelectUnit();
newUnit.OnSelect();
2024-09-27 19:05:49 +08:00
selectView.SetOwner(newUnit);
// 居中镜头
if (LevelManager.Instance.CurrentLevel.isInBattle)
{
CameraManager.Instance.MainCamera.GetComponent<CameraController>().KeepCenter(newUnit.transform.position);
}
2023-08-22 19:08:45 +08:00
}
public void SelectUnit(uint id)
{
2023-12-14 18:25:52 +08:00
var newUnit = GameUnitManager.instance.infightUnits.Search(id);
2024-09-27 19:05:49 +08:00
SelectUnit(newUnit);
2023-08-22 19:08:45 +08:00
}
public void UnSelectUnit()
{
if (selectUnit == null) return;
selectUnit.OnUnSelect();
2024-09-27 19:05:49 +08:00
selectView.SetOwner(null);
2023-08-22 19:08:45 +08:00
}
}
}