화살표 지정하면 해당 위치로 계속 쏘기
This commit is contained in:
parent
1afddcaefd
commit
1cdcf31548
|
|
@ -1,5 +1,3 @@
|
||||||
화살표 지정하면 해당 위치로 계속 쏘기
|
|
||||||
|
|
||||||
실제 스킬 선택
|
실제 스킬 선택
|
||||||
스킬 15종
|
스킬 15종
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -9,16 +9,33 @@ public class AimArrowController : MonoBehaviour
|
||||||
|
|
||||||
Vector2 startPos;
|
Vector2 startPos;
|
||||||
bool isAiming;
|
bool isAiming;
|
||||||
|
float m_attackTime, m_attackLifeTime;
|
||||||
|
|
||||||
void Start()
|
void Start()
|
||||||
{
|
{
|
||||||
arrow.enabled = false;
|
//arrow.enabled = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void OnEnable()
|
||||||
|
{
|
||||||
|
var unit = IngameMgr.Ins.Get_CurUnitTData();
|
||||||
|
m_attackLifeTime = m_attackTime = unit.f_AttackSpeed;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void Update()
|
||||||
|
{
|
||||||
|
m_attackLifeTime -= Time.deltaTime;
|
||||||
|
if (m_attackLifeTime <= 0)
|
||||||
|
{
|
||||||
|
m_attackLifeTime = m_attackTime;
|
||||||
|
OnAimEnd();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void OnAimStart(Vector2 screenPos)
|
public void OnAimStart(Vector2 screenPos)
|
||||||
{
|
{
|
||||||
isAiming = true;
|
isAiming = true;
|
||||||
arrow.enabled = true;
|
//arrow.enabled = true;
|
||||||
UpdateArrow(screenPos);
|
UpdateArrow(screenPos);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -30,7 +47,7 @@ public class AimArrowController : MonoBehaviour
|
||||||
|
|
||||||
public void OnAimEnd()
|
public void OnAimEnd()
|
||||||
{
|
{
|
||||||
arrow.enabled = false;
|
//arrow.enabled = false;
|
||||||
isAiming = false;
|
isAiming = false;
|
||||||
|
|
||||||
var unit = IngameMgr.Ins.Get_CurUnitTData();
|
var unit = IngameMgr.Ins.Get_CurUnitTData();
|
||||||
|
|
|
||||||
|
|
@ -1,38 +0,0 @@
|
||||||
using UnityEngine;
|
|
||||||
|
|
||||||
public class AimController : MonoBehaviour
|
|
||||||
{
|
|
||||||
public LineRenderer line;
|
|
||||||
public float maxDistance = 5f;
|
|
||||||
|
|
||||||
private Vector2 startPos;
|
|
||||||
private bool isAiming;
|
|
||||||
|
|
||||||
void Update()
|
|
||||||
{
|
|
||||||
if (Input.GetMouseButtonDown(0))
|
|
||||||
{
|
|
||||||
startPos = Camera.main.ScreenToWorldPoint(Input.mousePosition);
|
|
||||||
isAiming = true;
|
|
||||||
line.enabled = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (Input.GetMouseButton(0) && isAiming)
|
|
||||||
{
|
|
||||||
Vector2 currentPos = Camera.main.ScreenToWorldPoint(Input.mousePosition);
|
|
||||||
Vector2 dir = Vector2.ClampMagnitude(currentPos - startPos, maxDistance);
|
|
||||||
|
|
||||||
line.SetPosition(0, transform.position);
|
|
||||||
line.SetPosition(1, (Vector2)transform.position + dir);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (Input.GetMouseButtonUp(0) && isAiming)
|
|
||||||
{
|
|
||||||
Vector2 endPos = Camera.main.ScreenToWorldPoint(Input.mousePosition);
|
|
||||||
Vector2 shootDir = (endPos - startPos).normalized;
|
|
||||||
|
|
||||||
line.enabled = false;
|
|
||||||
isAiming = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,2 +0,0 @@
|
||||||
fileFormatVersion: 2
|
|
||||||
guid: bc2eb6f2e5a4e2e449cd1e1e4160ad82
|
|
||||||
|
|
@ -17,6 +17,6 @@ public class AimInputArea : MonoBehaviour, IPointerDownHandler, IPointerUpHandle
|
||||||
|
|
||||||
public void OnPointerUp(PointerEventData eventData)
|
public void OnPointerUp(PointerEventData eventData)
|
||||||
{
|
{
|
||||||
aim.OnAimEnd();
|
//aim.OnAimEnd();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Loading…
Reference in New Issue