Added New Bases and removed Air and Ground Movement Implementations Temporarily
This commit is contained in:
@@ -1,8 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 247a7892cc48fa54c971733d8e0213db
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@@ -1,40 +0,0 @@
|
||||
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 += 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() { }
|
||||
}
|
||||
}
|
@@ -1,11 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 2f38efc38cadfd94ba8698189577f60f
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@@ -1,31 +0,0 @@
|
||||
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 += 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() { }
|
||||
}
|
||||
}
|
@@ -1,11 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 9c73429b47407634daead7ee1b52629d
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@@ -1,10 +0,0 @@
|
||||
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;
|
||||
}
|
||||
}
|
@@ -1,11 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 51ee606e68723324b92b9d16835c1625
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@@ -1,64 +0,0 @@
|
||||
using System;
|
||||
using Syntriax.Modules.Movement.State;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Syntriax.Modules.Movement.Implementations.TwoDimensional
|
||||
{
|
||||
[RequireComponent(typeof(Rigidbody2D))]
|
||||
public abstract class TwoDimensionalMovementBase : MonoBehaviour, IMovement
|
||||
{
|
||||
protected Rigidbody2D rigid = null;
|
||||
protected IToggleState toggleState = null;
|
||||
protected IMovementController movementController = null;
|
||||
private bool _canTakeOver = false;
|
||||
|
||||
public float BaseSpeed { get; set; } = 1f;
|
||||
public float MovementMultiplier { get; set; } = 1f;
|
||||
|
||||
public Action<bool> OnTakeOverStateChanged { get; 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 Start()
|
||||
{
|
||||
rigid = GetComponent<Rigidbody2D>();
|
||||
toggleState = GetComponent<ToggleState>();
|
||||
movementController = GetComponent<IMovementController>();
|
||||
|
||||
movementController.OnMovementActivated += OnActivated;
|
||||
movementController.OnMovementDeactivated += OnDeactivated;
|
||||
}
|
||||
|
||||
protected abstract void OnDeactivated();
|
||||
private void OnDeactivated(IMovement movement)
|
||||
{
|
||||
if ((object)movement != this)
|
||||
return;
|
||||
OnDeactivated();
|
||||
}
|
||||
|
||||
protected abstract void OnActivated();
|
||||
private void OnActivated(IMovement movement)
|
||||
{
|
||||
if ((object)movement != this)
|
||||
return;
|
||||
OnActivated();
|
||||
}
|
||||
|
||||
public abstract void Move(float x = 0, float y = 0, float z = 0);
|
||||
public abstract void ApplyMovement();
|
||||
}
|
||||
}
|
@@ -1,11 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: b4a8f74afcbe280448862bac89545353
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
Reference in New Issue
Block a user