you really gotta calm down, marisa...
This commit is contained in:
parent
13bb58ea03
commit
b9fb490dce
68 changed files with 990 additions and 44 deletions
|
|
@ -1,79 +0,0 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Core.Extensions;
|
||||
using UnityEngine;
|
||||
|
||||
public class Laser : PlayerAbility
|
||||
{
|
||||
[Header("Laser Properties")]
|
||||
public float length;
|
||||
public float width;
|
||||
public float duration;
|
||||
private float currentDuration;
|
||||
[Header("Beam")]
|
||||
[SerializeField] private BeamCollider beamObject;
|
||||
private BeamCollider beamObjectInstance;
|
||||
public float turnSpeed;
|
||||
public float offset;
|
||||
[Header("Weapon Properties")]
|
||||
[HideInInspector] public List<Entity> enemyList = new();
|
||||
public float damageDebounceTime;
|
||||
private float currentDebounce;
|
||||
public float damage;
|
||||
private void Start()
|
||||
{
|
||||
CreateBeam();
|
||||
}
|
||||
|
||||
protected override void AbilityEffects()
|
||||
{
|
||||
canCooldown = false;
|
||||
currentDuration = duration;
|
||||
currentDebounce = damageDebounceTime;
|
||||
beamObjectInstance.gameObject.SetActive(true);
|
||||
transform.Lookat2D(thisPlayer.mouseWorldPos);
|
||||
}
|
||||
|
||||
protected override void Update()
|
||||
{
|
||||
if (currentDuration > 0)
|
||||
{
|
||||
Vector3 direction = (thisPlayer.mouseWorldPos - (Vector2)transform.position).normalized;
|
||||
float angle = Mathf.Atan2(direction.y, direction.x) * Mathf.Rad2Deg;
|
||||
transform.rotation = Quaternion.RotateTowards(beamObjectInstance.transform.rotation, Quaternion.Euler(0,0,angle), turnSpeed * Time.deltaTime);
|
||||
currentDuration -= Time.deltaTime;
|
||||
if (currentDebounce > 0)
|
||||
{
|
||||
currentDebounce -= Time.deltaTime;
|
||||
if (currentDebounce <= 0)
|
||||
{
|
||||
foreach (Entity enemy in enemyList.ToArray())
|
||||
{
|
||||
if (!enemy)
|
||||
{
|
||||
enemyList.Remove(enemy);
|
||||
continue;
|
||||
}
|
||||
enemy.TakeDamage(damage);
|
||||
}
|
||||
currentDebounce = damageDebounceTime;
|
||||
}
|
||||
}
|
||||
if (currentDuration <= 0)
|
||||
{
|
||||
canCooldown = true;
|
||||
beamObjectInstance.gameObject.SetActive(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void CreateBeam()
|
||||
{
|
||||
beamObjectInstance = Instantiate(beamObject, transform.position, Quaternion.identity);
|
||||
beamObjectInstance.transform.SetParent(transform);
|
||||
beamObjectInstance.transform.localScale = new Vector3(length, width, 1);
|
||||
beamObjectInstance.transform.Translate(Vector3.right * (beamObjectInstance.transform.localScale.x * 0.5f) + new Vector3(offset, 0, 0));
|
||||
beamObjectInstance.thisLaser = this;
|
||||
beamObjectInstance.gameObject.SetActive(false);
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue