2026-01-15 02:15:35 +00:00
|
|
|
using System.Collections;
|
2026-01-11 23:28:01 +00:00
|
|
|
using UnityEngine;
|
|
|
|
|
using UnityEngine.UI;
|
|
|
|
|
|
|
|
|
|
public class AimArrowController : MonoBehaviour
|
|
|
|
|
{
|
|
|
|
|
public Image arrow;
|
2026-01-11 23:53:38 +00:00
|
|
|
public Transform projectileParent;
|
2026-01-11 23:28:01 +00:00
|
|
|
|
2026-01-14 04:16:15 +00:00
|
|
|
float m_attackTime, m_attackLifeTime;
|
2026-01-11 23:28:01 +00:00
|
|
|
|
|
|
|
|
void Start()
|
|
|
|
|
{
|
2026-01-15 07:17:50 +00:00
|
|
|
arrow.enabled = false;
|
2026-01-14 04:16:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void OnEnable()
|
|
|
|
|
{
|
|
|
|
|
var unit = IngameMgr.Ins.Get_CurUnitTData();
|
|
|
|
|
m_attackLifeTime = m_attackTime = unit.f_AttackSpeed;
|
|
|
|
|
}
|
|
|
|
|
|
2026-01-14 07:29:45 +00:00
|
|
|
public void Set_AttackLifeTime()
|
|
|
|
|
{
|
|
|
|
|
var unit = IngameMgr.Ins.Get_CurUnitTData();
|
|
|
|
|
m_attackLifeTime = unit.f_AttackSpeed - IngameMgr.Ins.Get_SkillValue(eSkillType.AttackSpeedUp);
|
|
|
|
|
}
|
|
|
|
|
|
2026-01-14 04:16:15 +00:00
|
|
|
private void Update()
|
|
|
|
|
{
|
|
|
|
|
m_attackLifeTime -= Time.deltaTime;
|
|
|
|
|
if (m_attackLifeTime <= 0)
|
|
|
|
|
{
|
|
|
|
|
m_attackLifeTime = m_attackTime;
|
2026-01-15 02:15:35 +00:00
|
|
|
StartCoroutine(Co_Shoot());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
IEnumerator Co_Shoot()
|
|
|
|
|
{
|
|
|
|
|
int count = 1 + (int)IngameMgr.Ins.Get_SkillValue(eSkillType.DoubleShot);
|
|
|
|
|
for (int i = 0; i < count; i++)
|
|
|
|
|
{
|
2026-01-14 04:49:44 +00:00
|
|
|
Shoot();
|
2026-01-15 02:15:35 +00:00
|
|
|
yield return new WaitForSeconds(0.15f);
|
2026-01-14 04:16:15 +00:00
|
|
|
}
|
2026-01-11 23:28:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void OnAimStart(Vector2 screenPos)
|
|
|
|
|
{
|
|
|
|
|
UpdateArrow(screenPos);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void OnAimDrag(Vector2 screenPos)
|
|
|
|
|
{
|
|
|
|
|
UpdateArrow(screenPos);
|
|
|
|
|
}
|
|
|
|
|
|
2026-01-15 07:17:50 +00:00
|
|
|
public void OnAimEnd()
|
|
|
|
|
{
|
|
|
|
|
arrow.enabled = false;
|
|
|
|
|
}
|
|
|
|
|
|
2026-01-14 04:49:44 +00:00
|
|
|
void Shoot()
|
2026-01-11 23:28:01 +00:00
|
|
|
{
|
2026-01-13 00:46:52 +00:00
|
|
|
var unit = IngameMgr.Ins.Get_CurUnitTData();
|
2026-01-14 22:48:21 +00:00
|
|
|
|
|
|
|
|
ProjectileData basePd = new ProjectileData
|
2026-01-13 06:20:15 +00:00
|
|
|
{
|
|
|
|
|
IsPC = true,
|
|
|
|
|
m_Data = table_projectile.Ins.Get_Data(unit.n_ProjectileID),
|
2026-01-13 07:33:06 +00:00
|
|
|
tf_Start = arrow.transform,
|
2026-01-14 22:48:21 +00:00
|
|
|
Dmg = unit.n_DefaultAttack + (int)IngameMgr.Ins.Get_SkillValue(eSkillType.AttackUp),
|
2026-01-11 23:28:01 +00:00
|
|
|
|
2026-01-14 22:48:21 +00:00
|
|
|
PreviousArrow = (int)IngameMgr.Ins.Get_SkillValue(eSkillType.PreviousArrow),
|
|
|
|
|
DiagonalArrow = (int)IngameMgr.Ins.Get_SkillValue(eSkillType.DiagonalArrow),
|
2026-01-14 21:45:26 +00:00
|
|
|
|
2026-01-14 22:48:21 +00:00
|
|
|
ArrowLeftRight = (int)IngameMgr.Ins.Get_SkillValue(eSkillType.ArrowLeftRight),
|
|
|
|
|
ArrowUpDown = (int)IngameMgr.Ins.Get_SkillValue(eSkillType.ArrowUpDown),
|
2026-01-14 23:18:10 +00:00
|
|
|
Bounce = (int)IngameMgr.Ins.Get_SkillValue(eSkillType.Bounce),
|
|
|
|
|
Pierce = (int)IngameMgr.Ins.Get_SkillValue(eSkillType.ProjectilePierce)
|
2026-01-14 22:48:21 +00:00
|
|
|
};
|
2026-01-14 21:45:26 +00:00
|
|
|
|
2026-01-14 22:48:21 +00:00
|
|
|
int lineCnt = 1 + basePd.PreviousArrow;
|
|
|
|
|
int diagCnt = 1 + basePd.DiagonalArrow;
|
|
|
|
|
|
|
|
|
|
for (int l = 0; l < lineCnt; l++)
|
2026-01-14 21:45:26 +00:00
|
|
|
{
|
2026-01-14 22:48:21 +00:00
|
|
|
for (int d = 0; d < diagCnt; d++)
|
2026-01-14 21:45:26 +00:00
|
|
|
{
|
2026-01-14 22:48:21 +00:00
|
|
|
ProjectileMgr.Ins.Shoot_Projectile(new ProjectileData
|
|
|
|
|
{
|
|
|
|
|
LineIndex = l,
|
|
|
|
|
DiagIndex = d,
|
|
|
|
|
PreviousArrow = basePd.PreviousArrow,
|
|
|
|
|
DiagonalArrow = basePd.DiagonalArrow,
|
|
|
|
|
|
|
|
|
|
ArrowLeftRight = basePd.ArrowLeftRight,
|
|
|
|
|
ArrowUpDown = basePd.ArrowUpDown,
|
|
|
|
|
Bounce = basePd.Bounce,
|
2026-01-14 23:18:10 +00:00
|
|
|
Pierce = basePd.Pierce,
|
2026-01-14 22:48:21 +00:00
|
|
|
|
|
|
|
|
IsPC = basePd.IsPC,
|
|
|
|
|
m_Data = basePd.m_Data,
|
|
|
|
|
tf_Start = basePd.tf_Start,
|
|
|
|
|
Dmg = basePd.Dmg
|
|
|
|
|
});
|
|
|
|
|
}
|
2026-01-14 21:45:26 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2026-01-15 22:22:16 +00:00
|
|
|
public float m_AngleSpeed = 1.5f;
|
|
|
|
|
void UpdateArrow(Vector2 screenPos)
|
2026-01-11 23:28:01 +00:00
|
|
|
{
|
2026-01-15 22:22:16 +00:00
|
|
|
Debug.Log(screenPos);
|
2026-01-15 07:17:50 +00:00
|
|
|
arrow.enabled = true;
|
|
|
|
|
|
2026-01-15 22:22:16 +00:00
|
|
|
Vector2 baseScreenPos = Camera.main.WorldToScreenPoint(projectileParent.position);
|
|
|
|
|
Vector2 dir = screenPos - baseScreenPos;
|
|
|
|
|
dir.y = Mathf.Abs(dir.y);
|
|
|
|
|
float angle = Mathf.Atan2(dir.y, dir.x) * Mathf.Rad2Deg - 90f;
|
|
|
|
|
angle *= m_AngleSpeed;
|
2026-01-14 04:49:44 +00:00
|
|
|
angle = Mathf.Clamp(angle, -80f, 80f);
|
2026-01-11 23:28:01 +00:00
|
|
|
arrow.rectTransform.rotation = Quaternion.Euler(0, 0, angle);
|
|
|
|
|
}
|
|
|
|
|
}
|