You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
41 lines
791 B
41 lines
791 B
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
|
|
namespace Moloch
|
|
{
|
|
public class StateMachine : MonoBehaviour
|
|
{
|
|
BaseState m_currentState;
|
|
|
|
void Start ()
|
|
{
|
|
m_currentState = GetInitialState();
|
|
|
|
if (m_currentState != null)
|
|
m_currentState.Enter();
|
|
}
|
|
|
|
void FixedUpdate()
|
|
{
|
|
if (m_currentState != null)
|
|
m_currentState.UpdateLogic();
|
|
}
|
|
|
|
public void SwitchState(BaseState nextState)
|
|
{
|
|
m_currentState.Exit();
|
|
m_currentState = nextState;
|
|
m_currentState.Enter();
|
|
}
|
|
|
|
protected virtual BaseState GetInitialState()
|
|
{
|
|
return null;
|
|
}
|
|
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|