웅냥
This commit is contained in:
49
Assets/Scripts/Unicorn/Boss/AttackManager.cs
Normal file
49
Assets/Scripts/Unicorn/Boss/AttackManager.cs
Normal file
@@ -0,0 +1,49 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Unicorn.Hitbox;
|
||||
using Unity.Collections;
|
||||
using Unity.Collections.LowLevel.Unsafe;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Unicorn.Boss
|
||||
{
|
||||
public class AttackManager: MonoBehaviour
|
||||
{
|
||||
private Dictionary<EntityId, float> _projMap;
|
||||
private Dictionary<EntityId, UnicornHitbox> _projHitboxMap;
|
||||
private const float Lifetime = 5f;
|
||||
|
||||
private void Start()
|
||||
{
|
||||
_projMap = new Dictionary<EntityId, float>();
|
||||
_projHitboxMap = new Dictionary<EntityId, UnicornHitbox>();
|
||||
}
|
||||
|
||||
private void FixedUpdate()
|
||||
{
|
||||
foreach (Transform o in transform)
|
||||
{
|
||||
var entityId = o.GetEntityId();
|
||||
if (_projMap.TryAdd(entityId, 0f))
|
||||
{
|
||||
if (o.TryGetComponent(out UnicornHitbox hitbox))
|
||||
_projHitboxMap.Add(entityId, hitbox);
|
||||
}
|
||||
|
||||
if (o.gameObject.activeInHierarchy)
|
||||
_projMap[entityId] += Time.fixedDeltaTime;
|
||||
else continue;
|
||||
|
||||
if (_projMap[entityId] > Lifetime)
|
||||
{
|
||||
o.gameObject.SetActive(false);
|
||||
_projMap[entityId] = 0f;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!_projHitboxMap.TryGetValue(entityId, out var unicornHitbox)) continue;
|
||||
o.transform.Translate(o.right * (unicornHitbox.hitboxData.hitboxSpeed * Time.fixedDeltaTime), Space.World);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
3
Assets/Scripts/Unicorn/Boss/AttackManager.cs.meta
Normal file
3
Assets/Scripts/Unicorn/Boss/AttackManager.cs.meta
Normal file
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 88e10741af6249658ff3e467495bf561
|
||||
timeCreated: 1778331143
|
||||
@@ -1,8 +1,8 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using DG.Tweening;
|
||||
using Unicorn.Hitbox;
|
||||
using UnityEngine;
|
||||
using NotImplementedException = System.NotImplementedException;
|
||||
|
||||
namespace Unicorn.Boss
|
||||
{
|
||||
@@ -15,6 +15,7 @@ namespace Unicorn.Boss
|
||||
|
||||
private UnicornPhase _unicornPhase = UnicornPhase.Start;
|
||||
private Queue<GameObject> _p1Ps = new Queue<GameObject>();
|
||||
private SpriteRenderer _renderer;
|
||||
private const float P1PC = 12;
|
||||
|
||||
public Transform projContainer;
|
||||
@@ -23,14 +24,17 @@ namespace Unicorn.Boss
|
||||
|
||||
private void Start()
|
||||
{
|
||||
_renderer = GetComponent<SpriteRenderer>();
|
||||
StartCoroutine(Started());
|
||||
base.Start();
|
||||
}
|
||||
|
||||
private IEnumerator Started()
|
||||
{
|
||||
while (_p1Ps.Count < 50)
|
||||
const float target = 360*5/P1PC;
|
||||
while (_p1Ps.Count < target)
|
||||
{
|
||||
for (var i = 0; i < 5 && _p1Ps.Count < 50; i++) //프레임당 5개씩 생성
|
||||
for (var i = 0; i < 5 && _p1Ps.Count < target; i++) //프레임당 5개씩 생성
|
||||
{
|
||||
var instantiate = Instantiate(phase1Proj, projContainer);
|
||||
_p1Ps.Enqueue(instantiate);
|
||||
@@ -46,26 +50,52 @@ namespace Unicorn.Boss
|
||||
|
||||
}
|
||||
|
||||
// 수정된 Phase1 로직
|
||||
private IEnumerator Phase1()
|
||||
{
|
||||
_unicornPhase = UnicornPhase.P1;
|
||||
for (int i = 0; i < 360 / P1PC; i++)
|
||||
float angleStep = 360f / P1PC; // 각도 간격 (30도)
|
||||
|
||||
for (int i = 0; i < P1PC; i++)
|
||||
{
|
||||
var dequeue = _p1Ps.Dequeue();
|
||||
dequeue.SetActive(true);
|
||||
dequeue.transform.position = transform.position;
|
||||
var rotationEulerAngles = transform.rotation.eulerAngles;
|
||||
rotationEulerAngles.z += (360 / P1PC) * i;
|
||||
dequeue.transform.rotation = Quaternion.Euler(rotationEulerAngles);
|
||||
float targetAngle = transform.rotation.eulerAngles.z + (angleStep * i);
|
||||
dequeue.transform.rotation = Quaternion.Euler(0, 0, targetAngle);
|
||||
_p1Ps.Enqueue(dequeue);
|
||||
yield return new WaitForSeconds(.2f);
|
||||
}
|
||||
yield return new WaitForSeconds(5);
|
||||
yield return new WaitForSeconds(1);
|
||||
StartCoroutine(Phase1());
|
||||
}
|
||||
|
||||
protected override void OnKnockback(DamageInfo info)
|
||||
{
|
||||
//No KnockBack
|
||||
|
||||
}
|
||||
|
||||
protected override void OnDeath()
|
||||
{
|
||||
transform.DOScale(0f, 3f).SetEase(Ease.Linear).OnComplete(() =>
|
||||
{
|
||||
gameObject.SetActive(false);
|
||||
base.OnDeath();
|
||||
});
|
||||
}
|
||||
|
||||
protected override void OnDamaged(DamageInfo info)
|
||||
{
|
||||
StopCoroutine(HitColor());
|
||||
StartCoroutine(HitColor());
|
||||
base.OnDamaged(info);
|
||||
}
|
||||
|
||||
private IEnumerator HitColor()
|
||||
{
|
||||
_renderer.color = new Color(1f, 0.8f, 0.8f);
|
||||
yield return new WaitForSeconds(0.5f);
|
||||
_renderer.color = Color.white;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user