BEHOLD, MY SUPER LASER PISS
This commit is contained in:
parent
084aada510
commit
e29208a2e5
23 changed files with 760 additions and 20 deletions
60
Assets/Scripts/Laser.cs
Normal file
60
Assets/Scripts/Laser.cs
Normal file
|
|
@ -0,0 +1,60 @@
|
|||
using System;
|
||||
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 GameObject beamObject;
|
||||
private GameObject beamObjectInstance;
|
||||
public float turnSpeed;
|
||||
public float offset;
|
||||
|
||||
private void Start()
|
||||
{
|
||||
CreateBeam();
|
||||
}
|
||||
|
||||
protected override void AbilityEffects()
|
||||
{
|
||||
canCooldown = false;
|
||||
currentDuration = duration;
|
||||
beamObjectInstance.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 (currentDuration <= 0)
|
||||
{
|
||||
canCooldown = true;
|
||||
beamObjectInstance.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.SetActive(false);
|
||||
}
|
||||
|
||||
private void DetectEnemies()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue