Files
Cielonos/Assets/Scripts/MainGame/Characters/Player/Items/MainWeapons/FutureWand.cs
SoulliesOfficial f26f9fd374 爆更
2026-03-20 12:07:44 -04:00

172 lines
7.0 KiB
C#

using System.Collections.Generic;
using Cielonos.MainGame.Characters;
using Cielonos.MainGame.UI;
using SLSUtilities.General;
using UnityEngine;
namespace Cielonos.MainGame.Characters.Inventory.Collections
{
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");
viewObjects["Wand"].SetFadeAnim(0.5f);
PlayerCanvas.Instance.mainWeaponUIArea.displayer.SetFrameOutline(1);
}
public override void OnPrimaryPress()
{
if (functionSm["LightAttack"].IsAvailable() && fullBodyFuncAnimSm.CheckPlayability())
{
comboSm.main.NextCombo("L");
functionSm["LightAttack"].Execute();
currentTarget = BattleManager.EnemySm.GetNearestEnemy(25f);
if (currentTarget != null)
{
PlayTargetedAnimation("LightAttack" + comboSm.main.GetCurrentNodeName(), currentTarget, 5f);
}
else
{
PlayTargetedAnimation("LightAttack" + comboSm.main.GetCurrentNodeName());
}
}
}
public override void OnSecondaryPress()
{
if (functionSm["HeavyAttack"].IsAvailable() && fullBodyFuncAnimSm.CheckPlayability())
{
comboSm.main.Reset();
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, Vector3.down, 10f);
private void LightAttack1_0() => GenerateProjectile("NormalProjectile", currentTarget, Vector3.up, 10f);
private void LightAttack1_1() => GenerateProjectile("NormalProjectile", currentTarget, Vector3.zero, 10f, player.bodyPartsSc.leftHand);
private void LightAttack2() => GenerateProjectile("NormalProjectile", currentTarget, Vector3.down * 2, 10f);
private void LightAttack3() => GenerateProjectile("HeavyProjectile", currentTarget, Vector3.up * 3, 10f);
private void HeavyAttack() => GenerateGroundArea("GroundArea");
private void ReleaseAura() => GenerateSquareExpandingAura("SquareExpandingAura");
}
public partial class FutureWand
{
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, Vector3 swingRotation, float speed, Transform muzzle = null)
{
muzzle ??= this.muzzle;
vfxData.SpawnMuzzleVFX(vfxName, muzzle);
Projectile projectile = vfxData.SpawnVFX(vfxName).GetComponentInChildren<Projectile>();
Vector3 direction = player.transform.forward;
if (target != null)
{
direction = (target.centerPoint.position - projectile.transform.position).normalized;
}
projectile.Initialize(player, this, false, 1, Fraction.Enemy)
.SetAttackSubmodule<Projectile>(attackData[vfxName])
.SetTimeSubmodule<Projectile>(10f)
.SetHitSubmodule<Projectile>()
.SetAdaptiveTraceMoveModule<Projectile>(target, speed, 5f, 20f, 20f, direction)
.SetRaycastSubmodule<Projectile>(default, 0.25f, 0.5f)
.SetForceSubmodule<Projectile>(5f);
//Swing("Swing", "Swing", swingRotation);
audioContainer.PlaySoundFX(vfxName + "Release", projectile.gameObject, true);
projectile.hitSm.AddHitSound(AK.EVENTS.FUTUREWAND_NORMALHIT)
.AddHitEvent((enemy, hitPosition) => feedbackSc["Hit"].Play());
}
private void GenerateGroundArea(string vfxName)
{
vfxData.SpawnMuzzleVFX(vfxName, muzzle);
NormalArea area = vfxData.SpawnVFX(vfxName).GetComponentInChildren<NormalArea>();
area.Initialize<NormalArea>(player, this, Fraction.Enemy)
.SetAttackSubmodule<NormalArea>(attackData["GroundArea"])
.SetTimeSubmodule<NormalArea>(1f, 0.2f, 0.8f)
.SetHitSubmodule<NormalArea>(0.1f, 5)
.SetForceSubmodule<NormalArea>(5f, false);
//Swing("Swing", "Swing", Vector3.right);
audioContainer.PlaySoundFX("GroundArea", area.gameObject, true);
area.hitSm.AddHitSound(AK.EVENTS.FUTUREWAND_NORMALHIT)
.AddHitEvent((enemy, hitPosition) => feedbackSc["Hit"].Play());
}
private void GenerateSquareExpandingAura(string vfxName)
{
vfxData.SpawnMuzzleVFX(vfxName, muzzle);
NormalArea area = vfxData.SpawnVFX(vfxName).GetComponentInChildren<NormalArea>();
area.Initialize<NormalArea>(player, this, Fraction.Enemy)
.SetAttackSubmodule<NormalArea>(attackData["SquareAura"])
.SetTimeSubmodule<NormalArea>(4f, 0.2f, 2.8f)
.SetHitSubmodule<NormalArea>()
.SetTransformSubmodule<NormalArea>();
audioContainer.PlaySoundFX("SquareAura", area.gameObject, true);
//Swing("Swing", "Swing", Vector3.left);
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();
}
};
}
}
}