Пример #1
0
    public IEnumerator StateChangeTransition(ObjectStateLegacy newStateLegacy)
    {
        if (StateChangeLocked == false)
        {
            StateChangeLocked = true;
            yield return(StartCoroutine(currentStateLegacy.InvokeExitStateFunctions()));

            yield return(StartCoroutine(newStateLegacy.InvokeEnterStateFunctions()));

            Debug.Log("State Transition from " + currentStateLegacy.stateName + " to " + newStateLegacy.stateName + " Finished");
            currentStateLegacy = newStateLegacy;
            if (newStateLegacy.isFinalState == true)
            {
                StateChangeLocked = true;
            }
            else
            {
                StateChangeLocked = false;
            }
        }
        else
        {
            Debug.Log("State Change is Locked");
        }
        yield break;
    }
Пример #2
0
    public IEnumerator StateChangeTransition(ObjectStateLegacy newStateLegacy)
    {
        if (StateChangeLocked == false && ConditionToChangeToNewState(currentStateLegacy, newStateLegacy) == true)
        {
            OnStateChange();
            InitilizeAttackCoroutine(null);
            InitilizeMovementCoroutine(null);
            currentStateLegacy = newStateLegacy;
            StateInTransition  = true;
//            Debug.Log("Changed to State :" + _newState.stateName);
            yield return(StartCoroutine(currentStateLegacy.InvokeExitStateFunctions()));

            yield return(StartCoroutine(newStateLegacy.InvokeEnterStateFunctions()));

//            Debug.Log("State Transition from " + CurrentState.stateName + " to " + _newState.stateName + " Finished" );
            StateInTransition = false;
            if (newStateLegacy.isFinalState == true)
            {
                StateChangeLocked = true;
            }
            else
            {
                StateChangeLocked = false;
            }
        }
        else
        {
            Debug.Log("State change lock is : " + StateChangeLocked.ToString());
        }
        yield break;
    }
Пример #3
0
 public void AddState(ObjectStateLegacy _unitstate)
 {
     if (_unitstate != null)
     {
         States.Add(_unitstate.stateName, _unitstate);
     }
 }
Пример #4
0
 public static bool StandardEnterDirectBattleCondition(ObjectStateLegacy us, EnemyUnitController ec, NormalUnitStates states)
 {
     if (us == states.Default || us == states.PostBattle)
     {
         return(true);
     }
     return(false);
 }
Пример #5
0
 public void SetState(ObjectStateLegacy newStateLegacy)
 {
     if (StateChangeLocked != true)
     {
         StartCoroutine(StateChangeTransition(newStateLegacy));
     }
     else
     {
         if (currentStateLegacy.IsFinalState == true)
         {
             Debug.Log(currentStateLegacy.stateName + " is a final state");
         }
         else
         {
             Debug.Log("Could not change state from " + currentStateLegacy.stateName + " to " + newStateLegacy.stateName + " because STATE CHANGE LOCK is active");
         }
     }
 }
Пример #6
0
 public bool ConditionToChangeToNewState(ObjectStateLegacy _cur, ObjectStateLegacy _new)
 {
     if (currentStateLegacy.ExitEventIsNotEmpty())
     {
         if (_new.EnterEventIsNotEmpty())
         {
             return(true);
         }
         else
         {
             Debug.Log(_new.stateName + " Enter Sequence Is Empty");
             return(false);
         }
     }
     else
     {
         Debug.Log(_cur.stateName + " Exit Sequence Is Empty");
         return(false);
     }
 }
Пример #7
0
 public void RemoveState(ObjectStateLegacy _unitstate)
 {
     States.Remove(_unitstate.stateName);
 }