74 lines
2.0 KiB
C#
74 lines
2.0 KiB
C#
using Framework;
|
|
using Gameplay.Area;
|
|
using UnityEngine;
|
|
namespace Gameplay.Level.FightInfo
|
|
{
|
|
public partial class FightInfoManager
|
|
{
|
|
|
|
public void Init()
|
|
{
|
|
|
|
}
|
|
|
|
public void Dispose()
|
|
{
|
|
|
|
}
|
|
|
|
public void TriggerShortClick(Vector2 screenPos)
|
|
{
|
|
_OnShortClick(screenPos);
|
|
}
|
|
|
|
public void TriggerLongClick(Vector2 screenPos)
|
|
{
|
|
_OnLongClick(screenPos);
|
|
}
|
|
|
|
private void _OnShortClick(Vector2 screenPos)
|
|
{
|
|
// 必须没有选中的单位
|
|
if (LevelManager.Instance.CurrentLevel.selectUnit != null)
|
|
{
|
|
return;
|
|
}
|
|
_HandleClick(screenPos);
|
|
}
|
|
|
|
private void _OnLongClick(Vector2 screenPos)
|
|
{
|
|
// 必须有选中的单位
|
|
if (LevelManager.Instance.CurrentLevel.selectUnit == null)
|
|
{
|
|
return;
|
|
}
|
|
_HandleClick(screenPos);
|
|
}
|
|
|
|
private void _HandleClick(Vector2 screenPos)
|
|
{
|
|
var tgsMap = LevelManager.Instance.CurrentLevel.Map.TerrainGridSystem;
|
|
var clickCellIndex = GroundHitHelper.CalcHitCellIndex(screenPos, tgsMap);
|
|
if (clickCellIndex < 0)
|
|
{
|
|
DebugUtil.LogError("click cell index < 0");
|
|
return;
|
|
}
|
|
var units = AreaManager.instance.GetUnitsByCellIndex(clickCellIndex);
|
|
for (int i = 0; i < units.Count; i++)
|
|
{
|
|
var unit = units[i];
|
|
if (unit.commonData.canControl)
|
|
{
|
|
continue;
|
|
}
|
|
EventManager.Instance.Send(EventManager.EventName.INFIGHT_SHOW_FIGHTINFO_UNIT, unit);
|
|
return;
|
|
}
|
|
EventManager.Instance.Send(EventManager.EventName.INFIGHT_SHOW_FIGHTINFO_CELL, clickCellIndex);
|
|
}
|
|
|
|
}
|
|
}
|