slimecing

a fighting game featuring slimes and swords
Log | Files | Refs | README

StateChanger.cs (651B)


      1 using System;
      2 using System.Collections.Generic;
      3 using UnityEngine;
      4 
      5 namespace Slimecing.StateMachine
      6 {
      7     [Serializable]
      8     public class StateChanger
      9     {
     10         [SerializeField] private State nextState = null;
     11         [SerializeField] private List<StateChangerCondition> conditions = new List<StateChangerCondition>();
     12 
     13         public State NextState => nextState;
     14 
     15         public bool ShouldChange()
     16         {
     17             foreach (var condition in conditions)
     18             {
     19                 if (!condition.IsMet())
     20                 {
     21                     return false;
     22                 }
     23             }
     24 
     25             return true;
     26         }
     27     }
     28 }