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

40 lines
982 B
C#
Raw Normal View History

2023-12-13 16:20:41 +08:00
using Gameplay.Unit;
2023-08-22 19:08:45 +08:00
namespace Gameplay.Level
{
public partial class Level
{
2023-10-19 15:00:19 +08:00
public GameUnit selectUnit { 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();
selectUnit = newUnit;
}
public void SelectUnit(uint id)
{
2023-12-14 18:25:52 +08:00
var newUnit = GameUnitManager.instance.infightUnits.Search(id);
2023-08-22 19:08:45 +08:00
if (selectUnit == newUnit) return;
2023-10-19 15:00:19 +08:00
if (newUnit.commonData.canSelect)
2023-08-22 19:08:45 +08:00
{
UnSelectUnit();
newUnit.OnSelect();
selectUnit = newUnit;
}
}
public void UnSelectUnit()
{
if (selectUnit == null) return;
selectUnit.OnUnSelect();
selectUnit = null;
}
}
}