diff --git a/2D/MovementController.cs b/2D/MovementController.cs new file mode 100644 index 0000000..43137f4 --- /dev/null +++ b/2D/MovementController.cs @@ -0,0 +1,62 @@ +using System.Collections.Generic; +using Syntriax.Modules.Movement.State; +using UnityEngine; +using UnityEngine.Events; + + +namespace Syntriax.Modules.Movement +{ + public class MovementController : MonoBehaviour, IMovementController + { + + public IMovement ActiveMovement { get; protected set; } = null; + public UnityEvent OnMovementChanged { get; protected set; } = new UnityEvent(); + + protected List movements = new List(32); + protected IToggleState toggleState = null; + + protected virtual void Start() + { + toggleState = GetComponent(); + UpdateMovementCache(); + } + + protected virtual void FixedUpdate() + { + if (!toggleState.Toggled) + return; + + ActiveMovement.ApplyMovement(); + } + + protected virtual void UpdateMovementCache() + { + foreach (IMovement movement in movements) + movement.OnTakeOverStateChanged.RemoveListener(OnTakeOverListener); + + movements.Clear(); + GetComponents(movements); + UpdateActiveMovement(); + + foreach (IMovement movement in movements) + movement.OnTakeOverStateChanged.AddListener(OnTakeOverListener); + + } + + private void OnTakeOverListener(bool arg0) => UpdateActiveMovement(); + + protected virtual void UpdateActiveMovement() + { + foreach (IMovement movement in movements) + if (movement.CanTakeOver) + { + ActiveMovement = movement; + OnMovementChanged.Invoke(ActiveMovement); + return; + } + + ActiveMovement = movements[movements.Count - 1]; + OnMovementChanged.Invoke(ActiveMovement); + } + } +} diff --git a/ColliderCheck/ColliderCheckFactory.cs.meta b/2D/MovementController.cs.meta similarity index 83% rename from ColliderCheck/ColliderCheckFactory.cs.meta rename to 2D/MovementController.cs.meta index b7a7785..867aca0 100644 --- a/ColliderCheck/ColliderCheckFactory.cs.meta +++ b/2D/MovementController.cs.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: b1da221e5cee86a429230fca11bdf8dd +guid: f9a57082945be29498d2785f8be6484d MonoImporter: externalObjects: {} serializedVersion: 2 diff --git a/2D/OneDimensional2DAirMovement.cs b/2D/OneDimensional2DAirMovement.cs deleted file mode 100644 index f043d71..0000000 --- a/2D/OneDimensional2DAirMovement.cs +++ /dev/null @@ -1,54 +0,0 @@ -using Syntriax.Modules.Movement.ColliderCheck; -using UnityEngine; - -namespace Syntriax.Modules.Movement -{ - [RequireComponent(typeof(Rigidbody2D))] - public class OneDimensional2DAirMovement : MonoBehaviour, IMovement, IState - { - private IGroundCheck groundCheck = null; - private Rigidbody2D rigid = null; - private float moveValue = 0f; - - - public bool IsActive => StateEnabled && !groundCheck.IsCollided(); - public bool StateEnabled { get; set; } = true; - public float BaseSpeed { get; set; } = 1f; - public float MovementMultiplier { get; set; } = 1f; - - private void Start() - { - rigid = GetComponent(); - groundCheck = GetComponentInChildren(); - } - - private void FixedUpdate() - { - if (!IsActive) - return; - - ApplyMovement(); - } - - private void ApplyMovement() - { - Vector2 velocity = rigid.velocity; - velocity.x += moveValue * Time.fixedDeltaTime; - - if (moveValue != 0f) - { - if (Mathf.Abs(velocity.x) > Mathf.Abs(moveValue)) - velocity.x = moveValue; - else if (Mathf.Abs(velocity.x - moveValue) > Mathf.Abs(moveValue)) - velocity.x += moveValue * Time.fixedDeltaTime; - } - - rigid.velocity = velocity; - } - - public void Move(float x = 0, float y = 0, float z = 0) - { - moveValue = x * BaseSpeed * MovementMultiplier; - } - } -} diff --git a/2D/OneDimensional2DGroundMovement.cs b/2D/OneDimensional2DGroundMovement.cs deleted file mode 100644 index ec820bd..0000000 --- a/2D/OneDimensional2DGroundMovement.cs +++ /dev/null @@ -1,44 +0,0 @@ -using Syntriax.Modules.Movement.ColliderCheck; -using UnityEngine; - -namespace Syntriax.Modules.Movement -{ - [RequireComponent(typeof(Rigidbody2D))] - public class OneDimensional2DGroundMovement : MonoBehaviour, IMovement, IState - { - private IGroundCheck groundCheck = null; - private Rigidbody2D rigid = null; - private float moveValue = 0f; - - public bool IsActive => StateEnabled && groundCheck.IsCollided(); - public bool StateEnabled { get; set; } = true; - public float BaseSpeed { get; set; } = 1f; - public float MovementMultiplier { get; set; } = 1f; - - private void Start() - { - rigid = GetComponent(); - groundCheck = GetComponentInChildren(); - } - - private void FixedUpdate() - { - if (!IsActive) - return; - - ApplyMovement(); - } - - private void ApplyMovement() - { - Vector2 velocity = rigid.velocity; - velocity.x = moveValue; - rigid.velocity = velocity; - } - - public void Move(float x = 0, float y = 0, float z = 0) - { - moveValue = x * BaseSpeed * MovementMultiplier; - } - } -} diff --git a/2D/OneWay2DAirMovement.cs b/2D/OneWay2DAirMovement.cs new file mode 100644 index 0000000..0e2126d --- /dev/null +++ b/2D/OneWay2DAirMovement.cs @@ -0,0 +1,37 @@ +using Syntriax.Modules.Movement.ColliderTrigger; +using UnityEngine; + +namespace Syntriax.Modules.Movement +{ + public class OneWay2DAirMovement : OneWay2DMovementBase + { + protected override float moveValue { get; set; } = 0f; + protected IGroundTrigger groundTrigger = null; + + protected override void Start() + { + base.Start(); + groundTrigger = GetComponentInChildren(); + groundTrigger.OnTriggered.AddListener(OnGroundTrigger); + } + + private void OnGroundTrigger(bool isGrounded) + => CanTakeOver = !isGrounded; + + public override void ApplyMovement() + { + Vector2 velocity = rigid.velocity; + velocity.x += moveValue * Time.fixedDeltaTime; + + if (moveValue != 0f) + { + if (Mathf.Abs(velocity.x) > Mathf.Abs(moveValue)) + velocity.x = moveValue; + else if (Mathf.Abs(velocity.x - moveValue) > Mathf.Abs(moveValue)) + velocity.x += moveValue * Time.fixedDeltaTime; + } + + rigid.velocity = velocity; + } + } +} diff --git a/2D/OneDimensional2DAirMovement.cs.meta b/2D/OneWay2DAirMovement.cs.meta similarity index 83% rename from 2D/OneDimensional2DAirMovement.cs.meta rename to 2D/OneWay2DAirMovement.cs.meta index 497661e..81dfb1f 100644 --- a/2D/OneDimensional2DAirMovement.cs.meta +++ b/2D/OneWay2DAirMovement.cs.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: 12a58daabbf3fa8418a164390a593753 +guid: 2f38efc38cadfd94ba8698189577f60f MonoImporter: externalObjects: {} serializedVersion: 2 diff --git a/2D/OneWay2DGroundMovement.cs b/2D/OneWay2DGroundMovement.cs new file mode 100644 index 0000000..064a92e --- /dev/null +++ b/2D/OneWay2DGroundMovement.cs @@ -0,0 +1,28 @@ +using Syntriax.Modules.Movement.ColliderTrigger; +using UnityEngine; + +namespace Syntriax.Modules.Movement +{ + public class OneWay2DGroundMovement : OneWay2DMovementBase + { + protected override float moveValue { get; set; } = 0f; + protected IGroundTrigger groundTrigger = null; + + protected override void Start() + { + base.Start(); + groundTrigger = GetComponentInChildren(); + groundTrigger.OnTriggered.AddListener(OnGroundTrigger); + } + + private void OnGroundTrigger(bool isGrounded) + => CanTakeOver = isGrounded; + + public override void ApplyMovement() + { + Vector2 velocity = rigid.velocity; + velocity.x = moveValue; + rigid.velocity = velocity; + } + } +} diff --git a/ColliderCheck/Ground/IGroundCheck.cs.meta b/2D/OneWay2DGroundMovement.cs.meta similarity index 83% rename from ColliderCheck/Ground/IGroundCheck.cs.meta rename to 2D/OneWay2DGroundMovement.cs.meta index fa60c1b..cc344f8 100644 --- a/ColliderCheck/Ground/IGroundCheck.cs.meta +++ b/2D/OneWay2DGroundMovement.cs.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: 2cbb917bc29d63241aa50c7fe8dc141d +guid: 9c73429b47407634daead7ee1b52629d MonoImporter: externalObjects: {} serializedVersion: 2 diff --git a/2D/OneWay2DMovementBase.cs b/2D/OneWay2DMovementBase.cs new file mode 100644 index 0000000..338ee77 --- /dev/null +++ b/2D/OneWay2DMovementBase.cs @@ -0,0 +1,10 @@ +namespace Syntriax.Modules.Movement +{ + public abstract class OneWay2DMovementBase : TwoDimensionalMovementBase + { + protected abstract float moveValue { get; set; } + + public override void Move(float x = 0, float y = 0, float z = 0) + => moveValue = x * BaseSpeed * MovementMultiplier; + } +} diff --git a/2D/OneDimensional2DGroundMovement.cs.meta b/2D/OneWay2DMovementBase.cs.meta similarity index 83% rename from 2D/OneDimensional2DGroundMovement.cs.meta rename to 2D/OneWay2DMovementBase.cs.meta index 407916c..24940ac 100644 --- a/2D/OneDimensional2DGroundMovement.cs.meta +++ b/2D/OneWay2DMovementBase.cs.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: 849a6316df6662a48ae6cfcd4c2fbc1e +guid: 51ee606e68723324b92b9d16835c1625 MonoImporter: externalObjects: {} serializedVersion: 2 diff --git a/2D/TwoDimensionalMovementBase.cs b/2D/TwoDimensionalMovementBase.cs new file mode 100644 index 0000000..963d0c2 --- /dev/null +++ b/2D/TwoDimensionalMovementBase.cs @@ -0,0 +1,48 @@ +using Syntriax.Modules.Movement.State; +using UnityEngine; +using UnityEngine.Events; + +namespace Syntriax.Modules.Movement +{ + [RequireComponent(typeof(Rigidbody2D))] + public abstract class TwoDimensionalMovementBase : MonoBehaviour, IMovement + { + protected Rigidbody2D rigid = null; + protected IToggleState toggleState = null; + private bool _canTakeOver = false; + + public float BaseSpeed { get; set; } = 1f; + public float MovementMultiplier { get; set; } = 1f; + + public UnityEvent OnTakeOverStateChanged { get; protected set; } = null; + public bool CanTakeOver + { + get => _canTakeOver; + protected set + { + bool isNewValue = _canTakeOver != value; + + _canTakeOver = value; + + if (isNewValue) + OnTakeOverStateChanged.Invoke(value); + } + } + + public IToggleState ToggleState { get; protected set; } = null; + + protected virtual void Awake() + { + OnTakeOverStateChanged = new UnityEvent(); + } + + protected virtual void Start() + { + rigid = GetComponent(); + toggleState = GetComponent(); + } + + public abstract void Move(float x = 0, float y = 0, float z = 0); + public abstract void ApplyMovement(); + } +} diff --git a/2D/TwoDimensionalMovementBase.cs.meta b/2D/TwoDimensionalMovementBase.cs.meta new file mode 100644 index 0000000..8c1b357 --- /dev/null +++ b/2D/TwoDimensionalMovementBase.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: b4a8f74afcbe280448862bac89545353 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/ColliderCheck/ColliderCheckFactory.cs b/ColliderCheck/ColliderCheckFactory.cs deleted file mode 100644 index 9dbc94b..0000000 --- a/ColliderCheck/ColliderCheckFactory.cs +++ /dev/null @@ -1,7 +0,0 @@ -namespace Syntriax.Modules.Movement.ColliderCheck -{ - public class ColliderCheckFactory : TypeFactoryBaseMonoBehaviour - { - protected override int InitialCapacity => 8; - } -} diff --git a/ColliderCheck/Ground/IGroundCheck.cs b/ColliderCheck/Ground/IGroundCheck.cs deleted file mode 100644 index 402a9aa..0000000 --- a/ColliderCheck/Ground/IGroundCheck.cs +++ /dev/null @@ -1,4 +0,0 @@ -namespace Syntriax.Modules.Movement.ColliderCheck -{ - public interface IGroundCheck : IColliderCheck { } -} diff --git a/ColliderCheck/Ground/IGroundTrigger.cs b/ColliderCheck/Ground/IGroundTrigger.cs new file mode 100644 index 0000000..b0402f7 --- /dev/null +++ b/ColliderCheck/Ground/IGroundTrigger.cs @@ -0,0 +1,4 @@ +namespace Syntriax.Modules.Movement.ColliderTrigger +{ + public interface IGroundTrigger : IColliderTrigger { } +} diff --git a/ColliderCheck/Ground/IGroundTrigger.cs.meta b/ColliderCheck/Ground/IGroundTrigger.cs.meta new file mode 100644 index 0000000..56118a3 --- /dev/null +++ b/ColliderCheck/Ground/IGroundTrigger.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 91b4c4b7439cfcb448a15d0f2ce12ff9 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/ColliderCheck/Ground/TwoDimensionalBoxChildGroundCheck.cs b/ColliderCheck/Ground/TwoDimensionalBoxChildGroundCheck.cs deleted file mode 100644 index 98a6642..0000000 --- a/ColliderCheck/Ground/TwoDimensionalBoxChildGroundCheck.cs +++ /dev/null @@ -1,4 +0,0 @@ -namespace Syntriax.Modules.Movement.ColliderCheck -{ - public class TwoDimensionalBoxChildGroundCheck : TwoDimensionalBoxChildColliderCheck, IGroundCheck { } -} diff --git a/ColliderCheck/Ground/TwoDimensionalBoxChildGroundCheck.cs.meta b/ColliderCheck/Ground/TwoDimensionalBoxChildGroundCheck.cs.meta deleted file mode 100644 index 4eb6962..0000000 --- a/ColliderCheck/Ground/TwoDimensionalBoxChildGroundCheck.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: a878fb141e25e954c9b73eff8657605a -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/ColliderCheck/Ground/TwoDimensionalBoxChildGroundTrigger.cs b/ColliderCheck/Ground/TwoDimensionalBoxChildGroundTrigger.cs new file mode 100644 index 0000000..4e53415 --- /dev/null +++ b/ColliderCheck/Ground/TwoDimensionalBoxChildGroundTrigger.cs @@ -0,0 +1,4 @@ +namespace Syntriax.Modules.Movement.ColliderTrigger +{ + public class TwoDimensionalBoxChildGroundTrigger : TwoDimensionalBoxChildColliderTrigger, IGroundTrigger { } +} diff --git a/ColliderCheck/Ground/TwoDimensionalBoxChildGroundTrigger.cs.meta b/ColliderCheck/Ground/TwoDimensionalBoxChildGroundTrigger.cs.meta new file mode 100644 index 0000000..46ef330 --- /dev/null +++ b/ColliderCheck/Ground/TwoDimensionalBoxChildGroundTrigger.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 1213a467d17883844b2dc54d266cf211 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/ColliderCheck/IColliderCheck.cs b/ColliderCheck/IColliderCheck.cs deleted file mode 100644 index 04ca753..0000000 --- a/ColliderCheck/IColliderCheck.cs +++ /dev/null @@ -1,10 +0,0 @@ -using UnityEngine; - -namespace Syntriax.Modules.Movement.ColliderCheck -{ - public interface IColliderCheck - { - LayerMask ColliderMask { get; set; } - bool IsColliderDetected { get; } - } -} diff --git a/ColliderCheck/IColliderCheck.cs.meta b/ColliderCheck/IColliderCheck.cs.meta deleted file mode 100644 index d0f4f28..0000000 --- a/ColliderCheck/IColliderCheck.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 164c4b9411986c14e8012b2e7fdd2a6a -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/ColliderCheck/IColliderCheckExtensions.cs b/ColliderCheck/IColliderCheckExtensions.cs index c427d25..22c12c4 100644 --- a/ColliderCheck/IColliderCheckExtensions.cs +++ b/ColliderCheck/IColliderCheckExtensions.cs @@ -1,8 +1,8 @@ -namespace Syntriax.Modules.Movement.ColliderCheck +namespace Syntriax.Modules.Movement.ColliderTrigger { - public static class IColliderCheckExtensions + public static class IColliderTriggerExtensions { - public static bool IsCollided(this IColliderCheck colliderCheck) - => colliderCheck == null ? true : colliderCheck.IsColliderDetected; + public static bool IsTriggeredNullChecked(this IColliderTrigger colliderCheck) + => colliderCheck == null ? true : colliderCheck.IsTrigerred; } } diff --git a/ColliderCheck/IColliderTrigger.cs b/ColliderCheck/IColliderTrigger.cs new file mode 100644 index 0000000..2296f90 --- /dev/null +++ b/ColliderCheck/IColliderTrigger.cs @@ -0,0 +1,12 @@ +using UnityEngine; +using UnityEngine.Events; + +namespace Syntriax.Modules.Movement.ColliderTrigger +{ + public interface IColliderTrigger + { + LayerMask ColliderMask { get; set; } + bool IsTrigerred { get; } + UnityEvent OnTriggered { get; } + } +} diff --git a/ColliderCheck/IColliderTrigger.cs.meta b/ColliderCheck/IColliderTrigger.cs.meta new file mode 100644 index 0000000..3503f91 --- /dev/null +++ b/ColliderCheck/IColliderTrigger.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 8ab2264f0e385af4d8decc8750297a9e +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/ColliderCheck/TwoDimensionalBoxChildColliderCheck.cs b/ColliderCheck/TwoDimensionalBoxChildColliderCheck.cs index 800a8ab..255a42a 100644 --- a/ColliderCheck/TwoDimensionalBoxChildColliderCheck.cs +++ b/ColliderCheck/TwoDimensionalBoxChildColliderCheck.cs @@ -1,22 +1,40 @@ using UnityEngine; +using UnityEngine.Events; -namespace Syntriax.Modules.Movement.ColliderCheck +namespace Syntriax.Modules.Movement.ColliderTrigger { - public class TwoDimensionalBoxChildColliderCheck : MonoBehaviour, IColliderCheck, IState + public class TwoDimensionalBoxChildColliderTrigger : MonoBehaviour, IColliderTrigger { [SerializeField] private LayerMask colliderMask = 0; + private bool _isTrigerred = false; public LayerMask ColliderMask { get => colliderMask; set => colliderMask = value; } - public bool IsColliderDetected - => StateEnabled ? Physics2D.OverlapBox(transform.position, transform.localScale, 0, ColliderMask) != null : true; + public UnityEvent OnTriggered { get; protected set; } = null; + public bool IsTrigerred + { + get => _isTrigerred; + protected set + { + bool isNewValue = _isTrigerred != value; - public bool StateEnabled { get; set; } = true; + _isTrigerred = value; + + if (isNewValue) + OnTriggered.Invoke(value); + } + } + + protected void Awake() + => OnTriggered = new UnityEvent(); + + protected void FixedUpdate() + => IsTrigerred = Physics2D.OverlapBox(transform.position, transform.localScale, 0, ColliderMask) != null; #if UNITY_EDITOR private void OnDrawGizmosSelected() { - Gizmos.color = IsColliderDetected ? Color.green : Color.red; + Gizmos.color = IsTrigerred ? Color.green : Color.red; Gizmos.DrawWireCube(transform.position, transform.lossyScale); } #endif diff --git a/IMovement.cs b/IMovement.cs index d2c58b8..a521822 100644 --- a/IMovement.cs +++ b/IMovement.cs @@ -1,10 +1,17 @@ +using UnityEngine.Events; + namespace Syntriax.Modules.Movement { public interface IMovement { float BaseSpeed { get; set; } float MovementMultiplier { get; set; } - bool IsActive { get; } + + bool CanTakeOver { get; } + + UnityEvent OnTakeOverStateChanged { get; } + void Move(float x = 0f, float y = 0f, float z = 0f); + void ApplyMovement(); } } diff --git a/IMovementController.cs b/IMovementController.cs index 96b59ea..39a53a5 100644 --- a/IMovementController.cs +++ b/IMovementController.cs @@ -1,4 +1,10 @@ +using UnityEngine.Events; + namespace Syntriax.Modules.Movement { - public interface IMovementController : IState { } + public interface IMovementController + { + IMovement ActiveMovement { get; } + UnityEvent OnMovementChanged { get; } + } } diff --git a/IState.cs b/IState.cs deleted file mode 100644 index 2c46199..0000000 --- a/IState.cs +++ /dev/null @@ -1,7 +0,0 @@ -namespace Syntriax.Modules.Movement -{ - public interface IState - { - bool StateEnabled { get; set; } - } -} diff --git a/IState.cs.meta b/IState.cs.meta deleted file mode 100644 index 1d371a8..0000000 --- a/IState.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 02daadcda38072a4ca4798b8f8800f53 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/MovementControllerFactory.cs b/MovementControllerFactory.cs deleted file mode 100644 index 89558e1..0000000 --- a/MovementControllerFactory.cs +++ /dev/null @@ -1,7 +0,0 @@ -namespace Syntriax.Modules.Movement -{ - public class MovementControllerFactory : TypeFactoryBaseMonoBehaviour - { - protected override int InitialCapacity => 8; - } -} diff --git a/MovementControllerFactory.cs.meta b/MovementControllerFactory.cs.meta deleted file mode 100644 index 5e10e4a..0000000 --- a/MovementControllerFactory.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 975e4749036474b48a4a3fb36949be3f -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/MovementFactory.cs b/MovementFactory.cs deleted file mode 100644 index de17302..0000000 --- a/MovementFactory.cs +++ /dev/null @@ -1,7 +0,0 @@ -namespace Syntriax.Modules.Movement -{ - public class MovementFactory : TypeFactoryBaseMonoBehaviour - { - protected override int InitialCapacity => 8; - } -} diff --git a/MovementFactory.cs.meta b/MovementFactory.cs.meta deleted file mode 100644 index 505110e..0000000 --- a/MovementFactory.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: a549f3c5b33e60042b996e8988c4dfb6 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/SpecialAction/Actions/PlatformerJump.cs b/SpecialAction/Actions/PlatformerJump.cs index 1163420..a1f4346 100644 --- a/SpecialAction/Actions/PlatformerJump.cs +++ b/SpecialAction/Actions/PlatformerJump.cs @@ -1,20 +1,22 @@ -using Syntriax.Modules.Movement.ColliderCheck; +using Syntriax.Modules.Movement.ColliderTrigger; +using Syntriax.Modules.Movement.State; using UnityEngine; namespace Syntriax.Modules.Movement.SpecialAction { [RequireComponent(typeof(Rigidbody2D))] - public class PlatformerJump : MonoBehaviour, ISpecialActionActivate, ISpecialActionDeactivate, IState + public class PlatformerJump : MonoBehaviour, ISpecialActionActivate, ISpecialActionDeactivate { public float JumpSpeed { get; set; } = 0f; - public bool StateEnabled { get; set; } = true; + public IToggleState EnabledToggleState { get; private set; } = null; private bool airSuspension = false; private float fallMultiplier = 0f; private float suspensionMultiplier = 0f; - private IGroundCheck groundCheck = null; + private IGroundTrigger groundCheck = null; private Rigidbody2D rigid = null; + private IToggleState toggleState = null; private void Awake() @@ -22,17 +24,19 @@ namespace Syntriax.Modules.Movement.SpecialAction JumpSpeed = 10f; fallMultiplier = 1.5f * Time.fixedDeltaTime; suspensionMultiplier = 1f * Time.fixedDeltaTime; + EnabledToggleState = new MemberToggleState(); } private void Start() { rigid = GetComponent(); - groundCheck = GetComponentInChildren(); + groundCheck = GetComponentInChildren(); + toggleState = GetComponent(); } private void FixedUpdate() { - if (!StateEnabled) + if (!EnabledToggleState.Toggled) return; if (rigid.velocity.y < 0f) @@ -53,16 +57,22 @@ namespace Syntriax.Modules.Movement.SpecialAction rigid.velocity = velocity; } - public void OnActivation() + public void Activate() { - if (groundCheck.IsCollided()) + if (!toggleState.Toggled) + return; + + if (groundCheck.IsTrigerred) Jump(); airSuspension = true; } - public void OnDeactivation() + public void Deactivate() { + if (!toggleState.Toggled) + return; + airSuspension = false; } } diff --git a/SpecialAction/ISpecialActionActivate.cs b/SpecialAction/ISpecialActionActivate.cs index 1ff33dd..118660f 100644 --- a/SpecialAction/ISpecialActionActivate.cs +++ b/SpecialAction/ISpecialActionActivate.cs @@ -1,7 +1,11 @@ +using Syntriax.Modules.Movement.State; + namespace Syntriax.Modules.Movement.SpecialAction { public interface ISpecialActionActivate { - void OnActivation(); + IToggleState EnabledToggleState { get; } + + void Activate(); } } diff --git a/SpecialAction/ISpecialActionDeactivate.cs b/SpecialAction/ISpecialActionDeactivate.cs index 4c0f383..6e28b0e 100644 --- a/SpecialAction/ISpecialActionDeactivate.cs +++ b/SpecialAction/ISpecialActionDeactivate.cs @@ -1,7 +1,11 @@ +using Syntriax.Modules.Movement.State; + namespace Syntriax.Modules.Movement.SpecialAction { public interface ISpecialActionDeactivate { - void OnDeactivation(); + IToggleState EnabledToggleState { get; } + + void Deactivate(); } } diff --git a/SpecialAction/SpecialActionDeactivateFactory.cs b/SpecialAction/SpecialActionDeactivateFactory.cs deleted file mode 100644 index e5e6edf..0000000 --- a/SpecialAction/SpecialActionDeactivateFactory.cs +++ /dev/null @@ -1,7 +0,0 @@ -namespace Syntriax.Modules.Movement.SpecialAction -{ - public class SpecialActionDeactivateFactory : TypeFactoryBaseMonoBehaviour - { - protected override int InitialCapacity => 8; - } -} diff --git a/SpecialAction/SpecialActionDeactivateFactory.cs.meta b/SpecialAction/SpecialActionDeactivateFactory.cs.meta deleted file mode 100644 index eb1628b..0000000 --- a/SpecialAction/SpecialActionDeactivateFactory.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: f47f89e40f357be429015f81d7e8776d -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/SpecialAction/SpecialActionFactory.cs b/SpecialAction/SpecialActionFactory.cs deleted file mode 100644 index 0572d9d..0000000 --- a/SpecialAction/SpecialActionFactory.cs +++ /dev/null @@ -1,7 +0,0 @@ -namespace Syntriax.Modules.Movement.SpecialAction -{ - public class SpecialActionActivateFactory : TypeFactoryBaseMonoBehaviour - { - protected override int InitialCapacity => 8; - } -} diff --git a/SpecialAction/SpecialActionFactory.cs.meta b/SpecialAction/SpecialActionFactory.cs.meta deleted file mode 100644 index d496937..0000000 --- a/SpecialAction/SpecialActionFactory.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: cb0ba82e296c6144ca97136f508e6aa5 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/SpecialAction/Factories.meta b/State.meta similarity index 77% rename from SpecialAction/Factories.meta rename to State.meta index 1673a31..656a0a7 100644 --- a/SpecialAction/Factories.meta +++ b/State.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: f563d60029ac74b4f960a1fb0f28ac5c +guid: e5f744b49d70a8d418f1bc6fd0c128fa folderAsset: yes DefaultImporter: externalObjects: {} diff --git a/State/IToggleState.cs b/State/IToggleState.cs new file mode 100644 index 0000000..73202fb --- /dev/null +++ b/State/IToggleState.cs @@ -0,0 +1,10 @@ +using UnityEngine.Events; + +namespace Syntriax.Modules.Movement.State +{ + public interface IToggleState + { + bool Toggled { get; set; } + UnityEvent OnToggleStateChanged { get; } + } +} diff --git a/State/IToggleState.cs.meta b/State/IToggleState.cs.meta new file mode 100644 index 0000000..b7b04e6 --- /dev/null +++ b/State/IToggleState.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 174255e0fce0b3a4e8b5e34afa96ffd3 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/State/MemberToggleState.cs b/State/MemberToggleState.cs new file mode 100644 index 0000000..ebbc276 --- /dev/null +++ b/State/MemberToggleState.cs @@ -0,0 +1,25 @@ +using UnityEngine.Events; + +namespace Syntriax.Modules.Movement.State +{ + public class MemberToggleState : IToggleState + { + private bool _enabled = true; + + public bool Toggled + { + get => _enabled; + set + { + bool isNewValue = _enabled != value; + + _enabled = value; + + if (isNewValue) + OnToggleStateChanged.Invoke(value); + } + } + + public UnityEvent OnToggleStateChanged { get; protected set; } = new UnityEvent(); + } +} diff --git a/State/MemberToggleState.cs.meta b/State/MemberToggleState.cs.meta new file mode 100644 index 0000000..6b52b39 --- /dev/null +++ b/State/MemberToggleState.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 7e03986725a3747459e11540e8915a56 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/State/ToggleState.cs b/State/ToggleState.cs new file mode 100644 index 0000000..95ebc0d --- /dev/null +++ b/State/ToggleState.cs @@ -0,0 +1,25 @@ +using UnityEngine; +using UnityEngine.Events; + +namespace Syntriax.Modules.Movement.State +{ + public class ToggleState : MonoBehaviour, IToggleState + { + private bool _enabled = true; + public bool Toggled + { + get => _enabled; + set + { + bool isNewValue = _enabled != value; + + _enabled = value; + + if (isNewValue) + OnToggleStateChanged.Invoke(value); + } + } + + public UnityEvent OnToggleStateChanged { get; protected set; } = new UnityEvent(); + } +} diff --git a/State/ToggleState.cs.meta b/State/ToggleState.cs.meta new file mode 100644 index 0000000..c470298 --- /dev/null +++ b/State/ToggleState.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 7ed1257e4c3c70343bdc02d2e01a95d6 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/TypeFactoryBase.cs b/TypeFactoryBase.cs deleted file mode 100644 index d050d72..0000000 --- a/TypeFactoryBase.cs +++ /dev/null @@ -1,98 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Reflection; -using UnityEngine; - -namespace Syntriax.Modules.Movement -{ - public abstract class TypeFactoryBaseMonoBehaviour : MonoBehaviour - where T : TypeFactoryBaseMonoBehaviour - where T2 : class - { - protected abstract int InitialCapacity { get; } - - private Func predicate => type => type.IsClass && !type.IsAbstract && type.IsSubclassOf(typeof(MonoBehaviour)) && type.GetInterfaces().Contains(typeof(T2)); - private string factoryName => typeof(T).Name; - private static TypeFactoryBaseMonoBehaviour _instance = null; - public static TypeFactoryBaseMonoBehaviour Instance - { - get - { - if (_instance == null) - { - GameObject newGameObject = new GameObject(); - TypeFactoryBaseMonoBehaviour typeFactoryBase = newGameObject.AddComponent(); - newGameObject.name = typeFactoryBase.factoryName; - _instance = typeFactoryBase; - } - - return _instance; - } - } - - private Dictionary _types = null; - public Dictionary Types - { - get - { - Initialize(); - return _types; - } - } - - public void Initialize() - { - if (_types != null) - return; - - _types = new Dictionary(InitialCapacity); - - foreach (Assembly assembly in AppDomain.CurrentDomain.GetAssemblies()) - foreach (Type type in assembly.GetTypes().Where(predicate)) - _types.Add(GetTypeClassName(type), type); - } - - - public virtual void Start() - { - if (_instance != this) - Destroy(this); - } - - public void AddTypes(List<(string ClassName, Type TypeReference)> types) - { - foreach (var pair in types) - AddType(pair.ClassName, pair.TypeReference); - } - - public void AddType(string className, Type type) - { - if (Types.ContainsKey(className)) - throw new ArgumentException($"Component with the key \"{ className }\" already been loaded!"); - - Types.Add(className, type); - } - - public void LoadTypesFromAssembly(Assembly assembly) - { - foreach (Type type in assembly.GetTypes().Where(predicate)) - AddType(GetTypeClassName(type), type); - } - - public T2 AddComponentToGameObject(GameObject gameObject, string className) - { - if (!Types.ContainsKey(className)) - throw new ArgumentException($"Component with the key \"{ className }\" does not exist!"); - - return gameObject.AddComponent(Types[className]) as T2; - } - - public static string GetTypeClassName(Type type) - { - if (string.IsNullOrEmpty(type.Namespace)) - return type.Name; - return $"{ type.Namespace }.{ type.Name }"; - } - } -} diff --git a/TypeFactoryBase.cs.meta b/TypeFactoryBase.cs.meta deleted file mode 100644 index 2250054..0000000 --- a/TypeFactoryBase.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: ede07d45859817e489065dd95be5428a -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/VariableMovement.meta b/VariableMovement.meta deleted file mode 100644 index 9187881..0000000 --- a/VariableMovement.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: f05a188c063295a459be521ca7cb5edb -folderAsset: yes -DefaultImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/VariableMovement/DefaulVariableMovementAsset.cs b/VariableMovement/DefaulVariableMovementAsset.cs deleted file mode 100644 index 1b85213..0000000 --- a/VariableMovement/DefaulVariableMovementAsset.cs +++ /dev/null @@ -1,12 +0,0 @@ -namespace Syntriax.Modules.Movement.VariableMovement -{ - public class DefaulVariableMovementAsset : IVariableMovementAsset - { - public static DefaulVariableMovementAsset _instance = new DefaulVariableMovementAsset(); - public static DefaulVariableMovementAsset Instance => _instance; - - public string MovementName => "Default Movement"; - - public float MovementMultiplier { get; } = 1f; - } -} diff --git a/VariableMovement/DefaulVariableMovementAsset.cs.meta b/VariableMovement/DefaulVariableMovementAsset.cs.meta deleted file mode 100644 index ba10dbd..0000000 --- a/VariableMovement/DefaulVariableMovementAsset.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 51c6b19fd2c0c9f4e9a0b28528c875dd -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/VariableMovement/Factories.meta b/VariableMovement/Factories.meta deleted file mode 100644 index a4d0a3f..0000000 --- a/VariableMovement/Factories.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: bb29c5d8308d0b5469f8761266612fe5 -folderAsset: yes -DefaultImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/VariableMovement/Factories/VariableMovementAssetFactory.cs b/VariableMovement/Factories/VariableMovementAssetFactory.cs deleted file mode 100644 index 1896f29..0000000 --- a/VariableMovement/Factories/VariableMovementAssetFactory.cs +++ /dev/null @@ -1,7 +0,0 @@ -namespace Syntriax.Modules.Movement.VariableMovement -{ - public class VariableMovementAssetFactory : TypeFactoryBaseMonoBehaviour - { - protected override int InitialCapacity => 8; - } -} diff --git a/VariableMovement/Factories/VariableMovementAssetFactory.cs.meta b/VariableMovement/Factories/VariableMovementAssetFactory.cs.meta deleted file mode 100644 index 4df0a5e..0000000 --- a/VariableMovement/Factories/VariableMovementAssetFactory.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: ca4cae9b447933d4380cb3664509b0dd -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/VariableMovement/Factories/VariableMovementCollectionFactory.cs b/VariableMovement/Factories/VariableMovementCollectionFactory.cs deleted file mode 100644 index e394975..0000000 --- a/VariableMovement/Factories/VariableMovementCollectionFactory.cs +++ /dev/null @@ -1,7 +0,0 @@ -namespace Syntriax.Modules.Movement.VariableMovement -{ - public class VariableMovementCollectionFactory : TypeFactoryBaseMonoBehaviour - { - protected override int InitialCapacity => 8; - } -} diff --git a/VariableMovement/Factories/VariableMovementCollectionFactory.cs.meta b/VariableMovement/Factories/VariableMovementCollectionFactory.cs.meta deleted file mode 100644 index 2a9bdba..0000000 --- a/VariableMovement/Factories/VariableMovementCollectionFactory.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: bfc49ded5329db443b2ae57e61ad77a4 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/VariableMovement/Factories/VariableMovementControllerFactory.cs b/VariableMovement/Factories/VariableMovementControllerFactory.cs deleted file mode 100644 index 0ef12e4..0000000 --- a/VariableMovement/Factories/VariableMovementControllerFactory.cs +++ /dev/null @@ -1,7 +0,0 @@ -namespace Syntriax.Modules.Movement.VariableMovement -{ - public class VariableMovementControllerFactory : TypeFactoryBaseMonoBehaviour - { - protected override int InitialCapacity => 8; - } -} diff --git a/VariableMovement/Factories/VariableMovementControllerFactory.cs.meta b/VariableMovement/Factories/VariableMovementControllerFactory.cs.meta deleted file mode 100644 index b13f51b..0000000 --- a/VariableMovement/Factories/VariableMovementControllerFactory.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 0a76af33a21338f49bec92f17a6d6aca -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/VariableMovement/Factories/VariableMovementFactory.cs b/VariableMovement/Factories/VariableMovementFactory.cs deleted file mode 100644 index 6e23d78..0000000 --- a/VariableMovement/Factories/VariableMovementFactory.cs +++ /dev/null @@ -1,7 +0,0 @@ -namespace Syntriax.Modules.Movement.VariableMovement -{ - public class VariableMovementFactory : TypeFactoryBaseMonoBehaviour - { - protected override int InitialCapacity => 8; - } -} diff --git a/VariableMovement/Factories/VariableMovementFactory.cs.meta b/VariableMovement/Factories/VariableMovementFactory.cs.meta deleted file mode 100644 index b5b2734..0000000 --- a/VariableMovement/Factories/VariableMovementFactory.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: c96b25d959676ca4f9246e903fd2a928 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/VariableMovement/IVariableMovement.cs b/VariableMovement/IVariableMovement.cs deleted file mode 100644 index 6552da6..0000000 --- a/VariableMovement/IVariableMovement.cs +++ /dev/null @@ -1,7 +0,0 @@ -namespace Syntriax.Modules.Movement.VariableMovement -{ - public interface IVariableMovement : IState - { - IVariableMovementAsset VariableMovementAsset { get; set; } - } -} diff --git a/VariableMovement/IVariableMovement.cs.meta b/VariableMovement/IVariableMovement.cs.meta deleted file mode 100644 index 6f012be..0000000 --- a/VariableMovement/IVariableMovement.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: f5b11f55ed07dd9428e35c40af90714d -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/VariableMovement/IVariableMovementAsset.cs b/VariableMovement/IVariableMovementAsset.cs deleted file mode 100644 index 6978ad3..0000000 --- a/VariableMovement/IVariableMovementAsset.cs +++ /dev/null @@ -1,8 +0,0 @@ -namespace Syntriax.Modules.Movement.VariableMovement -{ - public interface IVariableMovementAsset - { - string MovementName { get; } - float MovementMultiplier { get; } - } -} diff --git a/VariableMovement/IVariableMovementAsset.cs.meta b/VariableMovement/IVariableMovementAsset.cs.meta deleted file mode 100644 index f8b0f07..0000000 --- a/VariableMovement/IVariableMovementAsset.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 18c50e4da3596b64d9cd3a01ab22a2ca -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/VariableMovement/IVariableMovementCollection.cs b/VariableMovement/IVariableMovementCollection.cs deleted file mode 100644 index 3e13710..0000000 --- a/VariableMovement/IVariableMovementCollection.cs +++ /dev/null @@ -1,10 +0,0 @@ -using System.Collections.Generic; - -namespace Syntriax.Modules.Movement.VariableMovement -{ - public interface IVariableMovementCollection - { - IVariableMovementAsset DefaultVariableMovementsAsset { get; } - List VariableMovementsAssets { get; } - } -} diff --git a/VariableMovement/IVariableMovementCollection.cs.meta b/VariableMovement/IVariableMovementCollection.cs.meta deleted file mode 100644 index 4e45d9a..0000000 --- a/VariableMovement/IVariableMovementCollection.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 47411e74f07b72041a17185dd8483dfc -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/VariableMovement/IVariableMovementController.cs b/VariableMovement/IVariableMovementController.cs deleted file mode 100644 index 139c030..0000000 --- a/VariableMovement/IVariableMovementController.cs +++ /dev/null @@ -1,11 +0,0 @@ -using System.Collections.Generic; - -namespace Syntriax.Modules.Movement.VariableMovement -{ - public interface IVariableMovementController : IState - { - List VariableMovements { get; } - IVariableMovementCollection VariableMovementCollection { get; set; } - IVariableMovement CurrentVariableMovement { get; } - } -} diff --git a/VariableMovement/IVariableMovementController.cs.meta b/VariableMovement/IVariableMovementController.cs.meta deleted file mode 100644 index b3d8544..0000000 --- a/VariableMovement/IVariableMovementController.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: a04461d521f1e754f85154d2548da368 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/VariableMovement/SimpleImplemantation.meta b/VariableMovement/SimpleImplemantation.meta deleted file mode 100644 index 081577f..0000000 --- a/VariableMovement/SimpleImplemantation.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: bc3b3517b04c51746a6f678728212d27 -folderAsset: yes -DefaultImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/VariableMovement/SimpleImplemantation/SimpleVariableMovement.cs b/VariableMovement/SimpleImplemantation/SimpleVariableMovement.cs deleted file mode 100644 index 9555dd1..0000000 --- a/VariableMovement/SimpleImplemantation/SimpleVariableMovement.cs +++ /dev/null @@ -1,23 +0,0 @@ -namespace Syntriax.Modules.Movement.VariableMovement.SimpleImplementation -{ - public class SimpleVariableMovement : IVariableMovement - { - protected IVariableMovementAsset _variableMovementAsset = null; - - public IVariableMovementAsset VariableMovementAsset - { - get => _variableMovementAsset; - set - { - _variableMovementAsset = value; - StateEnabled = false; - } - } - public bool StateEnabled { get; set; } = false; - - public SimpleVariableMovement() { } - - public SimpleVariableMovement(IVariableMovementAsset variableMovementAsset) - => VariableMovementAsset = variableMovementAsset; - } -} diff --git a/VariableMovement/SimpleImplemantation/SimpleVariableMovement.cs.meta b/VariableMovement/SimpleImplemantation/SimpleVariableMovement.cs.meta deleted file mode 100644 index 42f418c..0000000 --- a/VariableMovement/SimpleImplemantation/SimpleVariableMovement.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 05bc4dd9eef91cf4b82018ce47c7b9c9 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/VariableMovement/SimpleImplemantation/SimpleVariableMovementAsset.cs b/VariableMovement/SimpleImplemantation/SimpleVariableMovementAsset.cs deleted file mode 100644 index d84ef74..0000000 --- a/VariableMovement/SimpleImplemantation/SimpleVariableMovementAsset.cs +++ /dev/null @@ -1,13 +0,0 @@ -using UnityEngine; - -namespace Syntriax.Modules.Movement.VariableMovement.SimpleImplementation -{ - [CreateAssetMenu(fileName = "Simple Variable Movement Asset", menuName = "Syntriax/Modules/Movement/VariableMovement/Simple Variable Movement Asset", order = 0)] - public class SimpleVariableMovementAsset : ScriptableObject, IVariableMovementAsset - { - [SerializeField] protected float movementMultiplier = 1f; - - public string MovementName => this.name; - public float MovementMultiplier => movementMultiplier; - } -} diff --git a/VariableMovement/SimpleImplemantation/SimpleVariableMovementAsset.cs.meta b/VariableMovement/SimpleImplemantation/SimpleVariableMovementAsset.cs.meta deleted file mode 100644 index 03f8557..0000000 --- a/VariableMovement/SimpleImplemantation/SimpleVariableMovementAsset.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: f0b94067bad67de4689a6a41749e1b1b -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/VariableMovement/SimpleImplemantation/SimpleVariableMovementCollection.cs b/VariableMovement/SimpleImplemantation/SimpleVariableMovementCollection.cs deleted file mode 100644 index 7abd82e..0000000 --- a/VariableMovement/SimpleImplemantation/SimpleVariableMovementCollection.cs +++ /dev/null @@ -1,15 +0,0 @@ -using System.Collections.Generic; -using UnityEngine; - -namespace Syntriax.Modules.Movement.VariableMovement.SimpleImplementation -{ - [CreateAssetMenu(fileName = "Simple VM Asset Collection", menuName = "Syntriax/Modules/Movement/VariableMovement/Simple VM Asset Collection", order = 0)] - public class SimpleVariableMovementCollection : ScriptableObject, IVariableMovementCollection - { - [SerializeField] protected SimpleVariableMovementAsset defaultVariableMovementsAsset = null; - [SerializeField] protected List variableMovementsAssets = new List(); - - public IVariableMovementAsset DefaultVariableMovementsAsset => defaultVariableMovementsAsset; - public List VariableMovementsAssets => variableMovementsAssets.ConvertAll(simple => (IVariableMovementAsset)simple); - } -} diff --git a/VariableMovement/SimpleImplemantation/SimpleVariableMovementCollection.cs.meta b/VariableMovement/SimpleImplemantation/SimpleVariableMovementCollection.cs.meta deleted file mode 100644 index 836e3df..0000000 --- a/VariableMovement/SimpleImplemantation/SimpleVariableMovementCollection.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 5cee6b82ee9d68c4eb38ce2e693515d4 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/VariableMovement/SimpleImplemantation/SimpleVariableMovementController.cs b/VariableMovement/SimpleImplemantation/SimpleVariableMovementController.cs deleted file mode 100644 index bb5ea85..0000000 --- a/VariableMovement/SimpleImplemantation/SimpleVariableMovementController.cs +++ /dev/null @@ -1,50 +0,0 @@ -using System.Collections.Generic; -using UnityEngine; - -namespace Syntriax.Modules.Movement.VariableMovement.SimpleImplementation -{ - public class SimpleVariableMovementController : MonoBehaviour, IVariableMovementController - { - protected IVariableMovement _defaultVariableMovement = new SimpleVariableMovement(); - protected IVariableMovementCollection _variableMovementCollection = null; - - public bool StateEnabled { get; set; } = false; - - public List VariableMovements { get; protected set; } = new List(); - - public IVariableMovementCollection VariableMovementCollection - { - get => _variableMovementCollection; - set - { - _variableMovementCollection = value; - - VariableMovements.Clear(); - - _defaultVariableMovement.VariableMovementAsset = value.DefaultVariableMovementsAsset; - _defaultVariableMovement.StateEnabled = true; - - if (VariableMovements.Capacity < value.VariableMovementsAssets.Count) - VariableMovements.Capacity = value.VariableMovementsAssets.Count; - - foreach (var asset in value.VariableMovementsAssets) - VariableMovements.Add(new SimpleVariableMovement(asset)); - } - } - - public IVariableMovement CurrentVariableMovement - { - get - { - if (!StateEnabled) - return _defaultVariableMovement; - - foreach (IVariableMovement variableMovement in VariableMovements) - if (variableMovement.StateEnabled) - return variableMovement; - - return _defaultVariableMovement; - } - } - } -} diff --git a/VariableMovement/SimpleImplemantation/SimpleVariableMovementController.cs.meta b/VariableMovement/SimpleImplemantation/SimpleVariableMovementController.cs.meta deleted file mode 100644 index 449e76d..0000000 --- a/VariableMovement/SimpleImplemantation/SimpleVariableMovementController.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 580058b11e72667419d381dbffba60e8 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/VariableMovement/VariableMovementBehaviourApplier.cs b/VariableMovement/VariableMovementBehaviourApplier.cs deleted file mode 100644 index 714503f..0000000 --- a/VariableMovement/VariableMovementBehaviourApplier.cs +++ /dev/null @@ -1,24 +0,0 @@ -using System.Collections.Generic; -using System.Linq; -using UnityEngine; - -namespace Syntriax.Modules.Movement.VariableMovement -{ - public class VariableMovementBehaviourApplier : MonoBehaviour - { - private List movements = new List(); - private IVariableMovementController variableMovementController = null; - - private void Start() - { - movements = GetComponents().ToList(); - variableMovementController = GetComponent(); - } - - private void Update() - { - foreach (var movement in movements) - movement.MovementMultiplier = variableMovementController.CurrentVariableMovement.VariableMovementAsset.MovementMultiplier; - } - } -} diff --git a/VariableMovement/VariableMovementBehaviourApplier.cs.meta b/VariableMovement/VariableMovementBehaviourApplier.cs.meta deleted file mode 100644 index 91f4d26..0000000 --- a/VariableMovement/VariableMovementBehaviourApplier.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 47f9c34946b1c4a4d9b31dc2f1a6e315 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: