alot of stuff i forgot to commit
This commit is contained in:
parent
fc2329a873
commit
b8d516e734
60 changed files with 7397 additions and 64 deletions
56
Assets/Scripts/Abilities/ChargedShot.cs
Normal file
56
Assets/Scripts/Abilities/ChargedShot.cs
Normal file
|
|
@ -0,0 +1,56 @@
|
|||
using System;
|
||||
using Core.Extensions;
|
||||
using UnityEngine;
|
||||
|
||||
public class ChargedShot : Ability
|
||||
{
|
||||
[Header("Projectile Stats")]
|
||||
[SerializeField] private Projectile projectile;
|
||||
[SerializeField] private float projectileSpeed;
|
||||
[SerializeField] private float projectileLifetime;
|
||||
[SerializeField] private int pierceAmount;
|
||||
[Header("Charge")]
|
||||
private bool isCharging;
|
||||
private float currentChargeDuration;
|
||||
[SerializeField] private float maxChargeDuration;
|
||||
public float chargeModifier;
|
||||
|
||||
protected override void AbilityEffects()
|
||||
{
|
||||
base.AbilityEffects();
|
||||
isCharging = true;
|
||||
thisEntity.abilitiesDisabled = true;
|
||||
}
|
||||
|
||||
protected override void Update()
|
||||
{
|
||||
base.Update();
|
||||
if (isCharging)
|
||||
{
|
||||
if (Input.GetMouseButton(1))
|
||||
{
|
||||
currentChargeDuration += Time.deltaTime;
|
||||
}
|
||||
else if (Input.GetMouseButtonUp(1))
|
||||
{
|
||||
currentChargeDuration = Math.Clamp(currentChargeDuration, 0f, maxChargeDuration);
|
||||
float calculatedChargeModifier = Map(currentChargeDuration, 0f, maxChargeDuration, 0f, chargeModifier);
|
||||
isCharging = false;
|
||||
thisEntity.abilitiesDisabled = false;
|
||||
Projectile newProjectile = Instantiate(projectile, thisEntity.transform.position, projectile.transform.rotation);
|
||||
//newProjectile.owner = thisEntity;
|
||||
newProjectile.tag = thisEntity.tag;
|
||||
newProjectile.speed = projectileSpeed;
|
||||
newProjectile.damage = power * 1f + calculatedChargeModifier;
|
||||
newProjectile.lifetime = projectileLifetime;
|
||||
newProjectile.pierceAmount = pierceAmount;
|
||||
newProjectile.transform.Lookat2D(thisEntity.attackOriginPoint.position); //targetLocation);
|
||||
newProjectile.transform.localScale = new Vector3(newProjectile.transform.localScale.x * (1f + calculatedChargeModifier), newProjectile.transform.localScale.y * (1f + calculatedChargeModifier), 1f);
|
||||
currentChargeDuration = 0f;
|
||||
}
|
||||
}
|
||||
}
|
||||
public static float Map (float value, float from1, float to1, float from2, float to2) {
|
||||
return (value - from1) / (to1 - from1) * (to2 - from2) + from2;
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue