Rewrite
- Movement & Controller - Special Actions - ToggleState - ColliderChecker - and 2D Implementations
This commit is contained in:
@@ -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<Rigidbody2D>();
|
||||
groundCheck = GetComponentInChildren<IGroundCheck>();
|
||||
groundCheck = GetComponentInChildren<IGroundTrigger>();
|
||||
toggleState = GetComponent<IToggleState>();
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
@@ -1,8 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: f563d60029ac74b4f960a1fb0f28ac5c
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@@ -1,7 +1,11 @@
|
||||
using Syntriax.Modules.Movement.State;
|
||||
|
||||
namespace Syntriax.Modules.Movement.SpecialAction
|
||||
{
|
||||
public interface ISpecialActionActivate
|
||||
{
|
||||
void OnActivation();
|
||||
IToggleState EnabledToggleState { get; }
|
||||
|
||||
void Activate();
|
||||
}
|
||||
}
|
||||
|
@@ -1,7 +1,11 @@
|
||||
using Syntriax.Modules.Movement.State;
|
||||
|
||||
namespace Syntriax.Modules.Movement.SpecialAction
|
||||
{
|
||||
public interface ISpecialActionDeactivate
|
||||
{
|
||||
void OnDeactivation();
|
||||
IToggleState EnabledToggleState { get; }
|
||||
|
||||
void Deactivate();
|
||||
}
|
||||
}
|
||||
|
@@ -1,7 +0,0 @@
|
||||
namespace Syntriax.Modules.Movement.SpecialAction
|
||||
{
|
||||
public class SpecialActionDeactivateFactory : TypeFactoryBaseMonoBehaviour<SpecialActionDeactivateFactory, ISpecialActionDeactivate>
|
||||
{
|
||||
protected override int InitialCapacity => 8;
|
||||
}
|
||||
}
|
@@ -1,11 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: f47f89e40f357be429015f81d7e8776d
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@@ -1,7 +0,0 @@
|
||||
namespace Syntriax.Modules.Movement.SpecialAction
|
||||
{
|
||||
public class SpecialActionActivateFactory : TypeFactoryBaseMonoBehaviour<SpecialActionActivateFactory, ISpecialActionActivate>
|
||||
{
|
||||
protected override int InitialCapacity => 8;
|
||||
}
|
||||
}
|
@@ -1,11 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: cb0ba82e296c6144ca97136f508e6aa5
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
Reference in New Issue
Block a user