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

42 lines
1007 B
C#
Raw Normal View History

2023-08-22 19:08:45 +08:00
using Framework;
using Gameplay.Common;
using UnityEngine;
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)
{
var newUnit = GameUnitMapper.Inst.GetUnitById(id);
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;
}
}
}