114 lines
3.1 KiB
C#
114 lines
3.1 KiB
C#
using Framework;
|
|
using Gameplay.Area;
|
|
using UnityEngine;
|
|
namespace Gameplay.Level.FightInfo
|
|
{
|
|
public partial class FightInfoManager
|
|
{
|
|
|
|
private float _disableTime;
|
|
|
|
public void Init()
|
|
{
|
|
|
|
}
|
|
|
|
public void LogicUpdate(float dt)
|
|
{
|
|
if (_disableTime > 0)
|
|
{
|
|
_disableTime -= dt;
|
|
}
|
|
}
|
|
|
|
public void Dispose()
|
|
{
|
|
|
|
}
|
|
|
|
public void TriggerShortClick(Vector2 screenPos)
|
|
{
|
|
// _OnShortClick(screenPos);
|
|
}
|
|
|
|
public void TriggerLongClick(Vector2 screenPos)
|
|
{
|
|
_OnLongClick(screenPos);
|
|
}
|
|
|
|
private void _OnShortClick(Vector2 screenPos)
|
|
{
|
|
if (_disableTime > 0) return;
|
|
if (!LevelManager.Instance.CurrentLevel.IsInBattle())
|
|
{
|
|
// 非战斗状态下不响应
|
|
return;
|
|
}
|
|
|
|
// 放技能过程中不响应
|
|
if (AreaManager.instance.isInSkillPreview)
|
|
{
|
|
return;
|
|
}
|
|
|
|
// 上阵区域显示中不响应
|
|
if (AreaManager.instance.readyAreaManager.isShow)
|
|
{
|
|
return;
|
|
}
|
|
|
|
// 必须没有选中的单位
|
|
if (LevelManager.Instance.CurrentLevel.selectUnit != null)
|
|
{
|
|
return;
|
|
}
|
|
_HandleClick(screenPos);
|
|
}
|
|
|
|
private void _OnLongClick(Vector2 screenPos)
|
|
{
|
|
if (_disableTime > 0) return;
|
|
if (!LevelManager.Instance.CurrentLevel.IsInBattle())
|
|
{
|
|
// 非战斗状态下不响应
|
|
return;
|
|
}
|
|
|
|
// 必须有选中的单位
|
|
// 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);
|
|
var isClickedCanControl = false;
|
|
// TODO: 目前是如果点击的是己方单位,不响应
|
|
for (int i = 0; i < units.Count; i++)
|
|
{
|
|
var unit = units[i];
|
|
if (unit.commonData.canControl)
|
|
{
|
|
isClickedCanControl = true;
|
|
break;
|
|
}
|
|
// EventManager.Instance.Send(EventManager.EventName.INFIGHT_SHOW_FIGHTINFO_UNIT, unit);
|
|
// return;
|
|
}
|
|
if (isClickedCanControl) return;
|
|
EventManager.Instance.Send(EventManager.EventName.INFIGHT_SHOW_FIGHTINFO_CELL, clickCellIndex);
|
|
}
|
|
|
|
}
|
|
}
|