using System.Collections.Generic; using Cielonos.MainGame.UI; using DG.Tweening; using Lean.Pool; using SLSUtilities.General; using SLSUtilities.WwiseAssistance; using UniRx; using UnityEngine; namespace Cielonos.MainGame.Characters { public partial class NexusCrab : Enemy { protected override void Start() { base.Start(); RegisterFunctionsToAnimSc(SingleSwing, ThreeSwings_0, ThreeSwings_1, ThreeSwings_2, ClawStabBlast, ClawImpaleWave, JumpAttackBlast, BumpImpaleWave, GenerateNormalBulletSpawner, GenerateShockwaveMissileSpawner, GeneratePiercingBulletSpawner); PlayerCanvas.BossInfoUIArea.CreateInfoUnit(this); } protected override void InitializeSubmodules() { base.InitializeSubmodules(); eventSm.onHealthChanged.InsertByPriority("UI_HealthBarUpdate", new PrioritizedAction(UI_HealthBarUpdate)); eventSm.onEnergyChanged.InsertByPriority("UI_EnergyBarUpdate", new PrioritizedAction(UI_EnergyBarUpdate)); } private void UI_HealthBarUpdate(float healthChanged) { PlayerCanvas.BossInfoUIArea[this]?.UpdateHealth(); } private void UI_EnergyBarUpdate(float energyUsed) { PlayerCanvas.BossInfoUIArea[this]?.UpdateEnergy(); } private void SingleSwing() => GenerateSlash("SingleSwing"); private void ThreeSwings_0() => GenerateSlash("ThreeSwings_0"); private void ThreeSwings_1() => GenerateSlash("ThreeSwings_1"); private void ThreeSwings_2() => GenerateSlash("ThreeSwings_2"); private void ClawStabBlast() { GenerateClawStabBlast("ClawStabBlast", "ClawStabBlast", 10); //feedbackSc["ImpaleWave_Stab"].Play(); } private void ClawImpaleWave() { GenerateImpaleWave("ImpaleWave"); //feedbackSc["ImpaleWave_Wave"].Play(); } private void JumpAttackBlast() { GenerateJumpAttackBlast("JumpAttackBlast", "JumpAttackBlast", 10); //feedbackSc["JumpAttack_Blast"].Play(); } private void BumpImpaleWave() { GenerateImpaleWave("ImpaleWave"); //feedbackSc["ImpaleWave_Wave"].Play(); } private void GenerateNormalBulletSpawner() { GenerateBulletSpawner("NormalBulletSpawner"); Observable.Timer(System.TimeSpan.FromSeconds(0.3f)).Subscribe(_ => { Observable.Interval(System.TimeSpan.FromSeconds(0.2f)).Take(6).Subscribe(__ => { GenerateNormalBullet(); }); }); } private void GenerateShockwaveMissileSpawner() { GenerateBulletSpawner("SpecialBulletSpawner"); Observable.Timer(System.TimeSpan.FromSeconds(0.3f)).Subscribe(_ => { Observable.Interval(System.TimeSpan.FromSeconds(0.5f)).Take(2).Subscribe(__ => { GenerateShockwaveMissile(); }); }); } private void GeneratePiercingBulletSpawner() { GenerateBulletSpawner("SpecialBulletSpawner"); Observable.Timer(System.TimeSpan.FromSeconds(0.3f)).Subscribe(_ => { Observable.Interval(System.TimeSpan.FromSeconds(0.5f)).Take(2).Subscribe(__ => { GeneratePiercingBullet(); }); }); } private void GenerateSlash(string vfxName) { NormalArea slash = vfxData.SpawnVFX(vfxName, this).GetComponentInChildren(); slash.Initialize(this, null, Fraction.Player) .SetAttackSubmodule(attackData["Swing"]) .SetTimeSubmodule(1.5f) .SetHitSubmodule(); slash.SetImpulseSubmodule().WithRepulsion(5f); slash.hitSm.AddHitSound(AK.EVENTS.NEXUSCRAB_GENERALHIT); } private void GenerateClawStabBlast(string vfxName, string attackDataName, float force) { NormalArea slash = vfxData.SpawnVFX(vfxName, this).GetComponentInChildren(); slash.Initialize(this, null, Fraction.Player) .SetAttackSubmodule(attackData[attackDataName]) .SetTimeSubmodule(1.2f) .SetHitSubmodule() .SetReactionSubmodule(false, false, false, true, true, false, false); slash.SetImpulseSubmodule().WithCustomForce(transform.forward * force); } private void GenerateJumpAttackBlast(string vfxName, string attackDataName, float force) { NormalArea slash = vfxData.SpawnVFX(vfxName, this).GetComponentInChildren(); slash.Initialize(this, null, Fraction.Player) .SetAttackSubmodule(attackData[attackDataName]) .SetTimeSubmodule(1.2f) .SetHitSubmodule() .SetReactionSubmodule(false, false, false, true, true, false, false); slash.SetImpulseSubmodule().WithRepulsion(force); } private void GenerateImpaleWave(string vfxName) { NormalArea slash = vfxData.SpawnVFX(vfxName, this).GetComponentInChildren(); slash.Initialize(this, null, Fraction.Player) .SetAttackSubmodule(attackData["ImpaleWave"]) .SetTimeSubmodule(3f, 0.2f, 1.3f) .SetHitSubmodule() .SetReactionSubmodule(false, false, false, true, true, false, false); slash.SetImpulseSubmodule().WithCustomForce(transform.forward * 30f); slash.transform.DOLocalMoveZ(8f, 0.8f).From(0f).Play(); slash.transform.DOScale(1.5f, 0.8f).From(1f).Play(); } private Transform bulletSpawnerTransform; private void GenerateBulletSpawner(string vfxName) { bulletSpawnerTransform = vfxData.SpawnVFX(vfxName, this).transform; Observable.Timer(System.TimeSpan.FromSeconds(1.25f)).Subscribe(_ => { bulletSpawnerTransform.GetComponent().Stop(true); LeanPool.Despawn(bulletSpawnerTransform.gameObject, 0.3f); }); } private void GenerateNormalBullet() { Player player = MainGameManager.Player; if(player == null) return; bulletSpawnerTransform.forward = (player.CenterPoint.position - bulletSpawnerTransform.position).normalized; vfxData.SpawnMuzzleVFX("NormalBullet", this, bulletSpawnerTransform); //audioSc.audioContainer.PlaySoundFX("NormalBullet_Shoot", bulletSpawnerTransform.position); Projectile projectile = vfxData.SpawnVFX("NormalBullet", this, bulletSpawnerTransform).GetComponentInChildren(); projectile.Initialize(this, null, false, 1, Fraction.Player) .SetAttackSubmodule(attackData["NormalBullet"]) .SetTimeSubmodule(10f) .SetHitSubmodule() .SetLinearDirectionMoveModule(bulletSpawnerTransform.forward, 20f) .SetRaycastSubmodule() .SetReactionSubmodule(true, false, false, true, false, false, true); projectile.SetImpulseSubmodule().WithDynamicForce(1f); projectile.hitSm.AddHitSound(AK.EVENTS.NEXUSCRAB_NORMALBULLET_HIT); } private void GenerateShockwaveMissile() { Player player = MainGameManager.Player; if(player == null) return; bulletSpawnerTransform.forward = (player.CenterPoint.position - bulletSpawnerTransform.position).normalized; vfxData.SpawnMuzzleVFX("ShockwaveMissile", this, bulletSpawnerTransform); //audioSc.audioContainer.PlaySoundFX("ShockwaveMissile_Shoot", bulletSpawnerTransform.position); Projectile projectile = vfxData.SpawnVFX("ShockwaveMissile", this, bulletSpawnerTransform).GetComponentInChildren(); projectile.Initialize(this, null, false, 1, Fraction.Player) .SetAttackSubmodule(attackData["ShockwaveMissile"]) .SetTimeSubmodule(5f) .SetHitSubmodule() .SeDetachableTraceMoveModule(player, 20f, -2f, 60f, -10f, bulletSpawnerTransform.forward) .SetRaycastSubmodule(default, 0.1f, 0.2f) .SetReactionSubmodule(false, false, false, true, false, false, true); projectile.SetImpulseSubmodule().WithDynamicForce(1f); projectile.hitSm.AddHitSound(AK.EVENTS.NEXUSCRAB_SHOCKWAVEMISSILE_HIT); } private void GeneratePiercingBullet() { Player player = MainGameManager.Player; if(player == null) return; bulletSpawnerTransform.forward = (player.CenterPoint.position - bulletSpawnerTransform.position).normalized; vfxData.SpawnMuzzleVFX("PiercingBullet", this, bulletSpawnerTransform); //audioSc.audioContainer.PlaySoundFX("PiercingBullet_Shoot", bulletSpawnerTransform.position); Projectile projectile = vfxData.SpawnVFX("PiercingBullet", this, bulletSpawnerTransform).GetComponentInChildren(); projectile.Initialize(this, null, false, 1, Fraction.Player) .SetAttackSubmodule(attackData["PiercingBullet"]) .SetTimeSubmodule(10f) .SetHitSubmodule() .SetLinearDirectionMoveModule(bulletSpawnerTransform.forward, 60f) .SetRaycastSubmodule() .SetReactionSubmodule(false, false, true, true, false, false, true); projectile.SetImpulseSubmodule().WithDynamicForce(1f); projectile.hitSm.AddHitSound(AK.EVENTS.NEXUSCRAB_PIERCINGBULLET_HIT); } } }