Moved few Implemantations to Samples Folder
This commit is contained in:
49
Samples/AirMovement1D.cs
Normal file
49
Samples/AirMovement1D.cs
Normal file
@@ -0,0 +1,49 @@
|
||||
using Syntriax.Modules.Trigger;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Syntriax.Modules.Movement.Samples
|
||||
{
|
||||
[RequireComponent(typeof(Rigidbody2D))]
|
||||
public class AirMovement1D : MovementBase1D
|
||||
{
|
||||
protected override float moveValue { get; set; } = 0f;
|
||||
protected IGroundTrigger groundTrigger = null;
|
||||
protected Rigidbody2D rigid = null;
|
||||
|
||||
protected override void Start()
|
||||
{
|
||||
base.Start();
|
||||
|
||||
rigid = GetComponent<Rigidbody2D>();
|
||||
groundTrigger = GetComponentInChildren<IGroundTrigger>();
|
||||
|
||||
if (groundTrigger != null)
|
||||
{
|
||||
groundTrigger.OnTriggerStateChanged += OnGroundTrigger;
|
||||
CanTakeOver = false;
|
||||
}
|
||||
}
|
||||
|
||||
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() { }
|
||||
}
|
||||
}
|
11
Samples/AirMovement1D.cs.meta
Normal file
11
Samples/AirMovement1D.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 69ca5998eb951b64499b111100275018
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
42
Samples/GroundMovement1D.cs
Normal file
42
Samples/GroundMovement1D.cs
Normal file
@@ -0,0 +1,42 @@
|
||||
using Syntriax.Modules.Trigger;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Syntriax.Modules.Movement.Samples
|
||||
{
|
||||
[RequireComponent(typeof(Rigidbody2D))]
|
||||
public class GroundMovement1D : MovementBase1D
|
||||
{
|
||||
protected override float moveValue { get; set; } = 0f;
|
||||
protected IGroundTrigger groundTrigger = null;
|
||||
protected Rigidbody2D rigid = null;
|
||||
|
||||
private void Awake() => CanTakeOver = true;
|
||||
|
||||
protected override void Start()
|
||||
{
|
||||
base.Start();
|
||||
|
||||
rigid = GetComponent<Rigidbody2D>();
|
||||
groundTrigger = GetComponentInChildren<IGroundTrigger>();
|
||||
|
||||
if (groundTrigger != null)
|
||||
{
|
||||
groundTrigger.OnTriggerStateChanged += OnGroundTrigger;
|
||||
CanTakeOver = false;
|
||||
}
|
||||
}
|
||||
|
||||
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() { }
|
||||
}
|
||||
}
|
11
Samples/GroundMovement1D.cs.meta
Normal file
11
Samples/GroundMovement1D.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 10b59caf08f3e2d4b94eb72b7885346d
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
19
Samples/Syntriax.Modules.Movement.Samples.asmdef
Normal file
19
Samples/Syntriax.Modules.Movement.Samples.asmdef
Normal file
@@ -0,0 +1,19 @@
|
||||
{
|
||||
"name": "Syntriax.Modules.Movement.Samples",
|
||||
"rootNamespace": "",
|
||||
"references": [
|
||||
"GUID:efa9a9bc94c60c74684aafb7428fbf61",
|
||||
"GUID:1f5f15fe7e49bdb48a76c5ce9b1c9f2f",
|
||||
"GUID:d4c952ed5f59c5a449cda1b0080ed841",
|
||||
"GUID:c967acc4be781ca44b42a1887eb1ac7a"
|
||||
],
|
||||
"includePlatforms": [],
|
||||
"excludePlatforms": [],
|
||||
"allowUnsafeCode": false,
|
||||
"overrideReferences": false,
|
||||
"precompiledReferences": [],
|
||||
"autoReferenced": true,
|
||||
"defineConstraints": [],
|
||||
"versionDefines": [],
|
||||
"noEngineReferences": false
|
||||
}
|
7
Samples/Syntriax.Modules.Movement.Samples.asmdef.meta
Normal file
7
Samples/Syntriax.Modules.Movement.Samples.asmdef.meta
Normal file
@@ -0,0 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 863b8995abde2cf40b8b4cb709452a32
|
||||
AssemblyDefinitionImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
Reference in New Issue
Block a user