88 lines
2.0 KiB
C#
88 lines
2.0 KiB
C#
// ***********************************************************************
|
|
// Assembly : Game
|
|
// Author : Kimch
|
|
// Created : 2020-11-06
|
|
// Description :
|
|
// Last Modified By :
|
|
// Last Modified On :
|
|
// ***********************************************************************
|
|
// <copyright file= "MoveJoystick" company="Kunpo"></copyright>
|
|
// <summary></summary>
|
|
// ***********************************************************************
|
|
|
|
using UnityEngine;
|
|
using UnityEngine.EventSystems;
|
|
using UnityEngine.UI;
|
|
|
|
namespace G.UI
|
|
{
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
public class MoveJoystick : Joystick
|
|
{
|
|
private Vector2 _fixedPosition = Vector2.zero;
|
|
|
|
public RectTransform pointer = null;
|
|
|
|
protected override void Start()
|
|
{
|
|
base.Start();
|
|
_fixedPosition = background.anchoredPosition;
|
|
pointer.gameObject.SetActive(false);
|
|
}
|
|
|
|
public override void OnPointerDown(PointerEventData eventData)
|
|
{
|
|
base.OnPointerDown(eventData);
|
|
OnDrag(eventData);
|
|
pointer.anchoredPosition = ScreenPointToAnchoredPosition(eventData.position);
|
|
}
|
|
|
|
public override void OnBeginDrag(PointerEventData eventData)
|
|
{
|
|
background.anchoredPosition = ScreenPointToAnchoredPosition(eventData.position);
|
|
base.OnBeginDrag(eventData);
|
|
}
|
|
|
|
public override void OnEndDrag(PointerEventData eventData)
|
|
{
|
|
base.OnEndDrag(eventData);
|
|
background.anchoredPosition = _fixedPosition;
|
|
}
|
|
|
|
protected override void OnArrowAction()
|
|
{
|
|
if (UI_Ingame.Instance)
|
|
UI_Ingame.Instance.OnDodge();
|
|
}
|
|
|
|
protected override void OnShortTap()
|
|
{
|
|
_handleTimer = 0.1f;
|
|
pointer.gameObject.SetActive(true);
|
|
pointer.GetComponent<Animator>().Play("handle_click", -1, 0);
|
|
|
|
if (UI_Ingame.Instance)
|
|
UI_Ingame.Instance.OnAttack();
|
|
}
|
|
|
|
protected override void OnLongTap()
|
|
{
|
|
}
|
|
|
|
private float _handleTimer;
|
|
private void LateUpdate()
|
|
{
|
|
if (_handleTimer > 0f)
|
|
{
|
|
_handleTimer -= Time.unscaledDeltaTime;
|
|
if (_handleTimer <= 0f)
|
|
{
|
|
pointer.gameObject.SetActive(false);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|