This repository has been archived on 2024-11-28. You can view files and clone it, but cannot push or open issues or pull requests.
PMC_Projekt/ProjektUnity/Assets/Enemy 2/BasicEnemy/Interfaces/BasicEnemyStateController.cs

43 lines
1.1 KiB
C#
Raw Normal View History

2024-09-05 21:10:50 +02:00
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class BasicEnemyStateController : MonoBehaviour
{
IState currentState;
BasicenemyBaseState currentStatee;
public BasicEnemyPatrolState patrolState = new BasicEnemyPatrolState();
public BasicEnemyMovingState movingState = new BasicEnemyMovingState();
public BasicEnemyShootingState ShootingState = new BasicEnemyShootingState();
private void Start()
{
ChangeState(patrolState);
}
void Update()
{
if(currentState != null)
{
currentState.UpdateState(this);
}
}
public void ChangeState(IState newState)
{
if(currentState != null)
{
currentState.OnExit(this);
}
currentState = newState;
currentState.OnEnter(this);
}
}
public interface IState
{
public void OnEnter(BasicEnemyStateController controller);
public void UpdateState(BasicEnemyStateController controller);
public void OnExit(BasicEnemyStateController controller);
}