66 lines
2.4 KiB
C#
66 lines
2.4 KiB
C#
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
|
|
public class NondirectionalLaser : Laser
|
|
{
|
|
[SerializeField] private int beamCount = 1;
|
|
[SerializeField] private Transform beamRoot;
|
|
private List<BeamCollider> beamInstances = new();
|
|
|
|
protected override void AbilityEffects()
|
|
{
|
|
canCooldown = false;
|
|
currentDuration = duration;
|
|
currentDebounce = damageDebounceTime;
|
|
beamRoot.gameObject.SetActive(true);
|
|
}
|
|
protected override void Update()
|
|
{
|
|
//we're doing this the stupid way i guess because i am stupid
|
|
if (currentCooldown > 0)
|
|
{
|
|
currentCooldown -= Time.deltaTime;
|
|
}
|
|
if (currentDuration > 0)
|
|
{
|
|
// i think i can just put spinobject in it and that'll work lol
|
|
if (currentDebounce > 0)
|
|
{
|
|
currentDebounce -= Time.deltaTime;
|
|
if (currentDebounce <= 0)
|
|
{
|
|
foreach (Entity enemy in enemyList.ToArray())
|
|
{
|
|
if (!enemy)
|
|
{
|
|
enemyList.Remove(enemy);
|
|
continue;
|
|
}
|
|
enemy.TakeDamage(power);
|
|
}
|
|
currentDebounce = damageDebounceTime;
|
|
}
|
|
}
|
|
if (currentDuration <= 0)
|
|
{
|
|
canCooldown = true;
|
|
beamRoot.gameObject.SetActive(false);
|
|
}
|
|
}
|
|
}
|
|
protected override void CreateBeam()
|
|
{
|
|
float rotationAmount = 360f / beamCount;
|
|
for (int i = 0; i < beamCount; i++)
|
|
{
|
|
BeamCollider newBeamObjectInstance = Instantiate(beamObject, transform.position, Quaternion.identity);
|
|
beamInstances.Add(newBeamObjectInstance);
|
|
newBeamObjectInstance.transform.SetParent(beamRoot);
|
|
newBeamObjectInstance.transform.localScale = new Vector3(length, width, 1);
|
|
newBeamObjectInstance.transform.Translate(Vector3.right * (newBeamObjectInstance.transform.localScale.x * 0.5f) + new Vector3(offset, 0, 0));
|
|
newBeamObjectInstance.transform.RotateAround(beamRoot.position, Vector3.forward, rotationAmount * i);
|
|
newBeamObjectInstance.thisLaser = this;
|
|
}
|
|
beamRoot.gameObject.SetActive(false);
|
|
}
|
|
}
|