Пример #1
0
 private void ExitState(IState state)
 {
     //Log.Always($"Exiting State {GetId(state)}");
     if (state is IStateExit s)
     {
         s.OnExit();
     }
     if (state is IStateAsyncExit a)
     {
         CoroutineManager.StartRoutine(a.OnExit());
     }
     foreach (var transition in _currentTransitions)
     {
         transition.Disable();
     }
 }
Пример #2
0
 private void ExitInternalStates()
 {
     if (!_hasInternal)
     {
         return;
     }
     foreach (var state in _internal)
     {
         if (state is IStateExit s)
         {
             s.OnExit();
         }
         if (state is IStateAsyncExit a)
         {
             CoroutineManager.StartRoutine(a.OnExit());
         }
     }
 }
Пример #3
0
        public static void CreatePopup(string text, float popupTime, float3 finalPosition, float3 localPosition = default, Color?color = null, Transform parent = null, int fontSize = 40)
        {
            TextMesh  textMesh   = Create(text, localPosition, color, parent, fontSize, TextAnchor.LowerLeft);
            Transform transform  = textMesh.transform;
            Vector3   moveAmount = (finalPosition - localPosition) / popupTime;

            CoroutineManager.StartRoutine(() =>
            {
                transform.position += moveAmount * Time.deltaTime;
                popupTime          -= Time.deltaTime;
                if (!(popupTime <= 0f))
                {
                    return(false);
                }
                transform.Destroy();
                return(true);
            });
        }
Пример #4
0
 private void EnterState(IState state)
 {
     //Log.Always($"Entering State {GetId(state)}");
     _transitions.TryGetValue(GetId(state), out _currentTransitions);
     if (_currentTransitions == null)
     {
         _currentTransitions = Empty;
     }
     foreach (var transition in _currentTransitions)
     {
         transition.Enable();
     }
     if (state is IStateEnter s)
     {
         s.OnEnter();
     }
     if (state is IStateAsyncEnter a)
     {
         CoroutineManager.StartRoutine(a.OnEnter());
     }
 }
Пример #5
0
 public CoroutineWrapper Start()
 {
     _routine = CoroutineManager.StartRoutine(Wrapper(_target));
     return(this);
 }
Пример #6
0
 public void Start()
 {
     OnEnter();
     _routine   = CoroutineManager.StartRoutine(Wrapper());
     _isStarted = true;
 }