Variable MovementCollections Added
This commit is contained in:
parent
ccd9fdc435
commit
c7418eb578
|
@ -2,6 +2,9 @@ namespace Syntriax.Modules.Movement.VariableMovement
|
||||||
{
|
{
|
||||||
public class DefaulVariableMovementAsset : IVariableMovementAsset
|
public class DefaulVariableMovementAsset : IVariableMovementAsset
|
||||||
{
|
{
|
||||||
|
public static DefaulVariableMovementAsset _instance = new DefaulVariableMovementAsset();
|
||||||
|
public static DefaulVariableMovementAsset Instance => _instance;
|
||||||
|
|
||||||
public string MovementName => "Default Movement";
|
public string MovementName => "Default Movement";
|
||||||
|
|
||||||
public float MovementMultiplier { get; } = 1f;
|
public float MovementMultiplier { get; } = 1f;
|
||||||
|
|
|
@ -2,6 +2,6 @@ namespace Syntriax.Modules.Movement.VariableMovement
|
||||||
{
|
{
|
||||||
public interface IVariableMovement : IState
|
public interface IVariableMovement : IState
|
||||||
{
|
{
|
||||||
IVariableMovementAsset VariableMovementAsset { get; }
|
IVariableMovementAsset VariableMovementAsset { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,10 @@
|
||||||
|
using System.Collections.Generic;
|
||||||
|
|
||||||
|
namespace Syntriax.Modules.Movement.VariableMovement
|
||||||
|
{
|
||||||
|
public interface IVariableMovementCollection
|
||||||
|
{
|
||||||
|
IVariableMovementAsset DefaultVariableMovementsAsset { get; }
|
||||||
|
List<IVariableMovementAsset> VariableMovementsAssets { get; }
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,11 @@
|
||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 47411e74f07b72041a17185dd8483dfc
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
|
@ -5,6 +5,7 @@ namespace Syntriax.Modules.Movement.VariableMovement
|
||||||
public interface IVariableMovementController : IState
|
public interface IVariableMovementController : IState
|
||||||
{
|
{
|
||||||
List<IVariableMovement> VariableMovements { get; }
|
List<IVariableMovement> VariableMovements { get; }
|
||||||
|
IVariableMovementCollection VariableMovementCollection { get; set; }
|
||||||
IVariableMovement CurrentVariableMovement { get; }
|
IVariableMovement CurrentVariableMovement { get; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,9 +2,21 @@ namespace Syntriax.Modules.Movement.VariableMovement.SimpleImplementation
|
||||||
{
|
{
|
||||||
public class SimpleVariableMovement : IVariableMovement
|
public class SimpleVariableMovement : IVariableMovement
|
||||||
{
|
{
|
||||||
public IVariableMovementAsset VariableMovementAsset { get; protected set; } = null;
|
protected IVariableMovementAsset _variableMovementAsset = null;
|
||||||
|
|
||||||
|
public IVariableMovementAsset VariableMovementAsset
|
||||||
|
{
|
||||||
|
get => _variableMovementAsset;
|
||||||
|
set
|
||||||
|
{
|
||||||
|
_variableMovementAsset = value;
|
||||||
|
StateEnabled = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
public bool StateEnabled { get; set; } = false;
|
public bool StateEnabled { get; set; } = false;
|
||||||
|
|
||||||
|
public SimpleVariableMovement() { }
|
||||||
|
|
||||||
public SimpleVariableMovement(IVariableMovementAsset variableMovementAsset)
|
public SimpleVariableMovement(IVariableMovementAsset variableMovementAsset)
|
||||||
=> VariableMovementAsset = variableMovementAsset;
|
=> VariableMovementAsset = variableMovementAsset;
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,15 @@
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using UnityEngine;
|
||||||
|
|
||||||
|
namespace Syntriax.Modules.Movement.VariableMovement.SimpleImplementation
|
||||||
|
{
|
||||||
|
[CreateAssetMenu(fileName = "Simple VM Asset Collection", menuName = "Syntriax/Modules/Movement/VariableMovement/Simple VM Asset Collection", order = 0)]
|
||||||
|
public class SimpleVariableMovementCollection : ScriptableObject, IVariableMovementCollection
|
||||||
|
{
|
||||||
|
[SerializeField] protected SimpleVariableMovementAsset defaultVariableMovementsAsset = null;
|
||||||
|
[SerializeField] protected List<SimpleVariableMovementAsset> variableMovementsAssets = new List<SimpleVariableMovementAsset>();
|
||||||
|
|
||||||
|
public IVariableMovementAsset DefaultVariableMovementsAsset => defaultVariableMovementsAsset;
|
||||||
|
public List<IVariableMovementAsset> VariableMovementsAssets => variableMovementsAssets.ConvertAll<IVariableMovementAsset>(simple => (IVariableMovementAsset)simple);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,11 @@
|
||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 5cee6b82ee9d68c4eb38ce2e693515d4
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
|
@ -5,23 +5,45 @@ namespace Syntriax.Modules.Movement.VariableMovement.SimpleImplementation
|
||||||
{
|
{
|
||||||
public class SimpleVariableMovementController : MonoBehaviour, IVariableMovementController
|
public class SimpleVariableMovementController : MonoBehaviour, IVariableMovementController
|
||||||
{
|
{
|
||||||
private static IVariableMovement DefaultVariableMovement = new SimpleVariableMovement(new DefaulVariableMovementAsset());
|
protected IVariableMovement _defaultVariableMovement = new SimpleVariableMovement();
|
||||||
|
protected IVariableMovementCollection _variableMovementCollection = null;
|
||||||
|
|
||||||
public bool StateEnabled { get; set; } = false;
|
public bool StateEnabled { get; set; } = false;
|
||||||
|
|
||||||
public List<IVariableMovement> VariableMovements { get; protected set; } = new List<IVariableMovement>();
|
public List<IVariableMovement> VariableMovements { get; protected set; } = new List<IVariableMovement>();
|
||||||
|
|
||||||
|
public IVariableMovementCollection VariableMovementCollection
|
||||||
|
{
|
||||||
|
get => _variableMovementCollection;
|
||||||
|
set
|
||||||
|
{
|
||||||
|
_variableMovementCollection = value;
|
||||||
|
|
||||||
|
VariableMovements.Clear();
|
||||||
|
|
||||||
|
_defaultVariableMovement.VariableMovementAsset = value.DefaultVariableMovementsAsset;
|
||||||
|
_defaultVariableMovement.StateEnabled = true;
|
||||||
|
|
||||||
|
if (VariableMovements.Capacity < value.VariableMovementsAssets.Count)
|
||||||
|
VariableMovements.Capacity = value.VariableMovementsAssets.Count;
|
||||||
|
|
||||||
|
foreach (var asset in value.VariableMovementsAssets)
|
||||||
|
VariableMovements.Add(new SimpleVariableMovement(asset));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public IVariableMovement CurrentVariableMovement
|
public IVariableMovement CurrentVariableMovement
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
if (!StateEnabled)
|
if (!StateEnabled)
|
||||||
return DefaultVariableMovement;
|
return _defaultVariableMovement;
|
||||||
|
|
||||||
foreach (IVariableMovement variableMovement in VariableMovements)
|
foreach (IVariableMovement variableMovement in VariableMovements)
|
||||||
if (variableMovement.StateEnabled)
|
if (variableMovement.StateEnabled)
|
||||||
return variableMovement;
|
return variableMovement;
|
||||||
|
|
||||||
return DefaultVariableMovement;
|
return _defaultVariableMovement;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue