1
This commit is contained in:
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: abc53960d2470184c807cea21744653e
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,37 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
namespace MuHua
|
||||
{
|
||||
public abstract class Machine : MonoBehaviour
|
||||
{
|
||||
protected MachineState currentState;
|
||||
protected Dictionary<string, MachineState> states = new Dictionary<string, MachineState>();
|
||||
|
||||
protected virtual void Start() => InitializeStates();
|
||||
|
||||
protected virtual void Update() => currentState?.Update();
|
||||
|
||||
protected abstract void InitializeStates();
|
||||
|
||||
protected virtual void RegisterState(string stateType, MachineState state)
|
||||
{
|
||||
if (!states.ContainsKey(stateType)) { states.Add(stateType, state); }
|
||||
}
|
||||
|
||||
public virtual void ChangeState(string stateType)
|
||||
{
|
||||
if (states.ContainsKey(stateType))
|
||||
{
|
||||
currentState?.Exit();
|
||||
currentState = states[stateType];
|
||||
currentState.Enter();
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.LogWarning($"State {stateType} is not registered.");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 0cd74b3acde213f489a11a9e0ccd81e7
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,17 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
namespace MuHua
|
||||
{
|
||||
public abstract class MachineState
|
||||
{
|
||||
protected Machine machine;
|
||||
|
||||
public MachineState(Machine machine) => this.machine = machine;
|
||||
|
||||
public abstract void Enter();
|
||||
public abstract void Update();
|
||||
public abstract void Exit();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 18d0a64357fbec04d8fbd51d45c88e4b
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,14 @@
|
||||
{
|
||||
"name": "MuHua.FSM",
|
||||
"rootNamespace": "",
|
||||
"references": [],
|
||||
"includePlatforms": [],
|
||||
"excludePlatforms": [],
|
||||
"allowUnsafeCode": false,
|
||||
"overrideReferences": false,
|
||||
"precompiledReferences": [],
|
||||
"autoReferenced": true,
|
||||
"defineConstraints": [],
|
||||
"versionDefines": [],
|
||||
"noEngineReferences": false
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 856a56044e2bfce4dbc2d22bfb5a926f
|
||||
AssemblyDefinitionImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 3e92c6f04caccae40bb8e24b5307132d
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,18 @@
|
||||
{
|
||||
"name": "muhua-finite-state-machine",
|
||||
"version": "1.0.0",
|
||||
"displayName": "MuHua FSM",
|
||||
"description": "\u6709\u9650\u72b6\u6001\u673a\u6846\u67b6",
|
||||
"author": {
|
||||
"name": "MuHua",
|
||||
"email": "2960208585@qq.com"
|
||||
},
|
||||
"type": "tool",
|
||||
"samples": [
|
||||
{
|
||||
"displayName": "Label Follow Example",
|
||||
"description": "An example showing how to use the Label Follow system.",
|
||||
"path": "Samples~"
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ab0f2027431743d43afe689084dcd33c
|
||||
PackageManifestImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,14 @@
|
||||
{
|
||||
"name": "MuHua.LabelFollow",
|
||||
"rootNamespace": "",
|
||||
"references": [],
|
||||
"includePlatforms": [],
|
||||
"excludePlatforms": [],
|
||||
"allowUnsafeCode": false,
|
||||
"overrideReferences": false,
|
||||
"precompiledReferences": [],
|
||||
"autoReferenced": true,
|
||||
"defineConstraints": [],
|
||||
"versionDefines": [],
|
||||
"noEngineReferences": false
|
||||
}
|
||||
@@ -1,3 +0,0 @@
|
||||
{
|
||||
"name": "MuHua"
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: d9d7dc56eb286ef44869e5c4a543a365
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -215,6 +215,12 @@
|
||||
},
|
||||
"url": "https://packages.unity.cn"
|
||||
},
|
||||
"muhua-finite-state-machine": {
|
||||
"version": "file:FSM",
|
||||
"depth": 0,
|
||||
"source": "embedded",
|
||||
"dependencies": {}
|
||||
},
|
||||
"muhua-label-follow": {
|
||||
"version": "file:LabelFollow",
|
||||
"depth": 0,
|
||||
|
||||
Reference in New Issue
Block a user