Files
Cielonos/Assets/Scripts/MainGame/Items/MainWeapons/FutureWand.cs
2025-12-24 16:58:51 -05:00

170 lines
6.8 KiB
C#

using System.Collections.Generic;
using Cielonos.MainGame.Characters;
using SLSFramework.General;
using UnityEngine;
namespace Cielonos.MainGame.Inventory
{
public partial class FutureWand : MainWeaponBase
{
public CharacterBase currentTarget;
public override void OnEquipped()
{
base.OnEquipped();
RegisterFunctionsToAnimSc(SwingForward, SwingDown, LightAttack0, LightAttack1_0, LightAttack1_1,
LightAttack2, LightAttack3, HeavyAttack, ReleaseAura);
PlayTargetedAnimation("Equip");
}
public override void OnPrimaryPress()
{
if (functionSm["LightAttack"].IsAvailable() && fullBodyFuncAnimSm.CheckPlayability())
{
comboSm.NextCombo("L");
functionSm["LightAttack"].Execute();
currentTarget = BattleManager.EnemySm.GetNearestEnemy(25f);
if (currentTarget != null)
{
PlayTargetedAnimation("LightAttack" + comboSm.GetCurrentNodeName(), currentTarget, 5f);
}
else
{
PlayTargetedAnimation("LightAttack" + comboSm.GetCurrentNodeName());
}
}
}
public override void OnSecondaryPress()
{
if (functionSm["HeavyAttack"].IsAvailable() && fullBodyFuncAnimSm.CheckPlayability())
{
comboSm.ResetCombo();
functionSm["HeavyAttack"].Execute();
currentTarget = BattleManager.EnemySm.GetNearestEnemy(10f);
if (currentTarget != null)
{
PlayTargetedAnimation("HeavyAttack", currentTarget, 3f);
}
else
{
PlayTargetedAnimation("HeavyAttack", null, 3f);
}
}
}
}
public partial class FutureWand
{
private void LightAttack0() => GenerateProjectile("NormalProjectile", currentTarget, 10f);
private void LightAttack1_0() => GenerateProjectile("NormalProjectile", currentTarget, 10f);
private void LightAttack1_1() => GenerateProjectile("NormalProjectile", currentTarget, 10f, player.bodyPartsSc.leftHand);
private void LightAttack2() => GenerateProjectile("NormalProjectile", currentTarget, 10f);
private void LightAttack3() => GenerateProjectile("HeavyProjectile", currentTarget, 10f);
private void HeavyAttack() => GenerateGroundArea("GroundArea");
private void ReleaseAura() => GenerateSquareExpandingAura("SquareExpandingAura");
}
public partial class FutureWand : MainWeaponBase
{
private Transform muzzle => viewObjects["Wand"].functionalParts["Muzzle"].transform;
}
public partial class FutureWand
{
private void SwingForward()
{
Swing("Swing", "Swing", Vector3.forward * 0.2f);
}
private void SwingDown() => Swing("Swing", "Swing", Vector3.down * 0.3f);
private void GenerateProjectile(string vfxName, CharacterBase target, float speed, Transform muzzle = null)
{
muzzle ??= this.muzzle;
vfxData.SpawnMuzzleVFX(vfxName, muzzle);
Projectile projectile = vfxData.SpawnVFX(vfxName).GetComponentInChildren<Projectile>();
AttackUnit attackUnit = attackData["LightAttack"].Clone();
attackUnit.hitVFX = vfxData.Get(vfxName).hitVFX;
Vector3 direction = player.transform.forward;
if (target != null)
{
direction = (target.flexibleCenterPoint.position - projectile.transform.position).normalized;
}
projectile.Initialize(player, this, false, 1, Fraction.Enemy)
.SetAttackSubmodule<Projectile>(attackUnit)
.SetTimeSubmodule<Projectile>(10f)
.SetHitSubmodule<Projectile>()
.SetAdaptiveTraceMoveModule<Projectile>(currentTarget, speed, 5f, 20f, 20f, direction)
.SetRaycastSubmodule<Projectile>(default, 0.25f, 0.5f)
.SetForceSubmodule<Projectile>(5f);
audioContainer.PlaySoundFX(vfxName + "Release", projectile.gameObject, true);
projectile.hitSm.AddHitSound(vfxName.Replace("Projectile", "") + "Hit")
.AddHitEvent((enemy, hitPosition) => feedbackSc["Hit"].Play());
}
private void GenerateGroundArea(string vfxName)
{
vfxData.SpawnMuzzleVFX(vfxName, muzzle);
NormalArea area = vfxData.SpawnVFX(vfxName).GetComponentInChildren<NormalArea>();
AttackUnit attackUnit = attackData["LightAttack"].Clone();
attackUnit.hitVFX = vfxData.Get(vfxName).hitVFX;
area.Initialize<NormalArea>(player, this, Fraction.Enemy)
.SetAttackSubmodule<NormalArea>(attackUnit)
.SetTimeSubmodule<NormalArea>(1f, 0.2f, 0.8f)
.SetHitSubmodule<NormalArea>(0.1f, 5)
.SetForceSubmodule<NormalArea>(5f, false);
audioContainer.PlaySoundFX("GroundArea", area.gameObject, true);
area.hitSm.AddHitSound("NormalHit")
.AddHitEvent((enemy, hitPosition) => feedbackSc["Hit"].Play());
}
private void GenerateSquareExpandingAura(string vfxName)
{
vfxData.SpawnMuzzleVFX(vfxName, muzzle);
NormalArea area = vfxData.SpawnVFX(vfxName).GetComponentInChildren<NormalArea>();
AttackUnit attackUnit = attackData["LightAttack"].Clone();
attackUnit.hitVFX = vfxData.Get(vfxName).hitVFX;
area.Initialize<NormalArea>(player, this, Fraction.Enemy)
.SetAttackSubmodule<NormalArea>(attackUnit)
.SetTimeSubmodule<NormalArea>(4f, 0.2f, 2.8f)
.SetHitSubmodule<NormalArea>()
.SetTransformSubmodule<NormalArea>();
area.transformSm.ApplyScaleMove(Vector3.one, Vector3.one * 50, 1f, EaseType.OutQuart);
area.updateAction = () =>
{
if (area.timeSm.enablingTime > 3f)
{
return;
}
List<Projectile> toBeRemoved = new List<Projectile>();
foreach (Projectile projectile in BattleManager.AttackAreaSm.enemyAttackAreas.activeProjectiles)
{
if (area.areaCollider.IsPointInside(projectile.topParent.transform.position))
{
toBeRemoved.Add(projectile);
}
}
foreach (Projectile projectile in toBeRemoved)
{
projectile.Explode();
}
};
}
}
}