cool title screen
This commit is contained in:
parent
b0625ae834
commit
949135cecb
33 changed files with 4977 additions and 7 deletions
|
|
@ -1,17 +1,74 @@
|
|||
using System;
|
||||
using Core.Extensions;
|
||||
using Unity.Mathematics;
|
||||
using UnityEngine;
|
||||
|
||||
public class ReisenShoot : Ability
|
||||
{
|
||||
[SerializeField] private Projectile projectile;
|
||||
[SerializeField] private Projectile chargedProjectile;
|
||||
[SerializeField] private Camera cam;
|
||||
[Header("Charge")]
|
||||
[SerializeField] private float mouseHoldTime;
|
||||
private float currentMouseHoldTime;
|
||||
private float currentChargeTime;
|
||||
private bool isCharging;
|
||||
[SerializeField] private float maxChargeTime;
|
||||
[SerializeField] private float chargeCooldown;
|
||||
private float currentChargeCooldown;
|
||||
protected override void AbilityEffects()
|
||||
{
|
||||
if (currentChargeCooldown > 0)
|
||||
{
|
||||
ShootBullet(projectile, power);
|
||||
}
|
||||
else
|
||||
{
|
||||
isCharging = true;
|
||||
}
|
||||
}
|
||||
|
||||
private void ShootBullet(Projectile projectileToShoot, int damage)
|
||||
{
|
||||
direction = cam.ScreenToWorldPoint(Input.mousePosition);
|
||||
Projectile newProjectile = Instantiate(projectile, origin.position, Quaternion.identity);
|
||||
Projectile newProjectile = Instantiate(projectileToShoot, origin.position, Quaternion.identity);
|
||||
newProjectile.transform.Lookat2D(direction);
|
||||
newProjectile.damage = power;
|
||||
newProjectile.damage = damage;
|
||||
newProjectile.tag = tag;
|
||||
}
|
||||
|
||||
protected override void Update()
|
||||
{
|
||||
base.Update();
|
||||
if (currentMouseHoldTime >= 0)
|
||||
{
|
||||
currentMouseHoldTime -= Time.deltaTime;
|
||||
if (currentMouseHoldTime <= 0 && Input.GetMouseButton(1) && currentChargeTime <= 0)
|
||||
{
|
||||
isCharging = true;
|
||||
}
|
||||
else if (Input.GetMouseButtonUp(0))
|
||||
{
|
||||
ShootBullet(projectile, power);
|
||||
}
|
||||
}
|
||||
if (isCharging && Input.GetMouseButton(0)) //this code REEKS
|
||||
{
|
||||
currentChargeTime += Time.deltaTime;
|
||||
}
|
||||
else if (isCharging && Input.GetMouseButtonUp(0))
|
||||
{
|
||||
Debug.Log("here");
|
||||
currentChargeTime = 0;
|
||||
ShootBullet(chargedProjectile, power * (int)Math.Clamp(currentChargeTime, 0, maxChargeTime));
|
||||
currentChargeCooldown = chargeCooldown;
|
||||
isCharging = false;
|
||||
}
|
||||
|
||||
if (currentChargeCooldown > 0)
|
||||
{
|
||||
currentChargeCooldown -= Time.deltaTime;
|
||||
}
|
||||
Debug.Log(currentChargeTime);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue