Files
Cielonos/Assets/Scripts/MainGame/Items/MainWeapons/FutureWand.cs
SoulliesOfficial ef7b479712 initial
2025-11-25 08:19:33 -05:00

114 lines
4.7 KiB
C#

using Cielonos.MainGame.Characters;
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);
}
public override void OnPrimaryPress()
{
if (functionSm["LightAttack"].IsAvailable() && fullBodyFuncAnimSm.CheckPlayability())
{
comboSm.NextCombo("L");
functionSm["LightAttack"].ResetCooldown();
currentTarget = BattleManager.EnemySm.GetNearestEnemy(25f);
if (currentTarget != null)
{
PlayTargetedAnimation("LightAttack" + comboSm.GetCurrentNodeName(), currentTarget, 5f);
}
}
}
public override void OnSecondaryPress()
{
if (functionSm["HeavyAttack"].IsAvailable() && fullBodyFuncAnimSm.CheckPlayability())
{
comboSm.ResetCombo();
functionSm["HeavyAttack"].ResetCooldown();
currentTarget = BattleManager.EnemySm.GetNearestEnemy(10f);
if (currentTarget != null)
{
PlayTargetedAnimation("HeavyAttack", currentTarget, 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");
}
public partial class FutureWand
{
private void SwingForward()
{
Swing("Swing", "Swing", Vector3.forward * 0.2f);
Debug.Log("SwingForward executed");
}
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>()
.SetTraceMoveModule<Projectile>(currentTarget, speed, 5f, 20f, 20f, direction)
.SetRaycastSubmodule<Projectile>()
.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.8f, 0.2f)
.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());
}
}
}