浏览代码
Removed serializable actions/conditions. Added current state name in state machine component. Added more spheres to test scene.
/main
Removed serializable actions/conditions. Added current state name in state machine component. Added more spheres to test scene.
/main
DeivSky
4 年前
当前提交
32a19461
共有 15 个文件被更改,包括 573 次插入 和 155 次删除
-
488UOP1_Project/Assets/Scenes/StateMachines.unity
-
3UOP1_Project/Assets/ScriptableObjects/StateMachinesTest/Actions/Eat.asset
-
3UOP1_Project/Assets/ScriptableObjects/StateMachinesTest/Conditions/AttackDuration.asset
-
3UOP1_Project/Assets/ScriptableObjects/StateMachinesTest/Conditions/EatDuration.asset
-
5UOP1_Project/Assets/Scripts/StateMachine/Core/StateMachine.cs
-
6UOP1_Project/Assets/Scripts/StateMachine/Scriptables/ScriptableStateAction.cs
-
6UOP1_Project/Assets/Scripts/StateMachine/Scriptables/ScriptableStateCondition.cs
-
17UOP1_Project/Assets/Scripts/StateMachineTest/ScriptableEatAction.cs
-
15UOP1_Project/Assets/Scripts/StateMachineTest/ScriptableTimedCondition.cs
-
129UOP1_Project/Assets/Prefabs/Sphere.prefab
-
7UOP1_Project/Assets/Prefabs/Sphere.prefab.meta
-
15UOP1_Project/Assets/ScriptableObjects/StateMachinesTest/Conditions/AttackDurationOverride.asset
-
8UOP1_Project/Assets/ScriptableObjects/StateMachinesTest/Conditions/AttackDurationOverride.asset.meta
-
15UOP1_Project/Assets/ScriptableObjects/StateMachinesTest/Conditions/EatDurationOverride.asset
-
8UOP1_Project/Assets/ScriptableObjects/StateMachinesTest/Conditions/EatDurationOverride.asset.meta
|
|||
using System; |
|||
using DeivSky.StateMachine; |
|||
using DeivSky.StateMachine; |
|||
public class ScriptableEatAction : SerializableStateAction<EatAction> { } |
|||
public class ScriptableEatAction : ScriptableStateAction |
|||
{ |
|||
public float amount = 10f; |
|||
|
|||
protected override StateAction CreateAction() => new EatAction(amount); |
|||
} |
|||
[Serializable] |
|||
[SerializeField] private float amount = 10f; |
|||
private float _amount = 10f; |
|||
public EatAction(float amount) => _amount = amount; |
|||
|
|||
public override void OnStateExit() => _hungerComponent.Eat(amount); |
|||
public override void OnStateExit() => _hungerComponent.Eat(_amount); |
|||
} |
|
|||
using System; |
|||
using DeivSky.StateMachine; |
|||
using DeivSky.StateMachine; |
|||
public class ScriptableTimedCondition : SerializableStateCondition<TimedCondition> { } |
|||
public class ScriptableTimedCondition : ScriptableStateCondition |
|||
{ |
|||
public float Duration = 10f; |
|||
|
|||
protected override Condition CreateCondition() => new TimedCondition(Duration); |
|||
} |
|||
[Serializable] |
|||
[SerializeField] private float _duration = 10f; |
|||
private float _duration = 10f; |
|||
|
|||
public TimedCondition(float duration) => _duration = duration; |
|||
|
|||
public override void OnStateEnter() => _time = Time.time + _duration; |
|||
|
|
|||
%YAML 1.1 |
|||
%TAG !u! tag:unity3d.com,2011: |
|||
--- !u!1 &8065985805251957531 |
|||
GameObject: |
|||
m_ObjectHideFlags: 0 |
|||
m_CorrespondingSourceObject: {fileID: 0} |
|||
m_PrefabInstance: {fileID: 0} |
|||
m_PrefabAsset: {fileID: 0} |
|||
serializedVersion: 6 |
|||
m_Component: |
|||
- component: {fileID: 8065985805251957521} |
|||
- component: {fileID: 8065985805251957526} |
|||
- component: {fileID: 8065985805251957527} |
|||
- component: {fileID: 8065985805251957524} |
|||
- component: {fileID: 8065985805251957525} |
|||
- component: {fileID: 8065985805251957530} |
|||
m_Layer: 0 |
|||
m_Name: Sphere |
|||
m_TagString: Untagged |
|||
m_Icon: {fileID: 0} |
|||
m_NavMeshLayer: 0 |
|||
m_StaticEditorFlags: 0 |
|||
m_IsActive: 1 |
|||
--- !u!4 &8065985805251957521 |
|||
Transform: |
|||
m_ObjectHideFlags: 0 |
|||
m_CorrespondingSourceObject: {fileID: 0} |
|||
m_PrefabInstance: {fileID: 0} |
|||
m_PrefabAsset: {fileID: 0} |
|||
m_GameObject: {fileID: 8065985805251957531} |
|||
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} |
|||
m_LocalPosition: {x: 9.62, y: 0.73, z: -15.743169} |
|||
m_LocalScale: {x: 1, y: 1, z: 1} |
|||
m_Children: [] |
|||
m_Father: {fileID: 0} |
|||
m_RootOrder: 0 |
|||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} |
|||
--- !u!33 &8065985805251957526 |
|||
MeshFilter: |
|||
m_ObjectHideFlags: 0 |
|||
m_CorrespondingSourceObject: {fileID: 0} |
|||
m_PrefabInstance: {fileID: 0} |
|||
m_PrefabAsset: {fileID: 0} |
|||
m_GameObject: {fileID: 8065985805251957531} |
|||
m_Mesh: {fileID: 10207, guid: 0000000000000000e000000000000000, type: 0} |
|||
--- !u!23 &8065985805251957527 |
|||
MeshRenderer: |
|||
m_ObjectHideFlags: 0 |
|||
m_CorrespondingSourceObject: {fileID: 0} |
|||
m_PrefabInstance: {fileID: 0} |
|||
m_PrefabAsset: {fileID: 0} |
|||
m_GameObject: {fileID: 8065985805251957531} |
|||
m_Enabled: 1 |
|||
m_CastShadows: 1 |
|||
m_ReceiveShadows: 1 |
|||
m_DynamicOccludee: 1 |
|||
m_MotionVectors: 1 |
|||
m_LightProbeUsage: 1 |
|||
m_ReflectionProbeUsage: 1 |
|||
m_RayTracingMode: 2 |
|||
m_RenderingLayerMask: 1 |
|||
m_RendererPriority: 0 |
|||
m_Materials: |
|||
- {fileID: 2100000, guid: 31321ba15b8f8eb4c954353edc038b1d, type: 2} |
|||
m_StaticBatchInfo: |
|||
firstSubMesh: 0 |
|||
subMeshCount: 0 |
|||
m_StaticBatchRoot: {fileID: 0} |
|||
m_ProbeAnchor: {fileID: 0} |
|||
m_LightProbeVolumeOverride: {fileID: 0} |
|||
m_ScaleInLightmap: 1 |
|||
m_ReceiveGI: 1 |
|||
m_PreserveUVs: 0 |
|||
m_IgnoreNormalsForChartDetection: 0 |
|||
m_ImportantGI: 0 |
|||
m_StitchLightmapSeams: 1 |
|||
m_SelectedEditorRenderState: 3 |
|||
m_MinimumChartSize: 4 |
|||
m_AutoUVMaxDistance: 0.5 |
|||
m_AutoUVMaxAngle: 89 |
|||
m_LightmapParameters: {fileID: 0} |
|||
m_SortingLayerID: 0 |
|||
m_SortingLayer: 0 |
|||
m_SortingOrder: 0 |
|||
--- !u!135 &8065985805251957524 |
|||
SphereCollider: |
|||
m_ObjectHideFlags: 0 |
|||
m_CorrespondingSourceObject: {fileID: 0} |
|||
m_PrefabInstance: {fileID: 0} |
|||
m_PrefabAsset: {fileID: 0} |
|||
m_GameObject: {fileID: 8065985805251957531} |
|||
m_Material: {fileID: 0} |
|||
m_IsTrigger: 0 |
|||
m_Enabled: 1 |
|||
serializedVersion: 2 |
|||
m_Radius: 0.5 |
|||
m_Center: {x: 0, y: 0, z: 0} |
|||
--- !u!114 &8065985805251957525 |
|||
MonoBehaviour: |
|||
m_ObjectHideFlags: 0 |
|||
m_CorrespondingSourceObject: {fileID: 0} |
|||
m_PrefabInstance: {fileID: 0} |
|||
m_PrefabAsset: {fileID: 0} |
|||
m_GameObject: {fileID: 8065985805251957531} |
|||
m_Enabled: 1 |
|||
m_EditorHideFlags: 0 |
|||
m_Script: {fileID: 11500000, guid: 42ecc2ef8dcbbe4449a3f1d0bb1d04b2, type: 3} |
|||
m_Name: |
|||
m_EditorClassIdentifier: |
|||
_maxFullness: 100 |
|||
_hungerPerSecond: 10 |
|||
_isHungryThreshold: 0.4 |
|||
_currentFullness: 0 |
|||
--- !u!114 &8065985805251957530 |
|||
MonoBehaviour: |
|||
m_ObjectHideFlags: 0 |
|||
m_CorrespondingSourceObject: {fileID: 0} |
|||
m_PrefabInstance: {fileID: 0} |
|||
m_PrefabAsset: {fileID: 0} |
|||
m_GameObject: {fileID: 8065985805251957531} |
|||
m_Enabled: 1 |
|||
m_EditorHideFlags: 0 |
|||
m_Script: {fileID: 11500000, guid: 1eeda163c70b3cb4ebb88ba92f608fd8, type: 3} |
|||
m_Name: |
|||
m_EditorClassIdentifier: |
|||
CurrentState: |
|||
debug: 1 |
|||
_initialStateSO: {fileID: 11400000, guid: 4b9ef9df9c479aa469d161e9019b218e, type: 2} |
|||
_scriptableObjects: [] |
|
|||
fileFormatVersion: 2 |
|||
guid: 2ae670cd29a6f4843aa75201aa44ef31 |
|||
PrefabImporter: |
|||
externalObjects: {} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
%YAML 1.1 |
|||
%TAG !u! tag:unity3d.com,2011: |
|||
--- !u!114 &11400000 |
|||
MonoBehaviour: |
|||
m_ObjectHideFlags: 0 |
|||
m_CorrespondingSourceObject: {fileID: 0} |
|||
m_PrefabInstance: {fileID: 0} |
|||
m_PrefabAsset: {fileID: 0} |
|||
m_GameObject: {fileID: 0} |
|||
m_Enabled: 1 |
|||
m_EditorHideFlags: 0 |
|||
m_Script: {fileID: 11500000, guid: 9ea14bb700bdcb64e9855f6bd0837d08, type: 3} |
|||
m_Name: AttackDurationOverride |
|||
m_EditorClassIdentifier: |
|||
Duration: 0.2 |
|
|||
fileFormatVersion: 2 |
|||
guid: de18ec8184ba9ec418cfb61f39582a79 |
|||
NativeFormatImporter: |
|||
externalObjects: {} |
|||
mainObjectFileID: 0 |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
%YAML 1.1 |
|||
%TAG !u! tag:unity3d.com,2011: |
|||
--- !u!114 &11400000 |
|||
MonoBehaviour: |
|||
m_ObjectHideFlags: 0 |
|||
m_CorrespondingSourceObject: {fileID: 0} |
|||
m_PrefabInstance: {fileID: 0} |
|||
m_PrefabAsset: {fileID: 0} |
|||
m_GameObject: {fileID: 0} |
|||
m_Enabled: 1 |
|||
m_EditorHideFlags: 0 |
|||
m_Script: {fileID: 11500000, guid: 9ea14bb700bdcb64e9855f6bd0837d08, type: 3} |
|||
m_Name: EatDurationOverride |
|||
m_EditorClassIdentifier: |
|||
Duration: 3 |
|
|||
fileFormatVersion: 2 |
|||
guid: 2af0b23535059f54dbaef36909481aea |
|||
NativeFormatImporter: |
|||
externalObjects: {} |
|||
mainObjectFileID: 0 |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
撰写
预览
正在加载...
取消
保存
Reference in new issue