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(); 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(attackData[vfxName]) .SetTimeSubmodule(10f) .SetHitSubmodule() .SetAdaptiveTraceMoveModule(target, speed, 5f, 20f, 20f, direction) .SetRaycastSubmodule(default, 0.25f, 0.5f) .SetForceSubmodule(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(); area.Initialize(player, this, Fraction.Enemy) .SetAttackSubmodule(attackData["GroundArea"]) .SetTimeSubmodule(1f, 0.2f, 0.8f) .SetHitSubmodule(0.1f, 5) .SetForceSubmodule(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(); area.Initialize(player, this, Fraction.Enemy) .SetAttackSubmodule(attackData["SquareAura"]) .SetTimeSubmodule(4f, 0.2f, 2.8f) .SetHitSubmodule() .SetTransformSubmodule(); 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 toBeRemoved = new List(); 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(); } }; } } }