94 lines
3.1 KiB
C#
94 lines
3.1 KiB
C#
|
using Games.Events;
|
|||
|
using Games.LogicObj;
|
|||
|
using GCGame.Table;
|
|||
|
using Module.Log;
|
|||
|
using UnityEngine;
|
|||
|
using UnityEngine.EventSystems;
|
|||
|
|
|||
|
public class SimpleSkillButton : SkillButtonBase, IPointerDownHandler, IPointerUpHandler
|
|||
|
{
|
|||
|
//public GameObject PressShowImage; //增加按着时显示的图片
|
|||
|
|
|||
|
// 当前操作技能按钮的手指Id
|
|||
|
public int? CurrentFingerId { get; private set; }
|
|||
|
public bool AllowInput { get; private set; }
|
|||
|
|
|||
|
public void OnPointerDown(PointerEventData eventData)
|
|||
|
{
|
|||
|
if (CurrentFingerId == null && ProcessInput.Instance != null && !ProcessInput.Instance.isBlocked && AllowInput)
|
|||
|
{
|
|||
|
var mainPlayer = ObjManager.Instance.MainPlayer;
|
|||
|
if (mainPlayer == null)
|
|||
|
LogModule.ErrorLog("MainPlayer is Null");
|
|||
|
else if (mainPlayer.IsDisableControl())
|
|||
|
{
|
|||
|
//组队跟随,不响应技能报错
|
|||
|
if (GameManager.gameManager.PlayerDataPool.IsFollowTeam)
|
|||
|
GUIData.AddNotifyData(StrDictionary.GetClientDictionaryString("#{5128}"));
|
|||
|
// 暂时没有混乱中报错的机制
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
// 不确定这个事件同Update的周期,因此发送一次操作
|
|||
|
// 特殊处理场景不可使用技能的情况 - 这种情况不允许用户一直按着报错
|
|||
|
var useSkillResult = UseSkill();
|
|||
|
if (useSkillResult != SkillCastableCheckResult.FailScene
|
|||
|
&& useSkillResult != SkillCastableCheckResult.FailMission)
|
|||
|
{
|
|||
|
CurrentFingerId = eventData.pointerId;
|
|||
|
//if (PressShowImage != null)
|
|||
|
// PressShowImage.SetActive(true);
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
public void OnPointerUp(PointerEventData eventData)
|
|||
|
{
|
|||
|
if (CurrentFingerId == eventData.pointerId)
|
|||
|
Clear();
|
|||
|
}
|
|||
|
|
|||
|
private void Clear()
|
|||
|
{
|
|||
|
//if (PressShowImage != null && CurrentFingerId != null)
|
|||
|
// PressShowImage.SetActive(false);
|
|||
|
CurrentFingerId = null;
|
|||
|
}
|
|||
|
|
|||
|
private void Start()
|
|||
|
{
|
|||
|
EventDispatcher.Instance.Add(Games.Events.EventId.LockSkillInput, OnSkillInputUpdate);
|
|||
|
EventDispatcher.Instance.Add(Games.Events.EventId.ProcessInputBlock, OnProcessInputBlock);
|
|||
|
OnSkillInputUpdate(null);
|
|||
|
}
|
|||
|
|
|||
|
private void OnDestroy()
|
|||
|
{
|
|||
|
EventDispatcher.Instance.Remove(Games.Events.EventId.LockSkillInput, OnSkillInputUpdate);
|
|||
|
EventDispatcher.Instance.Remove(Games.Events.EventId.ProcessInputBlock, OnProcessInputBlock);
|
|||
|
}
|
|||
|
|
|||
|
private void OnProcessInputBlock(object args)
|
|||
|
{
|
|||
|
var block = (bool) args;
|
|||
|
if (block)
|
|||
|
Clear();
|
|||
|
}
|
|||
|
|
|||
|
private void OnSkillInputUpdate(object args)
|
|||
|
{
|
|||
|
AllowInput = GameManager.gameManager.PlayerDataPool.AllowSimpleInput;
|
|||
|
if (!AllowInput)
|
|||
|
Clear();
|
|||
|
}
|
|||
|
|
|||
|
private void Update()
|
|||
|
{
|
|||
|
if (CurrentFingerId != null)
|
|||
|
if (ProcessInput.Instance == null || !ProcessInput.Instance.isBlocked)
|
|||
|
UseSkill();
|
|||
|
else
|
|||
|
Clear();
|
|||
|
}
|
|||
|
}
|