Moved few Implemantations to Samples Folder

This commit is contained in:
2022-12-17 12:04:14 +03:00
parent e95462af00
commit c244ddeb98
13 changed files with 41 additions and 11 deletions

49
Samples/AirMovement1D.cs Normal file
View 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() { }
}
}

View File

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

View 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() { }
}
}

View File

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

View 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
}

View File

@@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 863b8995abde2cf40b8b4cb709452a32
AssemblyDefinitionImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant: