basically the whole game
This commit is contained in:
parent
949135cecb
commit
96dcfa9064
315 changed files with 34386 additions and 396 deletions
|
|
@ -1,16 +1,26 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Unity.Mathematics;
|
||||
using Core.Extensions;
|
||||
using UnityEngine;
|
||||
using Random = UnityEngine.Random;
|
||||
|
||||
public class YoumuDeflect : Ability
|
||||
{
|
||||
[SerializeField] private Camera cam;
|
||||
private List<Projectile> projectilesInRange = new();
|
||||
public float deflectionAngleMin = -48;
|
||||
public float deflectionAngleMax = 90;
|
||||
[Header("Deflection")]
|
||||
[SerializeField] private float deflectionSpeed;
|
||||
[SerializeField] private float deflectionSpeedVariance;
|
||||
[SerializeField] private float deflectionAngleMin = -48;
|
||||
[SerializeField] private float deflectionAngleMax = 90;
|
||||
[SerializeField] private Projectile chargeProjectile;
|
||||
[SerializeField] private float destructionChance;
|
||||
|
||||
[Header("Entity Detection")]
|
||||
[SerializeField] private float detectionRadius;
|
||||
[SerializeField] private LayerMask entityLayer;
|
||||
|
||||
[Header("SlashCharge")]
|
||||
[SerializeField] private float mouseHoldTime;
|
||||
private float currentMouseHoldTime;
|
||||
|
|
@ -20,12 +30,15 @@ public class YoumuDeflect : Ability
|
|||
[SerializeField] private float chargeCooldown;
|
||||
private float currentChargeCooldown;
|
||||
private float currentUnleashedChargeTime;
|
||||
[Header("Charge Effects")]
|
||||
[SerializeField] private AudioClip chargeSlashSFX;
|
||||
[SerializeField] private float chargeVolume = 1f;
|
||||
[SerializeField] private Transform chargeMeter;
|
||||
[Header("Effects")]
|
||||
[SerializeField] private ParticleSystem deflectionParticles;
|
||||
[SerializeField] private GameObject swordSweepEffect;
|
||||
[SerializeField] private GameObject chargeSweepEffect;
|
||||
private float currentDissipationTime = 0f;
|
||||
[SerializeField] private float dissipationTime;
|
||||
[SerializeField] private AudioClip noHitSlashSFX;
|
||||
[SerializeField] private float noHitVolume = 1f;
|
||||
|
||||
|
||||
protected override void AbilityEffects()
|
||||
|
|
@ -38,20 +51,28 @@ public class YoumuDeflect : Ability
|
|||
else
|
||||
{
|
||||
currentMouseHoldTime = mouseHoldTime;
|
||||
currentChargeTime = 0;
|
||||
}
|
||||
}
|
||||
|
||||
private void RegularDeflection()
|
||||
{
|
||||
//Debug.Log("Regular Deflection");
|
||||
swordSweepEffect.gameObject.SetActive(true);
|
||||
currentDissipationTime = dissipationTime;
|
||||
DeflectProjectiles();
|
||||
if (projectilesInRange.Count > 0)
|
||||
{
|
||||
DeflectProjectiles();
|
||||
}
|
||||
else
|
||||
{
|
||||
WaveManager.instance.audioSource.PlayOneShot(noHitSlashSFX, noHitVolume);
|
||||
}
|
||||
foreach (Enemy enemy in DetectEnemies())
|
||||
{
|
||||
enemy.TakeDamage(power);
|
||||
}
|
||||
}
|
||||
|
||||
private void DeflectProjectiles()
|
||||
{
|
||||
GameManager.instance.deflections += projectilesInRange.Count;
|
||||
foreach (Projectile projectile in projectilesInRange.ToList())
|
||||
{
|
||||
if (!projectile)
|
||||
|
|
@ -62,17 +83,28 @@ public class YoumuDeflect : Ability
|
|||
projectile.transform.eulerAngles = new Vector3(0, 0, Random.Range(deflectionAngleMin, deflectionAngleMax));
|
||||
projectile.direction = projectile.transform.right;
|
||||
projectile.tag = tag;
|
||||
projectile.speed = deflectionSpeed + Random.Range(-deflectionSpeedVariance, deflectionSpeedVariance);
|
||||
ParticleSystem newParticles = Instantiate(deflectionParticles, projectile.transform);
|
||||
projectile.Deflected();
|
||||
float destructionRoll = Random.Range(0f, 1f);
|
||||
if (destructionRoll < destructionChance)
|
||||
{
|
||||
Destroy(projectile.gameObject);
|
||||
}
|
||||
projectilesInRange.Remove(projectile);
|
||||
}
|
||||
WaveManager.instance.audioSource.PlayOneShot(abilitySound, volume);
|
||||
}
|
||||
|
||||
|
||||
private void OnTriggerEnter2D(Collider2D other)
|
||||
{
|
||||
if (!other.CompareTag(tag) && other.TryGetComponent(out Projectile isProjectile))
|
||||
if (!other.CompareTag(tag))
|
||||
{
|
||||
projectilesInRange.Add(isProjectile);
|
||||
if (other.TryGetComponent(out Projectile isProjectile) && isProjectile.deflectable)
|
||||
{
|
||||
projectilesInRange.Add(isProjectile);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -80,21 +112,22 @@ public class YoumuDeflect : Ability
|
|||
{
|
||||
if (!other.CompareTag(tag) && other.TryGetComponent(out Projectile isProjectile) && projectilesInRange.Contains(isProjectile))
|
||||
{
|
||||
projectilesInRange.Add(isProjectile);
|
||||
projectilesInRange.Remove(isProjectile);
|
||||
}
|
||||
}
|
||||
|
||||
private void ShootBullet(Projectile projectileToShoot, int damage)
|
||||
{
|
||||
Debug.Log(damage);
|
||||
direction = cam.ScreenToWorldPoint(Input.mousePosition);
|
||||
Projectile newProjectile = Instantiate(projectileToShoot, origin.position, Quaternion.identity);
|
||||
newProjectile.transform.Lookat2D(direction);
|
||||
newProjectile.damage = damage;
|
||||
newProjectile.tag = tag;
|
||||
newProjectile.playerBullet = true;
|
||||
}
|
||||
protected override void Update()
|
||||
{
|
||||
base.Update();
|
||||
if (currentDissipationTime > 0)
|
||||
{
|
||||
currentDissipationTime -= Time.deltaTime;
|
||||
if (currentDissipationTime <= 0)
|
||||
{
|
||||
swordSweepEffect.SetActive(false);
|
||||
}
|
||||
}
|
||||
|
||||
if (currentMouseHoldTime >= 0)
|
||||
{
|
||||
|
|
@ -102,6 +135,7 @@ public class YoumuDeflect : Ability
|
|||
if (currentMouseHoldTime <= 0 && Input.GetMouseButton(1) && currentChargeTime <= 0)
|
||||
{
|
||||
isCharging = true;
|
||||
currentChargeTime += mouseHoldTime;
|
||||
}
|
||||
else if (Input.GetMouseButtonUp(1))
|
||||
{
|
||||
|
|
@ -111,33 +145,36 @@ public class YoumuDeflect : Ability
|
|||
if (isCharging && Input.GetMouseButton(1)) //this code REEKS
|
||||
{
|
||||
currentChargeTime += Time.deltaTime;
|
||||
chargeMeter.localScale = new Vector3(Math.Clamp(currentChargeTime, 0, maxChargeTime)/maxChargeTime, 1f, 1f);
|
||||
}
|
||||
else if (isCharging && Input.GetMouseButtonUp(1))
|
||||
{
|
||||
Debug.Log("here");
|
||||
chargeSweepEffect.SetActive(true);
|
||||
currentUnleashedChargeTime = Math.Clamp(currentChargeTime, 0, maxChargeTime) * 2;
|
||||
ShootBullet(chargeProjectile, power * (int)Math.Clamp(currentChargeTime, 0, maxChargeTime));
|
||||
currentChargeTime = 0;
|
||||
WaveManager.instance.audioSource.PlayOneShot(chargeSlashSFX, chargeVolume);
|
||||
currentChargeCooldown = chargeCooldown;
|
||||
isCharging = false;
|
||||
chargeMeter.localScale = new Vector3(0f, 1f, 1f);
|
||||
}
|
||||
else if (currentUnleashedChargeTime > 0)
|
||||
{
|
||||
currentUnleashedChargeTime -= Time.deltaTime;
|
||||
if (currentUnleashedChargeTime < 0)
|
||||
{
|
||||
chargeSweepEffect.SetActive(false);
|
||||
}
|
||||
|
||||
if (projectilesInRange.Count > 0)
|
||||
{
|
||||
DeflectProjectiles();
|
||||
}
|
||||
}
|
||||
|
||||
if (currentChargeCooldown > 0)
|
||||
{
|
||||
currentChargeCooldown -= Time.deltaTime;
|
||||
}
|
||||
Debug.Log(currentChargeTime);
|
||||
//Debug.Log(currentChargeTime);
|
||||
}
|
||||
|
||||
private Enemy[] DetectEnemies()
|
||||
{
|
||||
Collider2D[] entitiesFound = Physics2D.OverlapCircleAll(transform.position, detectionRadius, entityLayer);
|
||||
List<Enemy> enemiesFound = new();
|
||||
foreach (Collider2D foundEntity in entitiesFound)
|
||||
{
|
||||
if (!foundEntity.CompareTag(tag) && foundEntity.TryGetComponent(out Enemy isEnemy))
|
||||
{
|
||||
enemiesFound.Add(isEnemy);
|
||||
}
|
||||
}
|
||||
return enemiesFound.ToArray();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue