feat/state #2
8
.idea/.idea.SpringJam2026/.idea/workspace.xml
generated
8
.idea/.idea.SpringJam2026/.idea/workspace.xml
generated
@ -5,9 +5,7 @@
|
|||||||
</component>
|
</component>
|
||||||
<component name="ChangeListManager">
|
<component name="ChangeListManager">
|
||||||
<list default="true" id="60468364-7d9c-427f-83f9-f6cd83ef8783" name="Changes" comment="">
|
<list default="true" id="60468364-7d9c-427f-83f9-f6cd83ef8783" name="Changes" comment="">
|
||||||
<change beforePath="$PROJECT_DIR$/Assets/Scenes/SampleScene.unity" beforeDir="false" />
|
<change beforePath="$PROJECT_DIR$/.idea/.idea.SpringJam2026/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/.idea.SpringJam2026/.idea/workspace.xml" afterDir="false" />
|
||||||
<change beforePath="$PROJECT_DIR$/Assets/Scenes/SampleScene.unity.meta" beforeDir="false" />
|
|
||||||
<change beforePath="$PROJECT_DIR$/ProjectSettings/EditorBuildSettings.asset" beforeDir="false" afterPath="$PROJECT_DIR$/ProjectSettings/EditorBuildSettings.asset" afterDir="false" />
|
|
||||||
</list>
|
</list>
|
||||||
<option name="SHOW_DIALOG" value="false" />
|
<option name="SHOW_DIALOG" value="false" />
|
||||||
<option name="HIGHLIGHT_CONFLICTS" value="true" />
|
<option name="HIGHLIGHT_CONFLICTS" value="true" />
|
||||||
@ -34,7 +32,7 @@
|
|||||||
"ModuleVcsDetector.initialDetectionPerformed": "true",
|
"ModuleVcsDetector.initialDetectionPerformed": "true",
|
||||||
"RunOnceActivity.ShowReadmeOnStart": "true",
|
"RunOnceActivity.ShowReadmeOnStart": "true",
|
||||||
"RunOnceActivity.git.unshallow": "true",
|
"RunOnceActivity.git.unshallow": "true",
|
||||||
"git-widget-placeholder": "feature/services",
|
"git-widget-placeholder": "main",
|
||||||
"ignore.virus.scanning.warn.message": "true",
|
"ignore.virus.scanning.warn.message": "true",
|
||||||
"node.js.detected.package.eslint": "true",
|
"node.js.detected.package.eslint": "true",
|
||||||
"node.js.detected.package.tslint": "true",
|
"node.js.detected.package.tslint": "true",
|
||||||
@ -108,7 +106,7 @@
|
|||||||
<option name="number" value="Default" />
|
<option name="number" value="Default" />
|
||||||
<option name="presentableId" value="Default" />
|
<option name="presentableId" value="Default" />
|
||||||
<updated>1777050991106</updated>
|
<updated>1777050991106</updated>
|
||||||
<workItem from="1777050993247" duration="1296000" />
|
<workItem from="1777050993247" duration="1899000" />
|
||||||
</task>
|
</task>
|
||||||
<servers />
|
<servers />
|
||||||
</component>
|
</component>
|
||||||
|
|||||||
8
Assets/Scripts/State.meta
Normal file
8
Assets/Scripts/State.meta
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 67f88045e5c39dd42af3559790c4c117
|
||||||
|
folderAsset: yes
|
||||||
|
DefaultImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
17
Assets/Scripts/State/GameState.cs
Normal file
17
Assets/Scripts/State/GameState.cs
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
using UnityEngine;
|
||||||
|
|
||||||
|
namespace State
|
||||||
|
{
|
||||||
|
public class GameState
|
||||||
|
{
|
||||||
|
protected Machine StateMachine;
|
||||||
|
public virtual void OnEnter(Machine machine)
|
||||||
|
{
|
||||||
|
StateMachine = machine;
|
||||||
|
}
|
||||||
|
|
||||||
|
public virtual void OnExit() {}
|
||||||
|
public virtual void OnUpdate(float deltaTime) {}
|
||||||
|
public virtual void OnFixedUpdate(float deltaTime) {}
|
||||||
|
}
|
||||||
|
}
|
||||||
2
Assets/Scripts/State/GameState.cs.meta
Normal file
2
Assets/Scripts/State/GameState.cs.meta
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: aece5e36c5691b84592b559518dc979c
|
||||||
26
Assets/Scripts/State/Machine.cs
Normal file
26
Assets/Scripts/State/Machine.cs
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
using UnityEngine;
|
||||||
|
|
||||||
|
namespace State
|
||||||
|
{
|
||||||
|
public class Machine : MonoBehaviour
|
||||||
|
{
|
||||||
|
private GameState _currentState;
|
||||||
|
|
||||||
|
public void Update()
|
||||||
|
{
|
||||||
|
_currentState?.OnUpdate(Time.deltaTime);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void FixedUpdate()
|
||||||
|
{
|
||||||
|
_currentState?.OnFixedUpdate(Time.fixedDeltaTime);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void ChangeState(GameState newState)
|
||||||
|
{
|
||||||
|
_currentState?.OnExit();
|
||||||
|
_currentState = newState;
|
||||||
|
_currentState.OnEnter(this);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
2
Assets/Scripts/State/Machine.cs.meta
Normal file
2
Assets/Scripts/State/Machine.cs.meta
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: c58c43f9d69af404f997461c6348049d
|
||||||
Loading…
x
Reference in New Issue
Block a user