diff --git a/nekoyume/Assets/_Scripts/Game/Battle/Stage.cs b/nekoyume/Assets/_Scripts/Game/Battle/Stage.cs index 44c04404abf..3fd7d4b037a 100644 --- a/nekoyume/Assets/_Scripts/Game/Battle/Stage.cs +++ b/nekoyume/Assets/_Scripts/Game/Battle/Stage.cs @@ -13,6 +13,7 @@ using System.Linq; using Cysharp.Threading.Tasks; using DG.Tweening; +using JetBrains.Annotations; using mixpanel; using Nekoyume.Battle; using Nekoyume.Blockchain; @@ -447,6 +448,7 @@ private IEnumerator CoPlayStage(BattleLog log) ClearBattle(); } + [CanBeNull] private AdventureBoss_line_character _adventurebossCharacterEffect; private IEnumerator CoBreakThroughStart() @@ -464,13 +466,16 @@ private IEnumerator CoBreakThroughEnd() NcDebug.Log($"CoBreakThroughEnd"); Widget.Find().LineEffect.SetActive(false); SetSpeed(AcceleratedAnimationTimeScaleWeight); - _adventurebossCharacterEffect.LazyStop(); + if (_adventurebossCharacterEffect) + { + _adventurebossCharacterEffect.LazyStop(); + } yield return new WaitForSeconds(0.5f); } private async UniTaskVoid FollowCharacterEffect() { - while (_adventurebossCharacterEffect.isActiveAndEnabled) + while (_adventurebossCharacterEffect != null && _adventurebossCharacterEffect.isActiveAndEnabled) { _adventurebossCharacterEffect.transform.position = _stageRunningPlayer.transform.position; _adventurebossCharacterEffect.transform.position += new Vector3(0.9581f, 0.7f, 0); diff --git a/nekoyume/Assets/_Scripts/Game/Character/BreakthroughCharacter.cs b/nekoyume/Assets/_Scripts/Game/Character/BreakthroughCharacter.cs index 778c65a6e08..fceb6f031df 100644 --- a/nekoyume/Assets/_Scripts/Game/Character/BreakthroughCharacter.cs +++ b/nekoyume/Assets/_Scripts/Game/Character/BreakthroughCharacter.cs @@ -95,7 +95,10 @@ private void OnTriggerEnter(Collider other) AudioController.instance.PlaySfx(AudioController.SfxCode.AdventureBossMonCollision); var vfx = VFXController.instance.CreateAndChaseCam(pos); - vfx.transform.localScale = new Vector3(2f, 2f, 2f); + if (vfx) + { + vfx.transform.localScale = new Vector3(2f, 2f, 2f); + } StartCoroutine(Dying()); transform.DOMove(transform.position + new Vector3(16f, 6f, 0), 4.8f).SetEase(Ease.OutExpo); SpineController.transform.DOBlendablePunchRotation(new Vector3(0, 0, 360), 2.2f).SetEase(Ease.OutExpo); diff --git a/nekoyume/Assets/_Scripts/Game/Controller/VFXController.cs b/nekoyume/Assets/_Scripts/Game/Controller/VFXController.cs index a9bf5de6d14..eef77c7c8d5 100644 --- a/nekoyume/Assets/_Scripts/Game/Controller/VFXController.cs +++ b/nekoyume/Assets/_Scripts/Game/Controller/VFXController.cs @@ -1,4 +1,5 @@ using System.Collections; +using JetBrains.Annotations; using Nekoyume.Game.Util; using Nekoyume.Pattern; using UnityEngine; @@ -40,6 +41,7 @@ public T CreateAndChase(Transform target, Vector3 offset) where T : VFX.VFX return vfx; } + [CanBeNull] public T CreateAndChaseCam(Vector3 position) where T : VFX.VFX { var target = ActionCamera.instance.transform; @@ -51,30 +53,38 @@ public T CreateAndChaseCam(Vector3 position) where T : VFX.VFX return vfx; } + [CanBeNull] public T CreateAndChaseCam(Vector3 position, Vector3 offset) where T : VFX.VFX { return CreateAndChaseCam(position + offset); } // FIXME: RectTransform이 아니라 Transform을 받아도 되겠습니다. + [CanBeNull] public T CreateAndChaseRectTransform(RectTransform target) where T : VFX.VFX { return CreateAndChaseRectTransform(target, target.position); } // FIXME: RectTransform이 아니라 Transform을 받아도 되겠습니다. + [CanBeNull] public T CreateAndChaseRectTransform(RectTransform target, Vector3 position) where T : VFX.VFX { var targetPosition = target.position; var offset = position - targetPosition; offset.z += 10f; - var vfx = _pool.Get(targetPosition + offset); + var vfx = _pool?.Get(targetPosition + offset); StartCoroutine(CoChaseTarget(vfx, target, offset)); return vfx; } private static IEnumerator CoChaseTarget(Component vfx, Transform target, Vector3 offset) { + if (!vfx) + { + yield break; + } + var g = vfx.gameObject; var t = vfx.transform; while (g.activeSelf && diff --git a/nekoyume/Assets/_Scripts/Game/Game.cs b/nekoyume/Assets/_Scripts/Game/Game.cs index 3e536fc2bd2..6a892fbeb6c 100644 --- a/nekoyume/Assets/_Scripts/Game/Game.cs +++ b/nekoyume/Assets/_Scripts/Game/Game.cs @@ -1018,7 +1018,7 @@ private static void PlayMouseOnClickVFX(Vector3 position) { position = MainCanvas.instance.Canvas.worldCamera.ScreenToWorldPoint(position); var vfx = VFXController.instance.CreateAndChaseCam(position); - vfx.Play(); + vfx?.Play(); } public void ResetStore() diff --git a/nekoyume/Assets/_Scripts/UI/Widget/Animation/ItemMoveAnimation.cs b/nekoyume/Assets/_Scripts/UI/Widget/Animation/ItemMoveAnimation.cs index da534130303..3bb997dfcee 100644 --- a/nekoyume/Assets/_Scripts/UI/Widget/Animation/ItemMoveAnimation.cs +++ b/nekoyume/Assets/_Scripts/UI/Widget/Animation/ItemMoveAnimation.cs @@ -149,7 +149,10 @@ private IEnumerator CoPlay(Vector2 defaultScale, bool moveToLeft, if (endPoint == EndPoint.None) { var vfx = VFXController.instance.Create(_endPosition); - yield return new WaitWhile(() => vfx.gameObject.activeSelf); + if (vfx) + { + yield return new WaitWhile(() => vfx.gameObject.activeSelf); + } } IsPlaying = false; diff --git a/nekoyume/Assets/_Scripts/UI/Widget/Hud/HpBar.cs b/nekoyume/Assets/_Scripts/UI/Widget/Hud/HpBar.cs index 9bead0ed985..b8463f06d4e 100644 --- a/nekoyume/Assets/_Scripts/UI/Widget/Hud/HpBar.cs +++ b/nekoyume/Assets/_Scripts/UI/Widget/Hud/HpBar.cs @@ -38,7 +38,7 @@ public void SetBuffs(IReadOnlyDictionary buffs, TableSheets tableShee var rectTransform = bar.rectTransform; HpVFX = VFXController.instance.CreateAndChaseRectTransform(rectTransform); - HpVFX.Play(); + HpVFX?.Play(); } else if (!buffLayout.HasBuff(StatType.HP)) { diff --git a/nekoyume/Assets/_Scripts/UI/Widget/Popup/CelebratesPopup.cs b/nekoyume/Assets/_Scripts/UI/Widget/Popup/CelebratesPopup.cs index 4f73fe0ff54..50808cf12c3 100644 --- a/nekoyume/Assets/_Scripts/UI/Widget/Popup/CelebratesPopup.cs +++ b/nekoyume/Assets/_Scripts/UI/Widget/Popup/CelebratesPopup.cs @@ -351,7 +351,7 @@ private void PlayEffects() var position = ActionCamera.instance.transform.position; _praiseVFX = VFXController.instance.CreateAndChaseCam(position); - _praiseVFX.Play(); + _praiseVFX?.Play(); } private void StopEffects() diff --git a/nekoyume/Assets/_Scripts/UI/Widget/Screen/CombinationLoadingScreen.cs b/nekoyume/Assets/_Scripts/UI/Widget/Screen/CombinationLoadingScreen.cs index ce9f0c9fdbd..896ec4f6f48 100644 --- a/nekoyume/Assets/_Scripts/UI/Widget/Screen/CombinationLoadingScreen.cs +++ b/nekoyume/Assets/_Scripts/UI/Widget/Screen/CombinationLoadingScreen.cs @@ -4,6 +4,7 @@ using Nekoyume.Game.VFX; using Nekoyume.UI.Tween; using System.Collections; +using JetBrains.Annotations; using Nekoyume.L10n; using Nekoyume.Model.Item; using Nekoyume.UI.Model; @@ -45,6 +46,7 @@ public enum SpeechBubbleItemType private Coroutine _npcAppearCoroutine = null; private readonly WaitForSeconds _waitForOneSec = new(1f); + [CanBeNull] private CombinationSparkVFX _sparkVFX = null; private bool _itemMoveAnimation = true;