diff --git a/HKMP/Animation/Effects/SlashBase.cs b/HKMP/Animation/Effects/SlashBase.cs index 05854c6..0e2c79e 100644 --- a/HKMP/Animation/Effects/SlashBase.cs +++ b/HKMP/Animation/Effects/SlashBase.cs @@ -2,6 +2,7 @@ using Hkmp.Util; using HutongGames.PlayMaker.Actions; using UnityEngine; +using Object = UnityEngine.Object; namespace Hkmp.Animation.Effects; @@ -74,8 +75,6 @@ protected void Play(GameObject playerObject, bool[] effectInfo, GameObject prefa var originalNailSlash = slash.GetComponent(); Object.Destroy(originalNailSlash); - ChangeAttackTypeOfFsm(slash); - slash.SetActive(true); // Get the slash audio source and its clip @@ -151,10 +150,38 @@ protected void Play(GameObject playerObject, bool[] effectInfo, GameObject prefa polygonCollider.enabled = true; + // Instantiate additional game object that can interact with enemies so remote enemies can be hit + GameObject enemySlash; + { + enemySlash = Object.Instantiate(prefab, playerAttacks.transform); + enemySlash.layer = 17; + enemySlash.name = "Enemy Slash"; + enemySlash.transform.localScale = slash.transform.localScale; + + var typesToRemove = new[] { + typeof(MeshFilter), typeof(MeshRenderer), typeof(tk2dSprite), typeof(tk2dSpriteAnimator), + typeof(NailSlash), + typeof(AudioSource) + }; + foreach (var typeToRemove in typesToRemove) { + Object.Destroy(enemySlash.GetComponent(typeToRemove)); + } + + for (var i = 0; i < enemySlash.transform.childCount; i++) { + Object.Destroy(enemySlash.transform.GetChild(i)); + } + + polygonCollider = enemySlash.GetComponent(); + polygonCollider.enabled = true; + + var damagesEnemyFsm = slash.LocateMyFSM("damages_enemy"); + Object.Destroy(damagesEnemyFsm); + + ChangeAttackTypeOfFsm(enemySlash); + } + var damage = ServerSettings.NailDamage; if (ServerSettings.IsPvpEnabled) { - // TODO: make it possible to pogo on players - if (ServerSettings.AllowParries) { AddParryFsm(slash); } @@ -167,6 +194,7 @@ protected void Play(GameObject playerObject, bool[] effectInfo, GameObject prefa // After the animation is finished, we can destroy the slash object var animationDuration = slashAnimator.CurrentClip.Duration; Object.Destroy(slash, animationDuration); + Object.Destroy(enemySlash, animationDuration); if (!hasGrubberflyElegyCharm || isOnOneHealth && !hasFuryCharm