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

81 lines
2.0 KiB
C#

using Framework;
using Gameplay.Character;
using Gameplay.Common;
using Gameplay.Level.Select;
using Gameplay.Unit;
using PhxhSDK;
using static Framework.Wrapper.Unit;
namespace Gameplay.Level
{
public partial class Level
{
public GameUnit selectUnit
{
get
{
return selectView.selectUnit;
}
}
public SelectView selectView { get; private set; }
public void SelectUnit(GameUnit newUnit)
{
if (selectUnit == newUnit)
return;
if (!newUnit.commonData.canSelect)
return;
if (Unit.Data.EGameUnitType.Character == newUnit.gameunitType &&
newUnit is Character.Character character)
{
EventManager.Instance.Send(EventManager.EventName.INFIGHT_AUDIO_SELECT_UNIT, character.ConfigId);
}
UnSelectUnit();
newUnit.OnSelect();
selectView.SetOwner(newUnit);
_ShowGrid();
}
private void _ShowGrid()
{
if (!GameSettingManager.Instance.SettingData.IsOpenGrid)
{
if (IsInBattle())
{
_map.ShowInfo(Map.InfoMask.ShowCells, true);
}
}
}
public void SelectUnit(uint id)
{
var newUnit = GameUnitManager.instance.infightUnits.Search(id);
SelectUnit(newUnit);
}
public void UnSelectUnit()
{
if (selectUnit == null) return;
selectUnit.OnUnSelect();
selectView.SetOwner(null);
_HideGrid();
}
private void _HideGrid()
{
if (!GameSettingManager.Instance.SettingData.IsOpenGrid)
{
if (IsInBattle())
{
_map.ShowInfo(Map.InfoMask.ShowCells, false);
}
}
}
}
}