Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class Ajdaha:Enemy
- {
- }
- public enum EnemyState
- {
- idle,
- run,
- attack
- }
- public abstract class StatableBehaviour:Monobehaviour
- {
- public EnemyState currentState;
- public virtual void StateBehaviour(EnemyState state) => if(state != currentState) return;
- }
- public class Move: StatableBehaviour
- {
- void Start()
- {
- currentState = EnemyState.run;
- }
- public override void StateBehaviour(EnemyState state){
- base.StateBehaviour();
- transform.position += Vector3.one;
- }
- }
- public abstract class Enemy:Monobehaviour
- {
- private EnemyState state;
- public EnemyState State{
- get => return state;
- set {
- state = value;
- onStateChanged?.Invoke(state);
- }
- }
- public event Action<EventState state> onStateChanged;
- public StatableBehaviour[] behaviours;
- void Start()
- {
- foreach(var t in behaviours)
- {
- onStateChanged += t.StateBehaviour;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement