Folder/Namespace Structure Improvements

This commit is contained in:
Syntriax 2022-11-13 17:43:30 +03:00
parent 713fb0188d
commit b93c966218
16 changed files with 126 additions and 4 deletions

8
Implementations.meta Normal file
View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 15528ebd51d27d54398c55826710f23e
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,40 @@
using Syntriax.Modules.Movement.ColliderTrigger;
using UnityEngine;
namespace Syntriax.Modules.Movement.Implementations.TwoDimensional
{
public class OneDirectional2DAirMovement : OneDirectional2DMovementBase
{
protected override float moveValue { get; set; } = 0f;
protected IGroundTrigger groundTrigger = null;
protected override void Start()
{
base.Start();
groundTrigger = GetComponentInChildren<IGroundTrigger>();
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;
}
protected override void OnDeactivated() { }
protected override void OnActivated() { }
}
}

View File

@ -0,0 +1,31 @@
using Syntriax.Modules.Movement.ColliderTrigger;
using UnityEngine;
namespace Syntriax.Modules.Movement.Implementations.TwoDimensional
{
public class OneDirectional2DGroundMovement : OneDirectional2DMovementBase
{
protected override float moveValue { get; set; } = 0f;
protected IGroundTrigger groundTrigger = null;
protected override void Start()
{
base.Start();
groundTrigger = GetComponentInChildren<IGroundTrigger>();
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;
}
protected override void OnDeactivated() { }
protected override void OnActivated() { }
}
}

View File

@ -0,0 +1,10 @@
namespace Syntriax.Modules.Movement.Implementations.TwoDimensional
{
public abstract class OneDirectional2DMovementBase : TwoDimensionalMovementBase
{
protected abstract float moveValue { get; set; }
public override void Move(float x = 0, float y = 0, float z = 0)
=> moveValue = x * BaseSpeed * MovementMultiplier;
}
}

View File

@ -1,7 +1,7 @@
using Syntriax.Modules.Movement.ColliderTrigger;
using UnityEngine;
namespace Syntriax.Modules.Movement.TwoDimensionalImplementations
namespace Syntriax.Modules.Movement.Implementations.TwoDimensional
{
public class OneWay2DAirMovement : OneWay2DMovementBase
{

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: ccd6df43b281de34fb8ea893de8ec4c6
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -1,7 +1,7 @@
using Syntriax.Modules.Movement.ColliderTrigger;
using UnityEngine;
namespace Syntriax.Modules.Movement.TwoDimensionalImplementations
namespace Syntriax.Modules.Movement.Implementations.TwoDimensional
{
public class OneWay2DGroundMovement : OneWay2DMovementBase
{

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: f7b798018f7cc444c92f7f17b0501bc7
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -1,4 +1,4 @@
namespace Syntriax.Modules.Movement.TwoDimensionalImplementations
namespace Syntriax.Modules.Movement.Implementations.TwoDimensional
{
public abstract class OneWay2DMovementBase : TwoDimensionalMovementBase
{

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 842775d6c36b58f40a18f3d930e04173
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -2,7 +2,7 @@ using Syntriax.Modules.Movement.State;
using UnityEngine;
using UnityEngine.Events;
namespace Syntriax.Modules.Movement.TwoDimensionalImplementations
namespace Syntriax.Modules.Movement.Implementations.TwoDimensional
{
[RequireComponent(typeof(Rigidbody2D))]
public abstract class TwoDimensionalMovementBase : MonoBehaviour, IMovement