From f900853952635a6e82e24fe62548d171823afda0 Mon Sep 17 00:00:00 2001 From: chai Date: Wed, 1 Sep 2021 17:47:20 +0800 Subject: =?UTF-8?q?*=E4=BF=AE=E6=94=B9=E7=B2=92=E5=AD=90=E7=B3=BB=E7=BB=9F?= =?UTF-8?q?=E5=9C=A8=E7=BC=96=E8=BE=91=E5=99=A8=E4=B8=8B=E7=9A=84=E6=92=AD?= =?UTF-8?q?=E6=94=BE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Assets/Scripts/Effects/FxClear.cs | 264 +++------------------ Assets/Scripts/Input/InputManager.cs | 9 +- Assets/Scripts/Line3D.meta | 8 + Assets/Scripts/Line3D/Line3DRenderer.cs | 18 ++ Assets/Scripts/Line3D/Line3DRenderer.cs.meta | 11 + Assets/Scripts/Projectile/Projectile.cs | 7 +- .../Scripts/Unit/Action/WaitForActionReachEnd.cs | 5 +- Assets/Scripts/Unit/Collider/CollisionSystem.cs | 6 +- .../Unit/Components/UnitAnimation/UnitAnimation.cs | 6 +- .../Scripts/Unit/Components/UnitState/PCState.cs | 9 +- Assets/Scripts/Unit/TimelineEventProxy.cs | 52 +++- 11 files changed, 142 insertions(+), 253 deletions(-) create mode 100644 Assets/Scripts/Line3D.meta create mode 100644 Assets/Scripts/Line3D/Line3DRenderer.cs create mode 100644 Assets/Scripts/Line3D/Line3DRenderer.cs.meta (limited to 'Assets/Scripts') diff --git a/Assets/Scripts/Effects/FxClear.cs b/Assets/Scripts/Effects/FxClear.cs index f5d3dff9..6b26da6c 100644 --- a/Assets/Scripts/Effects/FxClear.cs +++ b/Assets/Scripts/Effects/FxClear.cs @@ -50,59 +50,27 @@ public struct PlayEffectInfo } } -#if UNITY_EDITOR -[ExecuteInEditMode] -#endif public class FxClear : MonoBehaviour { - [SerializeField] public float ClearTime = 2f; private EffectPlayTypes m_EffectPlayType = EffectPlayTypes.None; - /// - /// 이름만 root. effect Tr 싱크 위해 사용. - /// + public float time { get { return m_curTime; } } + private Transform m_rootTr = null; private float m_curTime = 0.0f; - //private bool m_bExistTr = false; private bool m_bAttached = false; + private Vector3 m_offset = Vector3.zero; private Vector3 m_rot = Vector3.zero; private Vector3 m_scale = Vector3.zero; - private int m_ownerDbId = 0; - - public int ownerDbId - { - get - { - return m_ownerDbId; - } - } - - private bool m_bUIEffect = false; - #if UNITY_EDITOR private double m_prevTime = 0.0f; private float m_removeWaitTime = 0.0f; - private bool m_runInEditor = false; private bool m_destroyRequested = false; - - private List m_Particles = null; - - public bool RunInEditor - { - get - { - return m_runInEditor; - } - set - { - m_runInEditor = value; - } - } #endif private void Awake() @@ -114,32 +82,11 @@ public class FxClear : MonoBehaviour private void Start() { -#if UNITY_EDITOR - if (m_runInEditor) - { - UnityEditor.EditorApplication.update += Update; - m_prevTime = UnityEditor.EditorApplication.timeSinceStartup; - return; - } -#endif } private void OnDestroy() { Release(); - -#if UNITY_EDITOR - - if (m_runInEditor) - { - if (m_Particles != null) - { - m_Particles.Clear(); - m_Particles = null; - } - } - -#endif } public void Initialize(PlayEffectInfo info) @@ -152,30 +99,6 @@ public class FxClear : MonoBehaviour m_rot = info.rot; m_scale = info.scale; m_bAttached = info.bAttached; - m_ownerDbId = info.dbId; - m_bUIEffect = info.bUIEffect; - -#if UNITY_EDITOR - - if (m_runInEditor) - { - if (m_Particles == null) - { - m_Particles = new List(); - - transform.DoRecursively(x => - { - ParticleSystem sys = x.GetComponent(); - - if (sys != null) - { - m_Particles.Add(sys); - sys.Stop(); - } - }); - } - } -#endif SyncTr(); gameObject.SetActive(true); @@ -184,17 +107,11 @@ public class FxClear : MonoBehaviour public void Release() { m_rootTr = null; - m_ownerDbId = 0; m_curTime = 0.0f; - //m_bExistTr = false; m_bAttached = false; m_offset = Vector3.zero; m_rot = Vector3.zero; m_scale = Vector3.zero; - m_bUIEffect = false; -#if UNITY_EDITOR - m_removeWaitTime = 0.0f; -#endif } private void SyncTr() @@ -202,29 +119,29 @@ public class FxClear : MonoBehaviour #if UNITY_EDITOR if (transform == null || transform.gameObject == null) return; - if (m_runInEditor) - { - if (m_rootTr == null) - { - transform.position = m_offset; - } - else - { - - transform.localRotation = m_rootTr.rotation; - - if (m_bAttached) - { - transform.position = m_rootTr.position + (m_rootTr.rotation * m_offset); - } - else - { - transform.position = m_rootTr.position - (m_rootTr.rotation * m_offset); - } - } - } - else - { + //if (m_runInEditor) + //{ + // if (m_rootTr == null) + // { + // transform.position = m_offset; + // } + // else + // { + + // transform.localRotation = m_rootTr.rotation; + + // if (m_bAttached) + // { + // transform.position = m_rootTr.position + (m_rootTr.rotation * m_offset); + // } + // else + // { + // transform.position = m_rootTr.position - (m_rootTr.rotation * m_offset); + // } + // } + //} + //else + //{ if (m_rootTr == null) { transform.position = m_offset; @@ -242,7 +159,7 @@ public class FxClear : MonoBehaviour transform.position = m_rootTr.position + (m_rootTr.rotation * m_offset); } - } + //} #else if (m_rootTr == null) { @@ -265,14 +182,9 @@ public class FxClear : MonoBehaviour #if UNITY_EDITOR - if (m_runInEditor == false && m_bAttached && m_rootTr != null) + if (m_bAttached && m_rootTr != null) { transform.SetParent(m_rootTr); - - if (m_bUIEffect) - { - transform.localPosition = m_offset; - } } #else @@ -280,10 +192,6 @@ public class FxClear : MonoBehaviour if (m_bAttached && m_rootTr != null) { transform.SetParent(m_rootTr); - if (m_bUIEffect) - { - transform.localPosition = m_offset; - } } #endif @@ -300,122 +208,22 @@ public class FxClear : MonoBehaviour public void Restore() { - if (m_EffectPlayType == EffectPlayTypes.None) - { - DestroyImmediate(this.gameObject); - return; - } - - //EffectManager.Instance.RestoreEffect(this); + DestroyImmediate(this.gameObject); } -#if UNITY_EDITOR - - private void UpdateInEditMode() + public void UpdateFunc(float dt) { - if (!m_destroyRequested) - { - double timeDelta = UnityEditor.EditorApplication.timeSinceStartup - m_prevTime; - m_prevTime = UnityEditor.EditorApplication.timeSinceStartup; - - if (m_removeWaitTime <= 0.0f) // 순서 관계.. - { - if (ClearTime > 0.0f) - { - if (ClearTime < m_curTime) - { - List selectBuffer = new List(); - - if (m_Particles != null) - { - for (int i = 0; i < m_Particles.Count; i++) - { - m_Particles[i].Stop(); - m_Particles[i].gameObject.SetActive(false); - } - - Object[] selectedObjects = UnityEditor.Selection.objects; - for (int i = 0; i < selectedObjects.Length; i++) - { - if (m_Particles.Find(e => e.gameObject.GetInstanceID() == selectedObjects[i].GetInstanceID()) == null) - { - selectBuffer.Add(m_Particles[i]); - } - } - UnityEditor.Selection.objects = selectBuffer.ToArray(); - if (UnityEditor.Selection.selectionChanged != null) - { - UnityEditor.Selection.selectionChanged(); - } - } - - m_removeWaitTime = 1.0f; - } - else - { - if (m_Particles != null) - { - for (int i = 0; i < m_Particles.Count; i++) - { - m_Particles[i].Simulate(m_curTime); - } - } - } - } - } - else - { - m_removeWaitTime -= (float)timeDelta; - if (m_removeWaitTime < 0.0f) - { - transform.parent = null; - UnityEditor.EditorApplication.update -= Update; - DestroyImmediate(gameObject); - - m_destroyRequested = true; - return; - } - } - - SyncTr(); - } - } - -#endif - - private void Update() - { - m_curTime += Time.unscaledDeltaTime; - -#if UNITY_EDITOR - if (m_runInEditor) - { - UpdateInEditMode(); - return; - } -#endif - + m_curTime += dt; + SyncTr(); if (m_EffectPlayType != EffectPlayTypes.Loop && m_curTime >= ClearTime) { Restore(); return; } + } - //rootTr이 애초에 비어있으면 싱크 맞춰줄 필요 없음. - EffectMgr 통해서 관리되지 않는 이펙트. - //if (m_bExistTr == false) - // return; - // - //if (m_rootTr == null || m_rootTr.gameObject.activeInHierarchy == false) - //{ - // Restore(); - // return; - //} - // - //if (m_bAttached == false) - //{ - // return; - //} - // - //SyncTr(); + private void Update() + { + UpdateFunc(Time.unscaledDeltaTime); } } \ No newline at end of file diff --git a/Assets/Scripts/Input/InputManager.cs b/Assets/Scripts/Input/InputManager.cs index 838409b5..4ad6ec02 100644 --- a/Assets/Scripts/Input/InputManager.cs +++ b/Assets/Scripts/Input/InputManager.cs @@ -38,10 +38,11 @@ public class InputManager : SingletonMB cmd.key = vKey; cmd.time = Time.time; m_CommandQueue.Add(cmd); - Debug.Log(cmd.time); - string cmdStr = ""; - m_CommandQueue.ForEach(s => cmdStr += s.key.ToString() + ","); - Debug.Log(cmdStr); + + //Debug.Log(cmd.time); + //string cmdStr = ""; + //m_CommandQueue.ForEach(s => cmdStr += s.key.ToString() + ","); + //Debug.Log(cmdStr); } } float curTime = Time.time; diff --git a/Assets/Scripts/Line3D.meta b/Assets/Scripts/Line3D.meta new file mode 100644 index 00000000..7ca25728 --- /dev/null +++ b/Assets/Scripts/Line3D.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: df7762b0e9f4ea643822227dc54aa423 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scripts/Line3D/Line3DRenderer.cs b/Assets/Scripts/Line3D/Line3DRenderer.cs new file mode 100644 index 00000000..d16916cb --- /dev/null +++ b/Assets/Scripts/Line3D/Line3DRenderer.cs @@ -0,0 +1,18 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +public class Line3DRenderer : MonoBehaviour +{ + // Start is called before the first frame update + void Start() + { + + } + + // Update is called once per frame + void Update() + { + + } +} diff --git a/Assets/Scripts/Line3D/Line3DRenderer.cs.meta b/Assets/Scripts/Line3D/Line3DRenderer.cs.meta new file mode 100644 index 00000000..ad2c4500 --- /dev/null +++ b/Assets/Scripts/Line3D/Line3DRenderer.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: f4af360e8a036c74499160090bb71ff7 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scripts/Projectile/Projectile.cs b/Assets/Scripts/Projectile/Projectile.cs index b1eb1b61..a6411f5f 100644 --- a/Assets/Scripts/Projectile/Projectile.cs +++ b/Assets/Scripts/Projectile/Projectile.cs @@ -59,7 +59,7 @@ public class Projectile : MonoBehaviour private List m_Hitmask; - private float time; + public float time; private bool markDestroy; @@ -94,7 +94,7 @@ public class Projectile : MonoBehaviour { this.transform.position += this.velocity * deltaTime; time += deltaTime; - if(time > this.lifetime || markDestroy) + if (time > this.lifetime || markDestroy) { DestroyImmediate(this.gameObject); } @@ -170,6 +170,9 @@ public class Projectile : MonoBehaviour if (spark) { GameObject obj = GameObject.Instantiate(spark); +#if UNITY_EDITOR + obj.transform.SetParent(TimelineEventProxy.Root_Particles.transform); +#endif obj.transform.position = collision.collidee.unitCollider.owner.center; markDestroy = true; diff --git a/Assets/Scripts/Unit/Action/WaitForActionReachEnd.cs b/Assets/Scripts/Unit/Action/WaitForActionReachEnd.cs index c2dd5f92..771e946b 100644 --- a/Assets/Scripts/Unit/Action/WaitForActionReachEnd.cs +++ b/Assets/Scripts/Unit/Action/WaitForActionReachEnd.cs @@ -18,9 +18,8 @@ public class WaitForActionReachEnd : IEnumerator public bool MoveNext() { - var stateInfo = m_UnitAnimation.layers[m_Layer].stateInfo; - float normalTime = stateInfo.normalizedTime; - return normalTime < 1f; + var layer = m_UnitAnimation.layers[m_Layer]; + return layer.playbackNormalizedTime < 1f; } public void Reset() diff --git a/Assets/Scripts/Unit/Collider/CollisionSystem.cs b/Assets/Scripts/Unit/Collider/CollisionSystem.cs index e84c54a9..4a73446f 100644 --- a/Assets/Scripts/Unit/Collider/CollisionSystem.cs +++ b/Assets/Scripts/Unit/Collider/CollisionSystem.cs @@ -126,10 +126,14 @@ public class CollisionSystem : SingletonMB foreach (var projectile in registry.projectiles) { + if (projectile == null) + continue; for(int i = 0; i < hurtboxes.Count; ++i) { ColliderDescriptor hurtCollider = hurtboxes[i]; - if (projectile.owner.type == hurtCollider.unitCollider.owner.type) + if (hurtCollider.unitCollider == null) + continue; + if (projectile.owner == null || hurtCollider.unitCollider.owner == null || projectile.owner.type == hurtCollider.unitCollider.owner.type) continue; Box hurtbox = ColliderUtility.GetColliderInWorldSpace(hurtCollider); foreach (var itor in projectile.GetCollidersInWorldSpace()) diff --git a/Assets/Scripts/Unit/Components/UnitAnimation/UnitAnimation.cs b/Assets/Scripts/Unit/Components/UnitAnimation/UnitAnimation.cs index 6d17971d..1a990252 100644 --- a/Assets/Scripts/Unit/Components/UnitAnimation/UnitAnimation.cs +++ b/Assets/Scripts/Unit/Components/UnitAnimation/UnitAnimation.cs @@ -45,7 +45,7 @@ public class AnimatorLayerInfo get { AnimatorStateInfo stateInfo = m_Animator.GetCurrentAnimatorStateInfo(layerIndex); - if (isInTransition) + if (isInTransition) // 过渡中的动作认为当前动作是下一个动作 { stateInfo = m_Animator.GetNextAnimatorStateInfo(layerIndex); } @@ -62,7 +62,7 @@ public class AnimatorLayerInfo get { AnimatorClipInfo[] clips = null; - if (!isInTransition) + if (!isInTransition) { clips = m_Animator.GetCurrentAnimatorClipInfo(layerIndex); if (clips.Length == 0) @@ -70,7 +70,7 @@ public class AnimatorLayerInfo clips = m_Animator.GetNextAnimatorClipInfo(layerIndex); } } - else + else // 过渡中的动作认为当前动作是下一个动作 { clips = m_Animator.GetNextAnimatorClipInfo(layerIndex); } diff --git a/Assets/Scripts/Unit/Components/UnitState/PCState.cs b/Assets/Scripts/Unit/Components/UnitState/PCState.cs index 435591b0..6bd6fa78 100644 --- a/Assets/Scripts/Unit/Components/UnitState/PCState.cs +++ b/Assets/Scripts/Unit/Components/UnitState/PCState.cs @@ -210,12 +210,12 @@ public class PCState : UnitState { const int total = 3; int id = 0; - m_Owner.pcAnimation.AnimAttack(id); + m_Owner.pcAnimation.AnimAttack(id++); yield return null; while (true) { bool canCombo = m_Owner.pcAnimation.baseLayer.IsToggleOpen(EAnimationToogle.Combo); - if (canCombo) + if (canCombo && id < total) { if (Input.GetKeyDown("j")) { @@ -227,9 +227,8 @@ public class PCState : UnitState { TurnAround(true); } - ++id; - m_Owner.pcAnimation.AnimAttack(id); - yield return null; + m_Owner.pcAnimation.AnimAttack(id++); + yield return null; yield return new WaitForTransitionDone(m_Owner.pcAnimation); } } diff --git a/Assets/Scripts/Unit/TimelineEventProxy.cs b/Assets/Scripts/Unit/TimelineEventProxy.cs index 825cf5bf..e56f590a 100644 --- a/Assets/Scripts/Unit/TimelineEventProxy.cs +++ b/Assets/Scripts/Unit/TimelineEventProxy.cs @@ -8,10 +8,36 @@ using UnityEngine; [DisallowMultipleComponent] public partial class TimelineEventProxy { + #if UNITY_EDITOR // ActionTool里 + private static GameObject m_Root_Particles; + public static GameObject Root_Particles + { + get + { + if (m_Root_Particles == null) + m_Root_Particles = new GameObject("Root_Particles"); + return m_Root_Particles; + } + } + private static GameObject m_Root_Projectiles; + public static GameObject Root_Projectiles + { + get + { + if (m_Root_Projectiles == null) + m_Root_Projectiles = new GameObject("Root_Projectiles"); + return m_Root_Projectiles; + } + } + public bool isInEditMode; + public delegate void RegisterProjectileHandle(Projectile projectile); public RegisterProjectileHandle registerProjectile; + + public delegate void RegisterParticleSystemHandle(FxClear vfx); + public RegisterParticleSystemHandle registerParticleSystem; #endif public enum EEventType @@ -91,8 +117,10 @@ public partial class TimelineEventProxy } } m_PrevFrame = frame; - } - + } + + #region Event Handles + void ExecuteEvents(List events) { if (events == null || events.Count == 0) @@ -122,9 +150,16 @@ public partial class TimelineEventProxy GameObject go = GameObject.Instantiate(prefab); go.transform.SetParent(root.transform); - FxClear onClear = root.AddComponent(); - onClear.RunInEditor = true; - onClear.Initialize(new PlayEffectInfo(path, EffectPlayTypes.Oneshot, m_Root, effect.position, effect.rotation, effect.scale, 0, false)); + FxClear onClear = root.AddComponent(); + onClear.gameObject.name = prefab.name + "(Clone)"; + onClear.Initialize(new PlayEffectInfo(path, EffectPlayTypes.Oneshot, m_Root, effect.position, effect.rotation, effect.scale, 0, false)); +#if UNITY_EDITOR + if (isInEditMode && registerParticleSystem != null) + { + registerParticleSystem(onClear); + } + onClear.gameObject.transform.SetParent(Root_Particles.transform); +#endif } } @@ -168,7 +203,10 @@ public partial class TimelineEventProxy { registerProjectile(projectile); } + obj.transform.SetParent(Root_Projectiles.transform); #endif - } - + } + + #endregion + } \ No newline at end of file -- cgit v1.1-26-g67d0