Removed Special Action Temporarily

This commit is contained in:
Syntriax 2022-11-14 12:39:51 +03:00
parent 4e9fe6cbfb
commit a2d64a2eef
8 changed files with 0 additions and 158 deletions

View File

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

View File

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

View File

@ -1,87 +0,0 @@
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
{
public float JumpSpeed { get; set; } = 0f;
public IToggleState EnabledToggleState { get; protected set; } = null;
public float FallThreshold { get; set; } = 0f;
private float fallMultiplier = 0f;
public float FallMultiplier
{
get => fallMultiplier;
set => fallMultiplier = value * Time.fixedDeltaTime;
}
private float suspensionMultiplier = 0f;
public float SuspensionMultiplier
{
get => suspensionMultiplier;
set => suspensionMultiplier = value * Time.fixedDeltaTime;
}
protected bool airSuspension = false;
protected IGroundTrigger groundCheck = null;
protected Rigidbody2D rigid = null;
protected IToggleState toggleState = null;
protected virtual void Awake()
{
JumpSpeed = 10f;
FallMultiplier = 1.5f;
SuspensionMultiplier = 1f;
EnabledToggleState = new MemberToggleState();
}
protected virtual void Start()
{
rigid = GetComponent<Rigidbody2D>();
groundCheck = GetComponentInChildren<IGroundTrigger>();
toggleState = GetComponent<IToggleState>();
}
protected virtual void FixedUpdate()
{
if (!EnabledToggleState.Toggled)
return;
if (rigid.velocity.y < FallThreshold)
ApplySuspension(SuspensionMultiplier);
else if (!airSuspension)
ApplySuspension(FallMultiplier);
}
protected virtual void ApplySuspension(float multiplier)
=> rigid.velocity += Physics2D.gravity * multiplier;
protected virtual void Jump()
{
Vector2 velocity = rigid.velocity;
velocity.y = JumpSpeed;
rigid.velocity = velocity;
}
public virtual void Activate()
{
if (!toggleState.Toggled)
return;
if (groundCheck.IsTrigerred)
Jump();
airSuspension = true;
}
public virtual void Deactivate()
{
if (!toggleState.Toggled)
return;
airSuspension = false;
}
}
}

View File

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

View File

@ -1,11 +0,0 @@
using Syntriax.Modules.Movement.State;
namespace Syntriax.Modules.Movement.SpecialAction
{
public interface ISpecialActionActivate
{
IToggleState EnabledToggleState { get; }
void Activate();
}
}

View File

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

View File

@ -1,11 +0,0 @@
using Syntriax.Modules.Movement.State;
namespace Syntriax.Modules.Movement.SpecialAction
{
public interface ISpecialActionDeactivate
{
IToggleState EnabledToggleState { get; }
void Deactivate();
}
}

View File

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